[jOOQ/jOOQ#9238] Add a new Settings.parseNameCase
Implemented all cases except DEFAULT
This commit is contained in:
parent
bf127abe88
commit
b2a20cc2eb
46
jOOQ/src/main/java/org/jooq/conf/ParseNameCase.java
Normal file
46
jOOQ/src/main/java/org/jooq/conf/ParseNameCase.java
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
package org.jooq.conf;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for ParseNameCase.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="ParseNameCase">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="AS_IS"/>
|
||||
* <enumeration value="LOWER"/>
|
||||
* <enumeration value="LOWER_IF_UNQUOTED"/>
|
||||
* <enumeration value="UPPER"/>
|
||||
* <enumeration value="UPPER_IF_UNQUOTED"/>
|
||||
* <enumeration value="DEFAULT"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "ParseNameCase")
|
||||
@XmlEnum
|
||||
public enum ParseNameCase {
|
||||
|
||||
AS_IS,
|
||||
LOWER,
|
||||
LOWER_IF_UNQUOTED,
|
||||
UPPER,
|
||||
UPPER_IF_UNQUOTED,
|
||||
DEFAULT;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static ParseNameCase fromValue(String v) {
|
||||
return valueOf(v);
|
||||
}
|
||||
|
||||
}
|
||||
@ -193,6 +193,9 @@ public class Settings
|
||||
@XmlElement(type = String.class, defaultValue = "DEFAULT")
|
||||
@XmlJavaTypeAdapter(SQLDialectAdapter.class)
|
||||
protected SQLDialect parseDialect;
|
||||
@XmlElement(defaultValue = "DEFAULT")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected ParseNameCase parseNameCase = ParseNameCase.DEFAULT;
|
||||
@XmlElement(defaultValue = "OFF")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected ParseWithMetaLookups parseWithMetaLookups = ParseWithMetaLookups.OFF;
|
||||
@ -1623,6 +1626,22 @@ public class Settings
|
||||
this.parseDialect = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* [#7337] The default name case for parsed identifiers.
|
||||
*
|
||||
*/
|
||||
public ParseNameCase getParseNameCase() {
|
||||
return parseNameCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* [#7337] The default name case for parsed identifiers.
|
||||
*
|
||||
*/
|
||||
public void setParseNameCase(ParseNameCase value) {
|
||||
this.parseNameCase = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* [#7163] Whether the parser should perform meta lookups in the Configuration's MetaProvider.
|
||||
*
|
||||
@ -2263,6 +2282,15 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* [#7337] The default name case for parsed identifiers.
|
||||
*
|
||||
*/
|
||||
public Settings withParseNameCase(ParseNameCase value) {
|
||||
setParseNameCase(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* [#7163] Whether the parser should perform meta lookups in the Configuration's MetaProvider.
|
||||
*
|
||||
@ -2401,6 +2429,7 @@ public class Settings
|
||||
builder.append("executeDeleteWithoutWhere", executeDeleteWithoutWhere);
|
||||
builder.append("interpreterDialect", interpreterDialect);
|
||||
builder.append("parseDialect", parseDialect);
|
||||
builder.append("parseNameCase", parseNameCase);
|
||||
builder.append("parseWithMetaLookups", parseWithMetaLookups);
|
||||
builder.append("parseUnsupportedSyntax", parseUnsupportedSyntax);
|
||||
builder.append("parseUnknownFunctions", parseUnknownFunctions);
|
||||
@ -3014,6 +3043,15 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (parseNameCase == null) {
|
||||
if (other.parseNameCase!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!parseNameCase.equals(other.parseNameCase)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (parseWithMetaLookups == null) {
|
||||
if (other.parseWithMetaLookups!= null) {
|
||||
return false;
|
||||
@ -3149,6 +3187,7 @@ public class Settings
|
||||
result = ((prime*result)+((executeDeleteWithoutWhere == null)? 0 :executeDeleteWithoutWhere.hashCode()));
|
||||
result = ((prime*result)+((interpreterDialect == null)? 0 :interpreterDialect.hashCode()));
|
||||
result = ((prime*result)+((parseDialect == null)? 0 :parseDialect.hashCode()));
|
||||
result = ((prime*result)+((parseNameCase == null)? 0 :parseNameCase.hashCode()));
|
||||
result = ((prime*result)+((parseWithMetaLookups == null)? 0 :parseWithMetaLookups.hashCode()));
|
||||
result = ((prime*result)+((parseUnsupportedSyntax == null)? 0 :parseUnsupportedSyntax.hashCode()));
|
||||
result = ((prime*result)+((parseUnknownFunctions == null)? 0 :parseUnknownFunctions.hashCode()));
|
||||
|
||||
@ -50,6 +50,7 @@ import static org.jooq.JoinType.JOIN;
|
||||
// ...
|
||||
import static org.jooq.conf.ParseWithMetaLookups.IGNORE_ON_FAILURE;
|
||||
import static org.jooq.conf.ParseWithMetaLookups.THROW_ON_FAILURE;
|
||||
import static org.jooq.conf.SettingsTools.renderLocale;
|
||||
import static org.jooq.impl.AbstractName.NO_NAME;
|
||||
import static org.jooq.impl.DSL.abs;
|
||||
import static org.jooq.impl.DSL.acos;
|
||||
@ -310,6 +311,7 @@ import static org.jooq.impl.Tools.EMPTY_NAME;
|
||||
import static org.jooq.impl.Tools.EMPTY_QUERYPART;
|
||||
import static org.jooq.impl.Tools.EMPTY_ROWN;
|
||||
import static org.jooq.impl.Tools.EMPTY_SORTFIELD;
|
||||
import static org.jooq.tools.StringUtils.defaultIfNull;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
@ -484,6 +486,7 @@ import org.jooq.WindowSpecificationExcludeStep;
|
||||
import org.jooq.WindowSpecificationOrderByStep;
|
||||
import org.jooq.WindowSpecificationRowsAndStep;
|
||||
import org.jooq.WindowSpecificationRowsStep;
|
||||
import org.jooq.conf.ParseNameCase;
|
||||
import org.jooq.conf.ParseSearchSchema;
|
||||
import org.jooq.conf.ParseUnknownFunctions;
|
||||
import org.jooq.conf.ParseUnsupportedSyntax;
|
||||
@ -9201,6 +9204,33 @@ final class ParserImpl implements Parser {
|
||||
|
||||
String result = ctx.substring(start, ctx.position());
|
||||
|
||||
switch (defaultIfNull(ctx.settings().getParseNameCase(), ParseNameCase.DEFAULT)) {
|
||||
case LOWER_IF_UNQUOTED:
|
||||
if (quoteEnd != 0)
|
||||
break;
|
||||
|
||||
// no-break
|
||||
|
||||
case LOWER:
|
||||
result = result.toLowerCase(renderLocale(ctx.settings()));
|
||||
break;
|
||||
|
||||
case UPPER_IF_UNQUOTED:
|
||||
if (quoteEnd != 0)
|
||||
break;
|
||||
|
||||
// no-break
|
||||
case UPPER:
|
||||
result = result.toUpperCase(renderLocale(ctx.settings()));
|
||||
break;
|
||||
|
||||
case AS_IS:
|
||||
case DEFAULT:
|
||||
default:
|
||||
// Keep result
|
||||
break;
|
||||
}
|
||||
|
||||
if (quoteEnd != 0) {
|
||||
if (ctx.character() != quoteEnd)
|
||||
throw ctx.exception("Quoted identifier must terminate in " + quoteEnd);
|
||||
|
||||
@ -395,6 +395,10 @@ 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="parseNameCase" type="jooq-runtime:ParseNameCase" minOccurs="0" maxOccurs="1" default="DEFAULT">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[[#7337] The default name case for parsed identifiers.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<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>
|
||||
@ -799,6 +803,29 @@ Either <input/> or <inputExpression/> must be provided]]></jxb:javad
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="ParseNameCase">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Parse object names, as defined in the database. For instance: schema.TABLE -->
|
||||
<enumeration value="AS_IS"/>
|
||||
|
||||
<!-- Force parsing object names in lower case. For instance: schema."table" -->
|
||||
<enumeration value="LOWER"/>
|
||||
|
||||
<!-- Force parsing object names in lower case, if unquoted. For instance schema."TABLE" -->
|
||||
<enumeration value="LOWER_IF_UNQUOTED"/>
|
||||
|
||||
<!-- Force parsing object names in upper case. For instance: SCHEMA."TABLE" -->
|
||||
<enumeration value="UPPER"/>
|
||||
|
||||
<!-- Force parsing object names in upper case, if unquoted. For instance SCHEMA."table" -->
|
||||
<enumeration value="UPPER_IF_UNQUOTED"/>
|
||||
|
||||
<!-- Apply the parse dialect specific default behaviour -->
|
||||
<enumeration value="DEFAULT"></enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="ParseWithMetaLookups">
|
||||
<restriction base="string">
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user