[#5955] Support VALUES constructor
This commit is contained in:
parent
7cbf0390f5
commit
cb3375f45a
@ -150,6 +150,7 @@ import static org.jooq.impl.DSL.reverse;
|
||||
import static org.jooq.impl.DSL.right;
|
||||
import static org.jooq.impl.DSL.rollup;
|
||||
import static org.jooq.impl.DSL.round;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.rowNumber;
|
||||
import static org.jooq.impl.DSL.rownum;
|
||||
import static org.jooq.impl.DSL.rowsBetweenCurrentRow;
|
||||
@ -184,6 +185,7 @@ import static org.jooq.impl.DSL.time;
|
||||
import static org.jooq.impl.DSL.timestamp;
|
||||
import static org.jooq.impl.DSL.trim;
|
||||
import static org.jooq.impl.DSL.unique;
|
||||
import static org.jooq.impl.DSL.values;
|
||||
import static org.jooq.impl.DSL.varPop;
|
||||
import static org.jooq.impl.DSL.varSamp;
|
||||
import static org.jooq.impl.DSL.when;
|
||||
@ -267,6 +269,7 @@ import org.jooq.Queries;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RowN;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Sequence;
|
||||
@ -1784,6 +1787,10 @@ class ParserImpl implements Parser {
|
||||
result = table(parseSelect(ctx));
|
||||
parse(ctx, ')');
|
||||
}
|
||||
else if (peekKeyword(ctx, "VALUES")) {
|
||||
result = parseTableValueConstructor(ctx);
|
||||
parse(ctx, ')');
|
||||
}
|
||||
else {
|
||||
int parens = 0;
|
||||
|
||||
@ -1826,6 +1833,24 @@ class ParserImpl implements Parser {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final Table<?> parseTableValueConstructor(ParserContext ctx) {
|
||||
parseKeyword(ctx, "VALUES");
|
||||
|
||||
List<RowN> rows = new ArrayList<RowN>();
|
||||
do {
|
||||
rows.add(parseRow(ctx));
|
||||
}
|
||||
while (parseIf(ctx, ','));
|
||||
return values(rows.toArray(Tools.EMPTY_ROWN));
|
||||
}
|
||||
|
||||
private static final RowN parseRow(ParserContext ctx) {
|
||||
parse(ctx, '(');
|
||||
RowN row = row(parseFields(ctx));
|
||||
parse(ctx, ')');
|
||||
return row;
|
||||
}
|
||||
|
||||
private static final Table<?> parseJoinedTable(ParserContext ctx) {
|
||||
Table<?> result = parseTableFactor(ctx);
|
||||
|
||||
|
||||
@ -144,6 +144,7 @@ import org.jooq.RenderContext.CastMode;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.Results;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.RowN;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Select;
|
||||
@ -193,6 +194,7 @@ final class Tools {
|
||||
static final Query[] EMPTY_QUERY = {};
|
||||
static final QueryPart[] EMPTY_QUERYPART = {};
|
||||
static final Record[] EMPTY_RECORD = {};
|
||||
static final RowN[] EMPTY_ROWN = {};
|
||||
static final String[] EMPTY_STRING = {};
|
||||
static final Name[] EMPTY_NAME = {};
|
||||
static final TableRecord<?>[] EMPTY_TABLE_RECORD = {};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user