[jOOQ/jOOQ#11694] Parse TO_DATE(string) and TO_TIMESTAMP(string)
This commit is contained in:
parent
50825f5e1b
commit
7b7cd0e79f
@ -261,6 +261,10 @@ public class Settings
|
||||
@XmlElement(type = String.class)
|
||||
@XmlJavaTypeAdapter(LocaleAdapter.class)
|
||||
protected Locale parseLocale;
|
||||
@XmlElement(defaultValue = "YYYY-MM-DD")
|
||||
protected String parseDateFormat = "YYYY-MM-DD";
|
||||
@XmlElement(defaultValue = "YYYY-MM-DD HH24:MI:SS.FF")
|
||||
protected String parseTimestampFormat = "YYYY-MM-DD HH24:MI:SS.FF";
|
||||
@XmlElement(defaultValue = "DEFAULT")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected ParseNameCase parseNameCase = ParseNameCase.DEFAULT;
|
||||
@ -2353,6 +2357,38 @@ public class Settings
|
||||
this.parseLocale = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The date format to use when parsing functions whose behaviour depends on some session date format, such as NLS_DATE_FORMAT in Oracle
|
||||
*
|
||||
*/
|
||||
public String getParseDateFormat() {
|
||||
return parseDateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* The date format to use when parsing functions whose behaviour depends on some session date format, such as NLS_DATE_FORMAT in Oracle
|
||||
*
|
||||
*/
|
||||
public void setParseDateFormat(String value) {
|
||||
this.parseDateFormat = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp format to use when parsing functions whose behaviour depends on some session date format, such as NLS_TIMESTAMP_FORMAT in Oracle
|
||||
*
|
||||
*/
|
||||
public String getParseTimestampFormat() {
|
||||
return parseTimestampFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp format to use when parsing functions whose behaviour depends on some session date format, such as NLS_TIMESTAMP_FORMAT in Oracle
|
||||
*
|
||||
*/
|
||||
public void setParseTimestampFormat(String value) {
|
||||
this.parseTimestampFormat = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* [#7337] The default name case for parsed identifiers.
|
||||
*
|
||||
@ -3301,6 +3337,24 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The date format to use when parsing functions whose behaviour depends on some session date format, such as NLS_DATE_FORMAT in Oracle
|
||||
*
|
||||
*/
|
||||
public Settings withParseDateFormat(String value) {
|
||||
setParseDateFormat(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp format to use when parsing functions whose behaviour depends on some session date format, such as NLS_TIMESTAMP_FORMAT in Oracle
|
||||
*
|
||||
*/
|
||||
public Settings withParseTimestampFormat(String value) {
|
||||
setParseTimestampFormat(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* [#7337] The default name case for parsed identifiers.
|
||||
*
|
||||
@ -3534,6 +3588,8 @@ public class Settings
|
||||
builder.append("locale", locale);
|
||||
builder.append("parseDialect", parseDialect);
|
||||
builder.append("parseLocale", parseLocale);
|
||||
builder.append("parseDateFormat", parseDateFormat);
|
||||
builder.append("parseTimestampFormat", parseTimestampFormat);
|
||||
builder.append("parseNameCase", parseNameCase);
|
||||
builder.append("parseWithMetaLookups", parseWithMetaLookups);
|
||||
builder.append("parseSetCommands", parseSetCommands);
|
||||
@ -4414,6 +4470,24 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (parseDateFormat == null) {
|
||||
if (other.parseDateFormat!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!parseDateFormat.equals(other.parseDateFormat)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (parseTimestampFormat == null) {
|
||||
if (other.parseTimestampFormat!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!parseTimestampFormat.equals(other.parseTimestampFormat)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (parseNameCase == null) {
|
||||
if (other.parseNameCase!= null) {
|
||||
return false;
|
||||
@ -4632,6 +4706,8 @@ public class Settings
|
||||
result = ((prime*result)+((locale == null)? 0 :locale.hashCode()));
|
||||
result = ((prime*result)+((parseDialect == null)? 0 :parseDialect.hashCode()));
|
||||
result = ((prime*result)+((parseLocale == null)? 0 :parseLocale.hashCode()));
|
||||
result = ((prime*result)+((parseDateFormat == null)? 0 :parseDateFormat.hashCode()));
|
||||
result = ((prime*result)+((parseTimestampFormat == null)? 0 :parseTimestampFormat.hashCode()));
|
||||
result = ((prime*result)+((parseNameCase == null)? 0 :parseNameCase.hashCode()));
|
||||
result = ((prime*result)+((parseWithMetaLookups == null)? 0 :parseWithMetaLookups.hashCode()));
|
||||
result = ((prime*result)+((parseSetCommands == null)? 0 :parseSetCommands.hashCode()));
|
||||
|
||||
@ -9738,8 +9738,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
if (parseFunctionNameIf("TO_DATE")) {
|
||||
parse('(');
|
||||
Field<String> f1 = (Field) parseField(S);
|
||||
parse(',');
|
||||
Field<String> f2 = (Field) parseField(S);
|
||||
Field<String> f2 = parseIf(',') ? (Field) parseField(S) : inline(settings().getParseDateFormat());
|
||||
parse(')');
|
||||
|
||||
return toDate(f1, f2);
|
||||
@ -9752,8 +9751,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
if (parseFunctionNameIf("TO_TIMESTAMP")) {
|
||||
parse('(');
|
||||
Field<String> f1 = (Field) parseField(S);
|
||||
parse(',');
|
||||
Field<String> f2 = (Field) parseField(S);
|
||||
Field<String> f2 = parseIf(',') ? (Field) parseField(S) : inline(settings().getParseTimestampFormat());
|
||||
parse(')');
|
||||
|
||||
return toTimestamp(f1, f2);
|
||||
|
||||
@ -560,6 +560,14 @@ jOOQ queries, for which no specific fetchSize value was specified.]]></jxb:javad
|
||||
<element name="parseLocale" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The Locale to be used with any parser locale dependent logic, defaulting to {@link #getLocale()}.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="parseDateFormat" type="string" minOccurs="0" maxOccurs="1" default="YYYY-MM-DD">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The date format to use when parsing functions whose behaviour depends on some session date format, such as NLS_DATE_FORMAT in Oracle]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="parseTimestampFormat" type="string" minOccurs="0" maxOccurs="1" default="YYYY-MM-DD HH24:MI:SS.FF">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The timestamp format to use when parsing functions whose behaviour depends on some session date format, such as NLS_TIMESTAMP_FORMAT in Oracle]]></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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user