[#5909] Deprecate RenderNameStyle.QUOTED and replace feature by renderQuotedNames
This commit is contained in:
parent
1f86fcd20a
commit
39a4c8dade
@ -46,9 +46,10 @@ import org.jooq.Select;
|
||||
import org.jooq.academy.tools.Tools;
|
||||
import org.jooq.conf.MappedSchema;
|
||||
import org.jooq.conf.MappedTable;
|
||||
import org.jooq.conf.RenderKeywordStyle;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.RenderMapping;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.RenderNameCase;
|
||||
import org.jooq.conf.RenderQuotedNames;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -71,15 +72,20 @@ public class Example_4_2_Settings {
|
||||
out.println(using(H2, new Settings().withRenderSchema(false)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderSchema(true)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Name style");
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.AS_IS)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.LOWER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.QUOTED)).render(select));
|
||||
Tools.title("A couple of settings at work - Name case");
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.AS_IS)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.LOWER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.PASCAL)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Keyword style");
|
||||
out.println(using(H2, new Settings().withRenderKeywordStyle(RenderKeywordStyle.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderKeywordStyle(RenderKeywordStyle.LOWER)).render(select));
|
||||
Tools.title("A couple of settings at work - Name quoting");
|
||||
out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.ALWAYS)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.WHEN_NEEDED)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.NEVER)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Keyword case");
|
||||
out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.LOWER)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Mapping");
|
||||
out.println(using(H2, new Settings()
|
||||
|
||||
@ -46,9 +46,10 @@ import org.jooq.Select;
|
||||
import org.jooq.academy.tools.Tools;
|
||||
import org.jooq.conf.MappedSchema;
|
||||
import org.jooq.conf.MappedTable;
|
||||
import org.jooq.conf.RenderKeywordStyle;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.RenderMapping;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.RenderNameCase;
|
||||
import org.jooq.conf.RenderQuotedNames;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -71,15 +72,20 @@ public class Example_4_3_Settings {
|
||||
out.println(using(H2, new Settings().withRenderSchema(false)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderSchema(true)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Name style");
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.AS_IS)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.LOWER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameStyle(RenderNameStyle.QUOTED)).render(select));
|
||||
Tools.title("A couple of settings at work - Name case");
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.AS_IS)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.LOWER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.PASCAL)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Keyword style");
|
||||
out.println(using(H2, new Settings().withRenderKeywordStyle(RenderKeywordStyle.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderKeywordStyle(RenderKeywordStyle.LOWER)).render(select));
|
||||
Tools.title("A couple of settings at work - Name quoting");
|
||||
out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.ALWAYS)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.WHEN_NEEDED)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.NEVER)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Keyword case");
|
||||
out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.UPPER)).render(select));
|
||||
out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.LOWER)).render(select));
|
||||
|
||||
Tools.title("A couple of settings at work - Mapping");
|
||||
out.println(using(H2, new Settings()
|
||||
|
||||
@ -41,7 +41,7 @@ import java.sql.PreparedStatement;
|
||||
|
||||
import org.jooq.RenderContext.CastMode;
|
||||
import org.jooq.conf.ParamType;
|
||||
import org.jooq.conf.RenderKeywordStyle;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.DSL;
|
||||
@ -253,7 +253,7 @@ public interface Context<C extends Context<C>> extends Scope {
|
||||
/**
|
||||
* Append a SQL keyword to the context's contained {@link StringBuilder}.
|
||||
* <p>
|
||||
* Use this to have your SQL keyword rendered in {@link RenderKeywordStyle}.
|
||||
* Use this to have your SQL keyword rendered in {@link RenderKeywordCase}.
|
||||
*
|
||||
* @deprecated - 3.10.0 - [#4990] - Use {@link DSL#keyword(String)} instead.
|
||||
*/
|
||||
|
||||
@ -835,7 +835,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* query("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will render this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will render this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -952,7 +952,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetch("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1093,7 +1093,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1227,7 +1227,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1347,7 +1347,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1493,7 +1493,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1604,7 +1604,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchMany("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1723,7 +1723,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1846,7 +1846,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -1968,7 +1968,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -2095,7 +2095,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -2224,7 +2224,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -2350,7 +2350,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -2441,7 +2441,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* execute("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will execute this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -2615,7 +2615,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* // The following query
|
||||
* resultQuery("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will render this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will render this SQL by default, using SQLDialect.ORACLE:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
|
||||
@ -159,8 +159,8 @@ extends
|
||||
* Create an alias for this field.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned field depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
* {@link Settings#getRenderQuotedNames()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive in many SQL dialects!
|
||||
*
|
||||
* @param alias The alias name
|
||||
* @return The field alias
|
||||
@ -172,9 +172,9 @@ extends
|
||||
* Create an alias for this field.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned field depends on
|
||||
* {@link Settings#getRenderNameStyle()} and the {@link Name}. By default,
|
||||
* field aliases are quoted, and thus case-sensitive - use
|
||||
* {@link DSL#unquotedName(String...)} for case-insensitive aliases.
|
||||
* {@link Settings#getRenderQuotedNames()} and the {@link Name}. By default,
|
||||
* field aliases are quoted, and thus case-sensitive in many SQL dialects -
|
||||
* use {@link DSL#unquotedName(String...)} for case-insensitive aliases.
|
||||
* <p>
|
||||
* If the argument {@link Name#getName()} is qualified, then the
|
||||
* {@link Name#last()} part will be used.
|
||||
@ -187,10 +187,6 @@ extends
|
||||
|
||||
/**
|
||||
* Create an alias for this field based on another field's name.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned field depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
*
|
||||
* @param otherField The other field whose name this field is aliased with.
|
||||
* @return The field alias.
|
||||
@ -203,8 +199,8 @@ extends
|
||||
* Create an alias for this field.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned field depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
* {@link Settings#getRenderQuotedNames()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive in many SQL dialects!
|
||||
* <p>
|
||||
* This works like {@link #as(String)}, except that field aliases are
|
||||
* provided by a function. This is useful, for instance, to prefix all
|
||||
|
||||
@ -65,8 +65,8 @@ public interface FieldLike {
|
||||
* <code>SELECT y.*, (SELECT a FROM x) [alias] FROM y</code>
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned field depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
* {@link Settings#getRenderQuotedNames()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive in many SQL dialects!
|
||||
*
|
||||
* @return This result provider as a Field<?> object
|
||||
*/
|
||||
@ -80,8 +80,8 @@ public interface FieldLike {
|
||||
* <code>SELECT y.*, (SELECT a FROM x) [alias] FROM y</code>
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned field depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
* {@link Settings#getRenderQuotedNames()}. By default, field aliases are
|
||||
* quoted, and thus case-sensitive in many SQL dialects!
|
||||
* <p>
|
||||
* This works like {@link #asField(String)}, except that field aliases are
|
||||
* provided by a function. This is useful, for instance, to prefix all
|
||||
|
||||
@ -44,7 +44,7 @@ import org.jooq.conf.Settings;
|
||||
* <p>
|
||||
* A <code>Keyword</code> is a {@link QueryPart} that renders a SQL keyword
|
||||
* according to the settings specified in
|
||||
* {@link Settings#getRenderKeywordStyle()}.
|
||||
* {@link Settings#getRenderKeywordCase()}.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
|
||||
@ -65,7 +65,9 @@ import org.jooq.conf.Settings;
|
||||
* A SQL identifier <code>QueryPart</code>.
|
||||
* <p>
|
||||
* A <code>Name</code> is a {@link QueryPart} that renders a SQL identifier
|
||||
* according to the settings specified in {@link Settings#getRenderNameStyle()}.
|
||||
* according to the settings specified in
|
||||
* {@link Settings#getRenderQuotedNames()} and
|
||||
* {@link Settings#getRenderNameCase()}.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
|
||||
@ -37,8 +37,8 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import org.jooq.conf.RenderKeywordStyle;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.RenderNameCase;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.ParserException;
|
||||
@ -72,9 +72,9 @@ public final class ParserCLI {
|
||||
if (a.formatted)
|
||||
settings.setRenderFormatted(true);
|
||||
if (a.keywords != null)
|
||||
settings.setRenderKeywordStyle(a.keywords);
|
||||
settings.setRenderKeywordCase(a.keywords);
|
||||
if (a.name != null)
|
||||
settings.setRenderNameStyle(a.name);
|
||||
settings.setRenderNameCase(a.name);
|
||||
|
||||
DSLContext ctx = DSL.using(a.toDialect, settings);
|
||||
try {
|
||||
@ -106,29 +106,29 @@ public final class ParserCLI {
|
||||
}
|
||||
else if ("-k".equals(args[i]) || "--keyword".equals(args[i])) {
|
||||
try {
|
||||
result.keywords = RenderKeywordStyle.valueOf(args[++i]);
|
||||
result.keywords = RenderKeywordCase.valueOf(args[++i]);
|
||||
continue argsLoop;
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
invalid(args[i], RenderKeywordStyle.class);
|
||||
invalid(args[i], RenderKeywordCase.class);
|
||||
throw e;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
System.err.println("Flag -k / --keyword requires <RenderKeywordStyle> argument");
|
||||
System.err.println("Flag -k / --keyword requires <RenderKeywordCase> argument");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
else if ("-i".equals(args[i]) || "--identifier".equals(args[i])) {
|
||||
try {
|
||||
result.keywords = RenderKeywordStyle.valueOf(args[++i]);
|
||||
result.keywords = RenderKeywordCase.valueOf(args[++i]);
|
||||
continue argsLoop;
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
invalid(args[i], RenderKeywordStyle.class);
|
||||
invalid(args[i], RenderKeywordCase.class);
|
||||
throw e;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
System.err.println("Flag -i / --identifier requires <RenderNameStyle> argument");
|
||||
System.err.println("Flag -i / --identifier requires <RenderNameCase> argument");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@ -179,19 +179,19 @@ public final class ParserCLI {
|
||||
|
||||
private static final void help() {
|
||||
System.out.println("Usage:");
|
||||
System.out.println(" -f / --formatted Format output SQL");
|
||||
System.out.println(" -h / --help Display this help");
|
||||
System.out.println(" -k / --keyword <RenderKeywordStyle> Specify the output keyword style (org.jooq.conf.RenderKeywordStyle)");
|
||||
System.out.println(" -i / --identifier <RenderNameStyle> Specify the output identifier style (org.jooq.conf.RenderNameStyle)");
|
||||
System.out.println(" -t / --to-dialect <SQLDialect> Specify the output dialect (org.jooq.SQLDialect)");
|
||||
System.out.println(" -s / --sql <String> Specify the input SQL string");
|
||||
System.out.println(" -f / --formatted Format output SQL");
|
||||
System.out.println(" -h / --help Display this help");
|
||||
System.out.println(" -k / --keyword <RenderKeywordCase> Specify the output keyword case (org.jooq.conf.RenderKeywordCase)");
|
||||
System.out.println(" -i / --identifier <RenderNameCase> Specify the output identifier case (org.jooq.conf.RenderNameCase)");
|
||||
System.out.println(" -t / --to-dialect <SQLDialect> Specify the output dialect (org.jooq.SQLDialect)");
|
||||
System.out.println(" -s / --sql <String> Specify the input SQL string");
|
||||
}
|
||||
|
||||
public static final class Args {
|
||||
String sql;
|
||||
RenderKeywordStyle keywords;
|
||||
RenderNameStyle name;
|
||||
SQLDialect toDialect;
|
||||
boolean formatted;
|
||||
String sql;
|
||||
RenderKeywordCase keywords;
|
||||
RenderNameCase name;
|
||||
SQLDialect toDialect;
|
||||
boolean formatted;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
package org.jooq;
|
||||
|
||||
import org.jooq.conf.ParamType;
|
||||
import org.jooq.conf.RenderKeywordStyle;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.Settings;
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ public interface RenderContext extends Context<RenderContext> {
|
||||
/**
|
||||
* Append a SQL keyword to the context's contained {@link StringBuilder}.
|
||||
* <p>
|
||||
* Use this to have your SQL keyword rendered in {@link RenderKeywordStyle}.
|
||||
* Use this to have your SQL keyword rendered in {@link RenderKeywordCase}.
|
||||
*/
|
||||
@Override
|
||||
RenderContext keyword(String keyword);
|
||||
|
||||
@ -326,8 +326,8 @@ public interface Table<R extends Record> extends TableLike<R>, Named {
|
||||
* Create an alias for this table.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned table depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, table aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
* {@link Settings#getRenderQuotedNames()}. By default, table aliases are
|
||||
* quoted, and thus case-sensitive in many SQL dialects!
|
||||
*
|
||||
* @param alias The alias name
|
||||
* @return The table alias
|
||||
@ -339,8 +339,8 @@ public interface Table<R extends Record> extends TableLike<R>, Named {
|
||||
* Create an alias for this table and its fields.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned table and columns depends
|
||||
* on {@link Settings#getRenderNameStyle()}. By default, table aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
* on {@link Settings#getRenderQuotedNames()}. By default, table aliases are
|
||||
* quoted, and thus case-sensitive in many SQL dialects!
|
||||
* <p>
|
||||
* <h5>Derived column lists for table references</h5>
|
||||
* <p>
|
||||
@ -431,9 +431,9 @@ public interface Table<R extends Record> extends TableLike<R>, Named {
|
||||
* Create an alias for this table.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned table depends on
|
||||
* {@link Settings#getRenderNameStyle()} and the {@link Name}. By default,
|
||||
* table aliases are quoted, and thus case-sensitive - use
|
||||
* {@link DSL#unquotedName(String...)} for case-insensitive aliases.
|
||||
* {@link Settings#getRenderQuotedNames()} and the {@link Name}. By default,
|
||||
* table aliases are quoted, and thus case-sensitive in many SQL dialects -
|
||||
* use {@link DSL#unquotedName(String...)} for case-insensitive aliases.
|
||||
* <p>
|
||||
* If the argument {@link Name#getName()} is qualified, then the
|
||||
* {@link Name#last()} part will be used.
|
||||
@ -448,9 +448,9 @@ public interface Table<R extends Record> extends TableLike<R>, Named {
|
||||
* Create an alias for this table and its fields.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned table depends on
|
||||
* {@link Settings#getRenderNameStyle()} and the {@link Name}. By default,
|
||||
* table aliases are quoted, and thus case-sensitive - use
|
||||
* {@link DSL#unquotedName(String...)} for case-insensitive aliases.
|
||||
* {@link Settings#getRenderQuotedNames()} and the {@link Name}. By default,
|
||||
* table aliases are quoted, and thus case-sensitive in many SQL dialects -
|
||||
* use {@link DSL#unquotedName(String...)} for case-insensitive aliases.
|
||||
* <p>
|
||||
* If the argument {@link Name#getName()} is qualified, then the
|
||||
* {@link Name#last()} part will be used.
|
||||
@ -542,10 +542,6 @@ public interface Table<R extends Record> extends TableLike<R>, Named {
|
||||
|
||||
/**
|
||||
* Create an alias for this table based on another table's name.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned table depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, table aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
*
|
||||
* @param otherTable The other table whose name this table is aliased with.
|
||||
* @return The table alias.
|
||||
@ -555,10 +551,6 @@ public interface Table<R extends Record> extends TableLike<R>, Named {
|
||||
|
||||
/**
|
||||
* Create an alias for this table based on another table's name.
|
||||
* <p>
|
||||
* Note that the case-sensitivity of the returned table depends on
|
||||
* {@link Settings#getRenderNameStyle()}. By default, table aliases are
|
||||
* quoted, and thus case-sensitive!
|
||||
*
|
||||
* @param otherTable The other table whose name this table is aliased with.
|
||||
* @param otherFields The other fields whose field name this table's fields
|
||||
|
||||
49
jOOQ/src/main/java/org/jooq/conf/RenderKeywordCase.java
Normal file
49
jOOQ/src/main/java/org/jooq/conf/RenderKeywordCase.java
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
package org.jooq.conf;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for RenderKeywordCase.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="RenderKeywordCase">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="AS_IS"/>
|
||||
* <enumeration value="LOWER"/>
|
||||
* <enumeration value="UPPER"/>
|
||||
* <enumeration value="PASCAL"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "RenderKeywordCase")
|
||||
@XmlEnum
|
||||
public enum RenderKeywordCase {
|
||||
|
||||
AS_IS,
|
||||
LOWER,
|
||||
UPPER,
|
||||
PASCAL;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static RenderKeywordCase fromValue(String v) {
|
||||
return valueOf(v);
|
||||
}
|
||||
|
||||
}
|
||||
47
jOOQ/src/main/java/org/jooq/conf/RenderNameCase.java
Normal file
47
jOOQ/src/main/java/org/jooq/conf/RenderNameCase.java
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
package org.jooq.conf;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for RenderNameCase.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="RenderNameCase">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="AS_IS"/>
|
||||
* <enumeration value="LOWER"/>
|
||||
* <enumeration value="UPPER"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "RenderNameCase")
|
||||
@XmlEnum
|
||||
public enum RenderNameCase {
|
||||
|
||||
AS_IS,
|
||||
LOWER,
|
||||
UPPER;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static RenderNameCase fromValue(String v) {
|
||||
return valueOf(v);
|
||||
}
|
||||
|
||||
}
|
||||
45
jOOQ/src/main/java/org/jooq/conf/RenderQuotedNames.java
Normal file
45
jOOQ/src/main/java/org/jooq/conf/RenderQuotedNames.java
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
package org.jooq.conf;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for RenderQuotedNames.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="RenderQuotedNames">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="ALWAYS"/>
|
||||
* <enumeration value="NEVER"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlType(name = "RenderQuotedNames")
|
||||
@XmlEnum
|
||||
public enum RenderQuotedNames {
|
||||
|
||||
ALWAYS,
|
||||
NEVER;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static RenderQuotedNames fromValue(String v) {
|
||||
return valueOf(v);
|
||||
}
|
||||
|
||||
}
|
||||
@ -42,11 +42,20 @@ public class Settings
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean renderSchema = true;
|
||||
protected RenderMapping renderMapping;
|
||||
@XmlElement(defaultValue = "ALWAYS")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected RenderQuotedNames renderQuotedNames = RenderQuotedNames.ALWAYS;
|
||||
@XmlElement(defaultValue = "AS_IS")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected RenderNameCase renderNameCase = RenderNameCase.AS_IS;
|
||||
@XmlElement(defaultValue = "QUOTED")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected RenderNameStyle renderNameStyle = RenderNameStyle.QUOTED;
|
||||
@XmlElement(defaultValue = "AS_IS")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected RenderKeywordCase renderKeywordCase = RenderKeywordCase.AS_IS;
|
||||
@XmlElement(defaultValue = "AS_IS")
|
||||
@XmlSchemaType(name = "string")
|
||||
protected RenderKeywordStyle renderKeywordStyle = RenderKeywordStyle.AS_IS;
|
||||
@XmlElement(type = String.class)
|
||||
@XmlJavaTypeAdapter(LocaleAdapter.class)
|
||||
@ -217,11 +226,69 @@ public class Settings
|
||||
this.renderMapping = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether rendered schema, table, column names, etc should be quoted.
|
||||
* <p>
|
||||
* This only affects names created through {@link org.jooq.impl.DSL#name(String)} methods (including those that are implicitly created through this method), not {@link org.jooq.impl.DSL#quotedName(String)} or {@link org.jooq.impl.DSL#unquotedName(String)}, whose behaviour cannot be overridden.
|
||||
* <p>
|
||||
* This setting does not affect any plain SQL usage.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link RenderQuotedNames }
|
||||
*
|
||||
*/
|
||||
public RenderQuotedNames getRenderQuotedNames() {
|
||||
return renderQuotedNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the renderQuotedNames property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link RenderQuotedNames }
|
||||
*
|
||||
*/
|
||||
public void setRenderQuotedNames(RenderQuotedNames value) {
|
||||
this.renderQuotedNames = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the case of {@link org.jooq.Name} references should be modified in any way.
|
||||
* <p>
|
||||
* Names are modified irrespective of the {@link #getRenderQuotedNames()} setting.
|
||||
* <p>
|
||||
* This setting does not affect any plain SQL usage.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link RenderNameCase }
|
||||
*
|
||||
*/
|
||||
public RenderNameCase getRenderNameCase() {
|
||||
return renderNameCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the renderNameCase property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link RenderNameCase }
|
||||
*
|
||||
*/
|
||||
public void setRenderNameCase(RenderNameCase value) {
|
||||
this.renderNameCase = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether rendered schema, table, column names, etc should be quoted
|
||||
* in rendered SQL, or transformed in any other way.
|
||||
* <p>
|
||||
* This is set to "QUOTED" by default for backwards-compatibility
|
||||
* This is set to "QUOTED" by default for backwards-compatibility.
|
||||
* <p>
|
||||
* @deprecated - 3.12.0 - [#5909] - Use {@link RenderQuotedNames} and {@link RenderNameCase} instead.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
@ -245,7 +312,33 @@ public class Settings
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether SQL keywords should be rendered with upper or lower case.
|
||||
* Whether the case of {@link org.jooq.Keyword} references should be modified in any way.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link RenderKeywordCase }
|
||||
*
|
||||
*/
|
||||
public RenderKeywordCase getRenderKeywordCase() {
|
||||
return renderKeywordCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the renderKeywordCase property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link RenderKeywordCase }
|
||||
*
|
||||
*/
|
||||
public void setRenderKeywordCase(RenderKeywordCase value) {
|
||||
this.renderKeywordCase = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the case of {@link org.jooq.Keyword} references should be modified in any way.
|
||||
* <p>
|
||||
* @deprecated - 3.12.0 - [#5909] - Use {@link RenderQuotedNames} and {@link RenderNameCase} instead.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
@ -1233,11 +1326,26 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderQuotedNames(RenderQuotedNames value) {
|
||||
setRenderQuotedNames(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderNameCase(RenderNameCase value) {
|
||||
setRenderNameCase(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderNameStyle(RenderNameStyle value) {
|
||||
setRenderNameStyle(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderKeywordCase(RenderKeywordCase value) {
|
||||
setRenderKeywordCase(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderKeywordStyle(RenderKeywordStyle value) {
|
||||
setRenderKeywordStyle(value);
|
||||
return this;
|
||||
@ -1451,11 +1559,26 @@ public class Settings
|
||||
sb.append(renderMapping);
|
||||
sb.append("</renderMapping>");
|
||||
}
|
||||
if (renderQuotedNames!= null) {
|
||||
sb.append("<renderQuotedNames>");
|
||||
sb.append(renderQuotedNames);
|
||||
sb.append("</renderQuotedNames>");
|
||||
}
|
||||
if (renderNameCase!= null) {
|
||||
sb.append("<renderNameCase>");
|
||||
sb.append(renderNameCase);
|
||||
sb.append("</renderNameCase>");
|
||||
}
|
||||
if (renderNameStyle!= null) {
|
||||
sb.append("<renderNameStyle>");
|
||||
sb.append(renderNameStyle);
|
||||
sb.append("</renderNameStyle>");
|
||||
}
|
||||
if (renderKeywordCase!= null) {
|
||||
sb.append("<renderKeywordCase>");
|
||||
sb.append(renderKeywordCase);
|
||||
sb.append("</renderKeywordCase>");
|
||||
}
|
||||
if (renderKeywordStyle!= null) {
|
||||
sb.append("<renderKeywordStyle>");
|
||||
sb.append(renderKeywordStyle);
|
||||
@ -1693,6 +1816,24 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (renderQuotedNames == null) {
|
||||
if (other.renderQuotedNames!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!renderQuotedNames.equals(other.renderQuotedNames)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (renderNameCase == null) {
|
||||
if (other.renderNameCase!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!renderNameCase.equals(other.renderNameCase)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (renderNameStyle == null) {
|
||||
if (other.renderNameStyle!= null) {
|
||||
return false;
|
||||
@ -1702,6 +1843,15 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (renderKeywordCase == null) {
|
||||
if (other.renderKeywordCase!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!renderKeywordCase.equals(other.renderKeywordCase)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (renderKeywordStyle == null) {
|
||||
if (other.renderKeywordStyle!= null) {
|
||||
return false;
|
||||
@ -2063,7 +2213,10 @@ public class Settings
|
||||
result = ((prime*result)+((renderCatalog == null)? 0 :renderCatalog.hashCode()));
|
||||
result = ((prime*result)+((renderSchema == null)? 0 :renderSchema.hashCode()));
|
||||
result = ((prime*result)+((renderMapping == null)? 0 :renderMapping.hashCode()));
|
||||
result = ((prime*result)+((renderQuotedNames == null)? 0 :renderQuotedNames.hashCode()));
|
||||
result = ((prime*result)+((renderNameCase == null)? 0 :renderNameCase.hashCode()));
|
||||
result = ((prime*result)+((renderNameStyle == null)? 0 :renderNameStyle.hashCode()));
|
||||
result = ((prime*result)+((renderKeywordCase == null)? 0 :renderKeywordCase.hashCode()));
|
||||
result = ((prime*result)+((renderKeywordStyle == null)? 0 :renderKeywordStyle.hashCode()));
|
||||
result = ((prime*result)+((renderLocale == null)? 0 :renderLocale.hashCode()));
|
||||
result = ((prime*result)+((renderFormatted == null)? 0 :renderFormatted.hashCode()));
|
||||
|
||||
@ -180,6 +180,74 @@ public final class SettingsTools {
|
||||
return settings.getRenderMapping();
|
||||
}
|
||||
|
||||
/**
|
||||
* Backwards compatible access to {@link RenderKeywordCase} and/or
|
||||
* {@link RenderKeywordStyle} (the latter being deprecated).
|
||||
*/
|
||||
public static final RenderKeywordCase getRenderKeywordCase(Settings settings) {
|
||||
RenderKeywordCase result = settings.getRenderKeywordCase();
|
||||
|
||||
if (result == null || result == RenderKeywordCase.AS_IS) {
|
||||
RenderKeywordStyle style = settings.getRenderKeywordStyle();
|
||||
|
||||
if (style != null) {
|
||||
switch (style) {
|
||||
case AS_IS: result = RenderKeywordCase.AS_IS; break;
|
||||
case LOWER: result = RenderKeywordCase.LOWER; break;
|
||||
case UPPER: result = RenderKeywordCase.UPPER; break;
|
||||
case PASCAL: result = RenderKeywordCase.PASCAL; break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsupported style: " + style);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = RenderKeywordCase.AS_IS;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backwards compatible access to {@link RenderNameCase} and/or
|
||||
* {@link RenderNameStyle} (the latter being deprecated).
|
||||
*/
|
||||
public static final RenderNameCase getRenderNameCase(Settings settings) {
|
||||
RenderNameCase result = settings.getRenderNameCase();
|
||||
|
||||
if (result == null || result == RenderNameCase.AS_IS) {
|
||||
RenderNameStyle style = settings.getRenderNameStyle();
|
||||
|
||||
if (style == RenderNameStyle.LOWER)
|
||||
result = RenderNameCase.LOWER;
|
||||
else if (style == RenderNameStyle.UPPER)
|
||||
result = RenderNameCase.UPPER;
|
||||
else
|
||||
result = RenderNameCase.AS_IS;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backwards compatible access to {@link RenderQuotedNames} and/or
|
||||
* {@link RenderNameStyle} (the latter being deprecated).
|
||||
*/
|
||||
public static final RenderQuotedNames getRenderQuotedNames(Settings settings) {
|
||||
RenderQuotedNames result = settings.getRenderQuotedNames();
|
||||
|
||||
if (result == null || result == RenderQuotedNames.ALWAYS) {
|
||||
RenderNameStyle style = settings.getRenderNameStyle();
|
||||
|
||||
if (style == null || style == RenderNameStyle.QUOTED)
|
||||
result = RenderQuotedNames.ALWAYS;
|
||||
else
|
||||
result = RenderQuotedNames.NEVER;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy access to {@link Settings#getExecuteUpdateWithoutWhere()}.
|
||||
*/
|
||||
|
||||
@ -80,7 +80,7 @@ import org.jooq.VisitListener;
|
||||
import org.jooq.VisitListenerProvider;
|
||||
import org.jooq.conf.ParamCastMode;
|
||||
import org.jooq.conf.ParamType;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.RenderQuotedNames;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.conf.SettingsTools;
|
||||
import org.jooq.conf.StatementType;
|
||||
@ -179,7 +179,7 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
|
||||
: m == ParamCastMode.NEVER
|
||||
? CastMode.NEVER
|
||||
: CastMode.DEFAULT;
|
||||
this.quote = settings().getRenderNameStyle() == RenderNameStyle.QUOTED;
|
||||
this.quote = SettingsTools.getRenderQuotedNames(settings()) == RenderQuotedNames.ALWAYS;
|
||||
this.scopeStack = new ScopeStack();
|
||||
}
|
||||
|
||||
|
||||
@ -46,8 +46,6 @@ import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.RenderNameStyle.LOWER;
|
||||
import static org.jooq.conf.RenderNameStyle.UPPER;
|
||||
import static org.jooq.conf.SettingsTools.renderLocale;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.unquotedName;
|
||||
@ -104,7 +102,8 @@ import org.jooq.Select;
|
||||
import org.jooq.SelectFieldOrAsterisk;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.conf.ExecuteWithoutWhere;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.RenderNameCase;
|
||||
import org.jooq.conf.SettingsTools;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.Tools.DataKey;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
@ -619,22 +618,22 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
case HSQLDB:
|
||||
default: {
|
||||
String[] names = new String[returningResolvedAsterisks.size()];
|
||||
RenderNameStyle style = configuration().settings().getRenderNameStyle();
|
||||
RenderNameCase style = SettingsTools.getRenderNameCase(configuration().settings());
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
|
||||
// [#2845] Field names should be passed to JDBC in the case
|
||||
// imposed by the user. For instance, if the user uses
|
||||
// PostgreSQL generated case-insensitive Fields (default to lower case)
|
||||
// and wants to query HSQLDB (default to upper case), they may choose
|
||||
// to overwrite casing using RenderKeywordStyle.
|
||||
if (style == UPPER)
|
||||
// [#2845] Field names should be passed to JDBC in the case
|
||||
// imposed by the user. For instance, if the user uses
|
||||
// PostgreSQL generated case-insensitive Fields (default to lower case)
|
||||
// and wants to query HSQLDB (default to upper case), they may choose
|
||||
// to overwrite casing using RenderNameCase.
|
||||
if (style == RenderNameCase.UPPER)
|
||||
for (int i = 0; i < names.length; i++)
|
||||
names[i] = returningResolvedAsterisks.get(i).getName().toUpperCase(renderLocale(configuration().settings()));
|
||||
else if (style == LOWER)
|
||||
else if (style == RenderNameCase.LOWER)
|
||||
for (int i = 0; i < names.length; i++)
|
||||
names[i] = returningResolvedAsterisks.get(i).getName().toLowerCase(renderLocale(configuration().settings()));
|
||||
else
|
||||
else
|
||||
for (int i = 0; i < names.length; i++)
|
||||
names[i] = returningResolvedAsterisks.get(i).getName();
|
||||
}
|
||||
|
||||
ctx.statement(connection.prepareStatement(ctx.sql(), names));
|
||||
return;
|
||||
|
||||
@ -359,7 +359,6 @@ import org.jooq.WithAsStep7;
|
||||
import org.jooq.WithAsStep8;
|
||||
import org.jooq.WithAsStep9;
|
||||
import org.jooq.WithStep;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
import org.jooq.tools.Convert;
|
||||
@ -8888,7 +8887,7 @@ public class DSL {
|
||||
* <p>
|
||||
* A <code>Keyword</code> is a {@link QueryPart} that renders a SQL keyword
|
||||
* according to the settings specified in
|
||||
* {@link Settings#getRenderKeywordStyle()}. It can be embedded in other
|
||||
* {@link Settings#getRenderKeywordCase()}. It can be embedded in other
|
||||
* plain SQL <code>QueryParts</code> as shown in this example:
|
||||
* <p>
|
||||
* <code><pre>
|
||||
@ -8923,7 +8922,7 @@ public class DSL {
|
||||
* // This unqualified name here
|
||||
* name("book");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [book].[title]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -8950,7 +8949,7 @@ public class DSL {
|
||||
* // This qualified name here
|
||||
* name("book", "title");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [book].[title]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -8984,7 +8983,7 @@ public class DSL {
|
||||
* // This qualified name here
|
||||
* name(quotedName("book"), unquotedName("title"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [book].title
|
||||
* </pre></code>
|
||||
*
|
||||
@ -9011,7 +9010,7 @@ public class DSL {
|
||||
* // This qualified name here
|
||||
* name("book", "title");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [book].[title]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -9178,16 +9177,12 @@ public class DSL {
|
||||
* Create a qualified schema, given its schema name.
|
||||
* <p>
|
||||
* This constructs a schema reference given the schema's qualified name.
|
||||
* jOOQ will render the schema name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This schema...
|
||||
* schemaByName("MY_SCHEMA");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -9205,16 +9200,12 @@ public class DSL {
|
||||
* Create a qualified catalog, given its catalog name.
|
||||
* <p>
|
||||
* This constructs a catalog reference given the catalog's qualified name.
|
||||
* jOOQ will render the catalog name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This catalog...
|
||||
* catalog(name("MY_CATALOG"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_CATALOG]
|
||||
* </pre></code>
|
||||
*/
|
||||
@ -9227,16 +9218,12 @@ public class DSL {
|
||||
* Create a qualified schema, given its schema name.
|
||||
* <p>
|
||||
* This constructs a schema reference given the schema's qualified name.
|
||||
* jOOQ will render the schema name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This schema...
|
||||
* schema(name("MY_CATALOG", "MY_SCHEMA"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_CATALOG].[MY_SCHEMA]
|
||||
* </pre></code>
|
||||
*/
|
||||
@ -9249,16 +9236,12 @@ public class DSL {
|
||||
* Create a qualified sequence, given its sequence name.
|
||||
* <p>
|
||||
* This constructs a sequence reference given the sequence's qualified name.
|
||||
* jOOQ will render the sequence name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This sequence...
|
||||
* sequenceByName("MY_SCHEMA", "MY_SEQUENCE");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_SEQUENCE]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -9277,16 +9260,12 @@ public class DSL {
|
||||
* Create a qualified sequence, given its sequence name.
|
||||
* <p>
|
||||
* This constructs a sequence reference given the sequence's qualified name.
|
||||
* jOOQ will render the sequence name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This sequence...
|
||||
* sequenceByName("MY_SCHEMA", "MY_SEQUENCE");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_SEQUENCE]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -9306,16 +9285,12 @@ public class DSL {
|
||||
* Create a qualified sequence, given its sequence name.
|
||||
* <p>
|
||||
* This constructs a sequence reference given the sequence's qualified name.
|
||||
* jOOQ will render the sequence name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This sequence...
|
||||
* sequenceByName("MY_SCHEMA", "MY_SEQUENCE");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_SEQUENCE]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -9344,16 +9319,12 @@ public class DSL {
|
||||
* Create a qualified sequence, given its sequence name.
|
||||
* <p>
|
||||
* This constructs a sequence reference given the sequence's qualified name.
|
||||
* jOOQ will render the sequence name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This sequence...
|
||||
* sequence(name("MY_SCHEMA", "MY_SEQUENCE"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_SEQUENCE]
|
||||
* </pre></code>
|
||||
*/
|
||||
@ -9366,16 +9337,12 @@ public class DSL {
|
||||
* Create a qualified sequence, given its sequence name.
|
||||
* <p>
|
||||
* This constructs a sequence reference given the sequence's qualified name.
|
||||
* jOOQ will render the sequence name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This sequence...
|
||||
* sequence(name("MY_SCHEMA", "MY_SEQUENCE"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_SEQUENCE]
|
||||
* </pre></code>
|
||||
*/
|
||||
@ -9388,16 +9355,12 @@ public class DSL {
|
||||
* Create a qualified sequence, given its sequence name.
|
||||
* <p>
|
||||
* This constructs a sequence reference given the sequence's qualified name.
|
||||
* jOOQ will render the sequence name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This sequence...
|
||||
* sequence(name("MY_SCHEMA", "MY_SEQUENCE"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_SEQUENCE]
|
||||
* </pre></code>
|
||||
*/
|
||||
@ -9419,16 +9382,12 @@ public class DSL {
|
||||
* Create a qualified table, given its table name.
|
||||
* <p>
|
||||
* This constructs a table reference given the table's qualified name. jOOQ
|
||||
* will render the table name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This table...
|
||||
* tableByName("MY_SCHEMA", "MY_TABLE");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE]
|
||||
* </pre></code>
|
||||
*
|
||||
@ -9447,16 +9406,12 @@ public class DSL {
|
||||
* Create a qualified table, given its table name.
|
||||
* <p>
|
||||
* This constructs a table reference given the table's qualified name. jOOQ
|
||||
* will render the table name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This table...
|
||||
* tableByName("MY_SCHEMA", "MY_TABLE");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9472,16 +9427,12 @@ public class DSL {
|
||||
* Create a qualified table, given its table name.
|
||||
* <p>
|
||||
* This constructs a table reference given the table's qualified name. jOOQ
|
||||
* will render the table name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This table...
|
||||
* tableByName("MY_SCHEMA", "MY_TABLE");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9497,16 +9448,12 @@ public class DSL {
|
||||
* Create a qualified field, given its (qualified) field name.
|
||||
* <p>
|
||||
* This constructs a field reference given the field's qualified name. jOOQ
|
||||
* will render the field name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This field...
|
||||
* fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9534,16 +9481,12 @@ public class DSL {
|
||||
* Create a qualified field, given its (qualified) field name.
|
||||
* <p>
|
||||
* This constructs a field reference given the field's qualified name. jOOQ
|
||||
* will render the field name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This field...
|
||||
* fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9572,16 +9515,12 @@ public class DSL {
|
||||
* Create a qualified field, given its (qualified) field name.
|
||||
* <p>
|
||||
* This constructs a field reference given the field's qualified name. jOOQ
|
||||
* will render the field name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This field...
|
||||
* fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9610,16 +9549,12 @@ public class DSL {
|
||||
* Create a qualified field, given its (qualified) field name.
|
||||
* <p>
|
||||
* This constructs a field reference given the field's qualified name. jOOQ
|
||||
* will render the field name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This field...
|
||||
* field(name("MY_SCHEMA", "MY_TABLE", "MY_FIELD"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9641,16 +9576,12 @@ public class DSL {
|
||||
* Create a qualified field, given its (qualified) field name.
|
||||
* <p>
|
||||
* This constructs a field reference given the field's qualified name. jOOQ
|
||||
* will render the field name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This field...
|
||||
* field(name("MY_SCHEMA", "MY_TABLE", "MY_FIELD"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9672,16 +9603,12 @@ public class DSL {
|
||||
* Create a qualified field, given its (qualified) field name.
|
||||
* <p>
|
||||
* This constructs a field reference given the field's qualified name. jOOQ
|
||||
* will render the field name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This field...
|
||||
* field(name("MY_SCHEMA", "MY_TABLE", "MY_FIELD"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -9703,16 +9630,12 @@ public class DSL {
|
||||
* Create a qualified field, given its (qualified) field name.
|
||||
* <p>
|
||||
* This constructs a field reference given the field's qualified name. jOOQ
|
||||
* will render the field name according to your
|
||||
* {@link Settings#getRenderNameStyle()} settings. Choose
|
||||
* {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
|
||||
* injection.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* // This field...
|
||||
* field(name("MY_SCHEMA", "MY_TABLE", "MY_FIELD"));
|
||||
*
|
||||
* // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
|
||||
* // ... will render this SQL by default, using the SQL Server dialect
|
||||
* [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -10072,7 +9995,7 @@ public class DSL {
|
||||
* // The following query
|
||||
* query("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will render this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will render this SQL by default, using Oracle SQL dialect
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
@ -10253,7 +10176,7 @@ public class DSL {
|
||||
* // The following query
|
||||
* resultQuery("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will render this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* // Will render this SQL by default, using Oracle SQL dialect
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
|
||||
@ -41,8 +41,6 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.conf.ParamType.INDEXED;
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.conf.ParamType.NAMED;
|
||||
import static org.jooq.conf.RenderNameStyle.LOWER;
|
||||
import static org.jooq.conf.RenderNameStyle.UPPER;
|
||||
import static org.jooq.conf.SettingsTools.renderLocale;
|
||||
import static org.jooq.impl.Identifiers.QUOTES;
|
||||
import static org.jooq.impl.Identifiers.QUOTE_END_DELIMITER;
|
||||
@ -71,9 +69,11 @@ import org.jooq.RenderContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.conf.RenderFormatting;
|
||||
import org.jooq.conf.RenderKeywordStyle;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.RenderNameCase;
|
||||
import org.jooq.conf.RenderQuotedNames;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.conf.SettingsTools;
|
||||
import org.jooq.exception.ControlFlowSignal;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.Tools.DataKey;
|
||||
@ -102,8 +102,9 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
private int skipUpdateCounts;
|
||||
|
||||
// [#1632] Cached values from Settings
|
||||
RenderKeywordStyle cachedRenderKeywordStyle;
|
||||
RenderNameStyle cachedRenderNameStyle;
|
||||
RenderKeywordCase cachedRenderKeywordCase;
|
||||
RenderNameCase cachedRenderNameCase;
|
||||
RenderQuotedNames cachedRenderQuotedNames;
|
||||
boolean cachedRenderFormatted;
|
||||
|
||||
// [#6525] Cached values from Settings.renderFormatting
|
||||
@ -119,9 +120,10 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
|
||||
this.sql = new StringBuilder();
|
||||
this.bindValues = new QueryPartList<Param<?>>();
|
||||
this.cachedRenderKeywordStyle = settings.getRenderKeywordStyle();
|
||||
this.cachedRenderKeywordCase = SettingsTools.getRenderKeywordCase(settings);
|
||||
this.cachedRenderFormatted = Boolean.TRUE.equals(settings.isRenderFormatted());
|
||||
this.cachedRenderNameStyle = settings.getRenderNameStyle();
|
||||
this.cachedRenderNameCase = SettingsTools.getRenderNameCase(settings);
|
||||
this.cachedRenderQuotedNames = SettingsTools.getRenderQuotedNames(settings);
|
||||
|
||||
RenderFormatting formatting = settings.getRenderFormatting();
|
||||
if (formatting == null)
|
||||
@ -467,15 +469,12 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
// [#1982] [#3360] ... yet, do quote when an identifier contains special characters
|
||||
(family == SQLITE && !IDENTIFIER_PATTERN.matcher(literal).matches());
|
||||
|
||||
if (!needsQuote) {
|
||||
if (LOWER == cachedRenderNameStyle)
|
||||
literal = literal.toLowerCase(renderLocale(configuration().settings()));
|
||||
else if (UPPER == cachedRenderNameStyle)
|
||||
literal = literal.toUpperCase(renderLocale(configuration().settings()));
|
||||
if (RenderNameCase.LOWER == cachedRenderNameCase)
|
||||
literal = literal.toLowerCase(renderLocale(configuration().settings()));
|
||||
else if (RenderNameCase.UPPER == cachedRenderNameCase)
|
||||
literal = literal.toUpperCase(renderLocale(configuration().settings()));
|
||||
|
||||
sql(literal, true);
|
||||
}
|
||||
else {
|
||||
if (needsQuote) {
|
||||
char[][][] quotes = QUOTES.get(family);
|
||||
|
||||
char start = quotes[QUOTE_START_DELIMITER][0][0];
|
||||
@ -493,6 +492,9 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
|
||||
sql(end);
|
||||
}
|
||||
else {
|
||||
sql(literal, true);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -40,7 +40,8 @@ package org.jooq.impl;
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Keyword;
|
||||
import org.jooq.conf.RenderKeywordStyle;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.SettingsTools;
|
||||
|
||||
/**
|
||||
* A default {@link Keyword} implementation.
|
||||
@ -70,16 +71,16 @@ public class KeywordImpl extends AbstractQueryPart implements Keyword {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
RenderKeywordStyle style = ctx.settings().getRenderKeywordStyle();
|
||||
RenderKeywordCase style = SettingsTools.getRenderKeywordCase(ctx.settings());
|
||||
|
||||
if (RenderKeywordStyle.AS_IS == style)
|
||||
ctx.sql(asIs, true);
|
||||
else if (RenderKeywordStyle.UPPER == style)
|
||||
ctx.sql(upper, true);
|
||||
else if (RenderKeywordStyle.PASCAL == style)
|
||||
ctx.sql(pascal, true);
|
||||
else
|
||||
ctx.sql(lower, true);
|
||||
switch (style) {
|
||||
case AS_IS: ctx.sql(asIs, true); break;
|
||||
case LOWER: ctx.sql(lower, true); break;
|
||||
case UPPER: ctx.sql(upper, true); break;
|
||||
case PASCAL: ctx.sql(pascal, true); break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsupported style: " + style);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -33,15 +33,39 @@ available using synonyms]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
generated SQL.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderQuotedNames" type="jooq-runtime:RenderQuotedNames" minOccurs="0" maxOccurs="1" default="ALWAYS">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether rendered schema, table, column names, etc should be quoted.
|
||||
<p>
|
||||
This only affects names created through {@link org.jooq.impl.DSL#name(String)} methods (including those that are implicitly created through this method), not {@link org.jooq.impl.DSL#quotedName(String)} or {@link org.jooq.impl.DSL#unquotedName(String)}, whose behaviour cannot be overridden.
|
||||
<p>
|
||||
This setting does not affect any plain SQL usage.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderNameCase" type="jooq-runtime:RenderNameCase" minOccurs="0" maxOccurs="1" default="AS_IS">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether the case of {@link org.jooq.Name} references should be modified in any way.
|
||||
<p>
|
||||
Names are modified irrespective of the {@link #getRenderQuotedNames()} setting.
|
||||
<p>
|
||||
This setting does not affect any plain SQL usage.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderNameStyle" type="jooq-runtime:RenderNameStyle" minOccurs="0" maxOccurs="1" default="QUOTED">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether rendered schema, table, column names, etc should be quoted
|
||||
in rendered SQL, or transformed in any other way.
|
||||
<p>
|
||||
This is set to "QUOTED" by default for backwards-compatibility]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
This is set to "QUOTED" by default for backwards-compatibility.
|
||||
<p>
|
||||
@deprecated - 3.12.0 - [#5909] - Use {@link RenderQuotedNames} and {@link RenderNameCase} instead.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderKeywordCase" type="jooq-runtime:RenderKeywordCase" minOccurs="0" maxOccurs="1" default="AS_IS">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether the case of {@link org.jooq.Keyword} references should be modified in any way.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderKeywordStyle" type="jooq-runtime:RenderKeywordStyle" minOccurs="0" maxOccurs="1" default="AS_IS">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether SQL keywords should be rendered with upper or lower case.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether the case of {@link org.jooq.Keyword} references should be modified in any way.
|
||||
<p>
|
||||
@deprecated - 3.12.0 - [#5909] - Use {@link RenderQuotedNames} and {@link RenderNameCase} instead.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="renderLocale" type="string" minOccurs="0" maxOccurs="1">
|
||||
@ -402,6 +426,57 @@ Either <input/> or <inputExpression/> must be provided]]></jxb:javadoc></j
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="RenderQuotedNames">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Always render object names quoted, as defined in the database.
|
||||
Use this to stay on the safe side with case-sensitivity, special
|
||||
characters, and keywords. For instance:
|
||||
Oracle : "SYS"."ALL_TAB_COLS"
|
||||
MySQL : `information_schema`.`TABLES`
|
||||
SQL Server: [INFORMATION_SCHEMA].[TABLES] -->
|
||||
<enumeration value="ALWAYS"/>
|
||||
|
||||
<!-- Never quote names -->
|
||||
<enumeration value="NEVER"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="RenderNameCase">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Render object names, as defined in the database. For instance: schema.TABLE -->
|
||||
<enumeration value="AS_IS"/>
|
||||
|
||||
<!-- Force rendering object names in lower case. For instance: schema.table -->
|
||||
<enumeration value="LOWER"/>
|
||||
|
||||
<!-- Force rendering object names in upper case. For instance: SCHEMA.TABLE -->
|
||||
<enumeration value="UPPER"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="RenderKeywordCase">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Keywords are rendered "as is", i.e. mostly in lower case. For instance:
|
||||
select .. from .. where .. -->
|
||||
<enumeration value="AS_IS"/>
|
||||
|
||||
<!-- Keywords are rendered in lower case. For instance:
|
||||
select .. from .. where .. -->
|
||||
<enumeration value="LOWER"/>
|
||||
|
||||
<!-- Keywords are rendered in upper case. For instance:
|
||||
SELECT .. FROM .. WHERE .. -->
|
||||
<enumeration value="UPPER"/>
|
||||
|
||||
<!-- Keywords are rendered in Pascal Case. For instance:
|
||||
Select .. From .. Where .. -->
|
||||
<enumeration value="PASCAL"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="RenderKeywordStyle">
|
||||
<restriction base="string">
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user