This commit is contained in:
lukaseder 2019-05-10 16:43:43 +02:00
parent 4aa834c8d0
commit 00dbe54d69
4 changed files with 54 additions and 22 deletions

View File

@ -140,9 +140,9 @@ public class Settings
@XmlElement(type = String.class, defaultValue = "DEFAULT")
@XmlJavaTypeAdapter(SQLDialectAdapter.class)
protected SQLDialect parseDialect;
@XmlElement(defaultValue = "IGNORE_ON_FAILURE")
@XmlElement(defaultValue = "OFF")
@XmlSchemaType(name = "string")
protected ParseWithMetaLookups parseWithMetaLookups = ParseWithMetaLookups.IGNORE_ON_FAILURE;
protected ParseWithMetaLookups parseWithMetaLookups = ParseWithMetaLookups.OFF;
@XmlElement(defaultValue = "IGNORE")
@XmlSchemaType(name = "string")
protected ParseUnsupportedSyntax parseUnsupportedSyntax = ParseUnsupportedSyntax.IGNORE;

View File

@ -62,6 +62,14 @@ import org.jooq.InsertResultStep;
import org.jooq.InsertSetMoreStep;
import org.jooq.InsertSetStep;
import org.jooq.InsertValuesStep1;
import org.jooq.InsertValuesStep2;
import org.jooq.InsertValuesStep3;
import org.jooq.InsertValuesStep4;
import org.jooq.InsertValuesStep5;
import org.jooq.InsertValuesStep6;
import org.jooq.InsertValuesStep7;
import org.jooq.InsertValuesStep8;
import org.jooq.InsertValuesStep9;
import org.jooq.InsertValuesStep10;
import org.jooq.InsertValuesStep11;
import org.jooq.InsertValuesStep12;
@ -72,23 +80,23 @@ import org.jooq.InsertValuesStep16;
import org.jooq.InsertValuesStep17;
import org.jooq.InsertValuesStep18;
import org.jooq.InsertValuesStep19;
import org.jooq.InsertValuesStep2;
import org.jooq.InsertValuesStep20;
import org.jooq.InsertValuesStep21;
import org.jooq.InsertValuesStep22;
import org.jooq.InsertValuesStep3;
import org.jooq.InsertValuesStep4;
import org.jooq.InsertValuesStep5;
import org.jooq.InsertValuesStep6;
import org.jooq.InsertValuesStep7;
import org.jooq.InsertValuesStep8;
import org.jooq.InsertValuesStep9;
import org.jooq.InsertValuesStepN;
import org.jooq.Name;
import org.jooq.Operator;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record2;
import org.jooq.Record3;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.Record9;
import org.jooq.Record10;
import org.jooq.Record11;
import org.jooq.Record12;
@ -99,17 +107,9 @@ import org.jooq.Record16;
import org.jooq.Record17;
import org.jooq.Record18;
import org.jooq.Record19;
import org.jooq.Record2;
import org.jooq.Record20;
import org.jooq.Record21;
import org.jooq.Record22;
import org.jooq.Record3;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.Record9;
import org.jooq.Result;
import org.jooq.SQL;
import org.jooq.Select;

View File

@ -8269,7 +8269,7 @@ final class ParserImpl implements Parser {
}
private static final Table<?> parseTableName(ParserContext ctx) {
return table(parseName(ctx));
return ctx.tableLookup(parseName(ctx));
}
private static final Table<?> parseTableNameIf(ParserContext ctx) {
@ -8317,7 +8317,7 @@ final class ParserImpl implements Parser {
return field(name);
return ctx.lookupField(name);
}
}
@ -8412,7 +8412,7 @@ final class ParserImpl implements Parser {
}
else {
parse(ctx, '*');
return table(result == null ? i1 : DSL.name(result.toArray(EMPTY_NAME))).asterisk();
return ctx.tableLookup(result == null ? i1 : DSL.name(result.toArray(EMPTY_NAME))).asterisk();
}
}
while (parseIf(ctx, '.'));
@ -10263,6 +10263,38 @@ final class ParserContext {
+ (sqlString.length() > position + 80 ? "..." : "");
}
Table<?> tableLookup(Name name) {
if (meta != null) {
List<Table<?>> tables = meta.getTables(name);
if (tables.size() == 1)
return tables.get(0);
}
if (metaLookups == THROW_ON_FAILURE)
throw exception("Unknown table identifier");
return table(name);
}
Field<?> lookupField(Name name) {
if (meta != null) {
List<Table<?>> tables = meta.getTables(name.qualifier());
if (tables.size() == 1) {
Field<?> field = tables.get(0).field(name);
if (field != null)
return field;
}
}
if (metaLookups == THROW_ON_FAILURE)
throw exception("Unknown field identifier");
return field(name);
}
@Override
public String toString() {
return mark();

View File

@ -298,7 +298,7 @@ jOOQ queries, for which no specific fetchSize value was specified.]]></jxb:javad
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[[#7337] The input dialect that should be chosen to disambiguate ambiguous SQL syntax.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="parseWithMetaLookups" type="jooq-runtime:ParseWithMetaLookups" minOccurs="0" maxOccurs="1" default="IGNORE_ON_FAILURE">
<element name="parseWithMetaLookups" type="jooq-runtime:ParseWithMetaLookups" minOccurs="0" maxOccurs="1" default="OFF">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[[#7163] Whether the parser should perform meta lookups in the Configuration's MetaProvider.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>