[#521] Add runtime configuration for SQL reference style (upper case, lower case, as-is, quoted)
This commit is contained in:
parent
19c706b0d6
commit
b55236f0ba
@ -62,6 +62,7 @@ import org.jooq.Result;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.TableRecord;
|
||||
import org.jooq.UpdatableRecord;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.conf.StatementType;
|
||||
import org.jooq.impl.Factory;
|
||||
@ -379,7 +380,7 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, D, T, U, I, IPK, T658, T725, T639
|
||||
@Test
|
||||
public void testRenderQuoted() throws Exception {
|
||||
Select<?> s =
|
||||
create(new Settings().withRenderQuoted(false))
|
||||
create(new Settings().withRenderNameStyle(RenderNameStyle.AS_IS))
|
||||
.select(TBook_ID(), TBook_TITLE(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())
|
||||
.from(TBook())
|
||||
.join(TAuthor()).on(TBook_AUTHOR_ID().equal(TAuthor_ID()))
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<!-- Run a full mvn clean package install deploy first before this -->
|
||||
<target name="xjc-generator" description="Generate JAXB artefacts from XSD">
|
||||
<mkdir dir="${dir.target}" />
|
||||
<xjc schema="${dir.resources}/xsd/jooq-runtime-2.0.5.xsd" destdir="${dir.java}" package="org.jooq.conf">
|
||||
<xjc schema="${dir.resources}/xsd/jooq-runtime-2.1.0.xsd" destdir="${dir.java}" package="org.jooq.conf">
|
||||
<arg value="-extension"/>
|
||||
<arg value="-Xxew" />
|
||||
<arg value="-Xfluent-api" />
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2012.02.28 at 06:36:54 PM MEZ
|
||||
// Generated on: 2012.02.29 at 06:59:29 PM MEZ
|
||||
//
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
||||
* <all>
|
||||
* <element name="input" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="output" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* <element name="tables" type="{http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd}MappedTables" minOccurs="0"/>
|
||||
* <element name="tables" type="{http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd}MappedTables" minOccurs="0"/>
|
||||
* </all>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2012.02.28 at 06:36:54 PM MEZ
|
||||
// Generated on: 2012.02.29 at 06:59:29 PM MEZ
|
||||
//
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2012.02.28 at 06:36:54 PM MEZ
|
||||
// Generated on: 2012.02.29 at 06:59:29 PM MEZ
|
||||
//
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ import javax.xml.bind.annotation.XmlType;
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <all>
|
||||
* <element name="defaultSchema" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* <element name="schemata" type="{http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd}MappedSchemata" minOccurs="0"/>
|
||||
* <element name="schemata" type="{http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd}MappedSchemata" minOccurs="0"/>
|
||||
* </all>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
|
||||
47
jOOQ/src/main/java/org/jooq/conf/RenderNameStyle.java
Normal file
47
jOOQ/src/main/java/org/jooq/conf/RenderNameStyle.java
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2012.02.29 at 06:59:29 PM MEZ
|
||||
//
|
||||
|
||||
|
||||
package org.jooq.conf;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for RenderNameStyle.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p>
|
||||
* <pre>
|
||||
* <simpleType name="RenderNameStyle">
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="QUOTED"/>
|
||||
* <enumeration value="AS_IS"/>
|
||||
* <enumeration value="LOWER"/>
|
||||
* <enumeration value="UPPER"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@XmlEnum
|
||||
public enum RenderNameStyle {
|
||||
|
||||
QUOTED,
|
||||
AS_IS,
|
||||
LOWER,
|
||||
UPPER;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static RenderNameStyle fromValue(String v) {
|
||||
return valueOf(v);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2012.02.28 at 06:36:54 PM MEZ
|
||||
// Generated on: 2012.02.29 at 06:59:29 PM MEZ
|
||||
//
|
||||
|
||||
|
||||
@ -29,11 +29,11 @@ import javax.xml.bind.annotation.XmlType;
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <all>
|
||||
* <element name="renderMapping" type="{http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd}RenderMapping" minOccurs="0"/>
|
||||
* <element name="renderQuoted" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
|
||||
* <element name="statementType" type="{http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd}StatementType" minOccurs="0"/>
|
||||
* <element name="renderMapping" type="{http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd}RenderMapping" minOccurs="0"/>
|
||||
* <element name="renderNameStyle" type="{http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd}RenderNameStyle" minOccurs="0"/>
|
||||
* <element name="statementType" type="{http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd}StatementType" minOccurs="0"/>
|
||||
* <element name="executeLogging" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
|
||||
* <element name="executeListeners" type="{http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd}ExecuteListeners" minOccurs="0"/>
|
||||
* <element name="executeListeners" type="{http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd}ExecuteListeners" minOccurs="0"/>
|
||||
* </all>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
@ -52,8 +52,8 @@ public class Settings
|
||||
|
||||
private final static long serialVersionUID = 205L;
|
||||
protected RenderMapping renderMapping;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean renderQuoted = true;
|
||||
@XmlElement(defaultValue = "QUOTED")
|
||||
protected RenderNameStyle renderNameStyle = RenderNameStyle.QUOTED;
|
||||
@XmlElement(defaultValue = "PREPARED_STATEMENT")
|
||||
protected StatementType statementType = StatementType.PREPARED_STATEMENT;
|
||||
@XmlElement(defaultValue = "true")
|
||||
@ -87,27 +87,27 @@ public class Settings
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the renderQuoted property.
|
||||
* Gets the value of the renderNameStyle property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
* {@link RenderNameStyle }
|
||||
*
|
||||
*/
|
||||
public Boolean isRenderQuoted() {
|
||||
return renderQuoted;
|
||||
public RenderNameStyle getRenderNameStyle() {
|
||||
return renderNameStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the renderQuoted property.
|
||||
* Sets the value of the renderNameStyle property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
* {@link RenderNameStyle }
|
||||
*
|
||||
*/
|
||||
public void setRenderQuoted(Boolean value) {
|
||||
this.renderQuoted = value;
|
||||
public void setRenderNameStyle(RenderNameStyle value) {
|
||||
this.renderNameStyle = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,8 +170,8 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withRenderQuoted(Boolean value) {
|
||||
setRenderQuoted(value);
|
||||
public Settings withRenderNameStyle(RenderNameStyle value) {
|
||||
setRenderNameStyle(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2012.02.28 at 06:36:54 PM MEZ
|
||||
// Generated on: 2012.02.29 at 06:59:29 PM MEZ
|
||||
//
|
||||
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
|
||||
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||
// Generated on: 2012.02.28 at 06:36:54 PM MEZ
|
||||
// Generated on: 2012.02.29 at 06:59:29 PM MEZ
|
||||
//
|
||||
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd")
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd")
|
||||
package org.jooq.conf;
|
||||
|
||||
@ -42,6 +42,7 @@ import org.jooq.QueryPart;
|
||||
import org.jooq.QueryPartInternal;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -119,7 +120,18 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
|
||||
@Override
|
||||
public final RenderContext literal(String literal) {
|
||||
if (Boolean.TRUE.equals(configuration.getSettings().isRenderQuoted())) {
|
||||
RenderNameStyle style = configuration.getSettings().getRenderNameStyle();
|
||||
|
||||
if (RenderNameStyle.LOWER.equals(style)) {
|
||||
sql(literal.toLowerCase());
|
||||
}
|
||||
else if (RenderNameStyle.UPPER.equals(style)) {
|
||||
sql(literal.toUpperCase());
|
||||
}
|
||||
else if (RenderNameStyle.AS_IS.equals(style)) {
|
||||
sql(literal);
|
||||
}
|
||||
else {
|
||||
switch (configuration.getDialect()) {
|
||||
case MYSQL:
|
||||
sql("`").sql(literal).sql("`");
|
||||
@ -152,9 +164,6 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
sql(literal);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1,109 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:jooq-runtime="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd"
|
||||
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:jooq-runtime="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd"
|
||||
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
|
||||
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
|
||||
jaxb:version="1.0" jaxb:extensionBindingPrefixes="xjc"
|
||||
targetNamespace="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd">
|
||||
targetNamespace="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd">
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<jaxb:globalBindings>
|
||||
<xjc:serializable uid="205"/>
|
||||
</jaxb:globalBindings>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<jaxb:globalBindings>
|
||||
<xjc:serializable uid="205"/>
|
||||
</jaxb:globalBindings>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
|
||||
<element name="settings" type="jooq-runtime:Settings"/>
|
||||
|
||||
<complexType name="Settings">
|
||||
<all>
|
||||
<!-- Configure render mapping for runtime schema / table rewriting in
|
||||
generated SQL -->
|
||||
<element name="renderMapping" type="jooq-runtime:RenderMapping" minOccurs="0" maxOccurs="1"/>
|
||||
<complexType name="Settings">
|
||||
<all>
|
||||
<!-- Configure render mapping for runtime schema / table rewriting in
|
||||
generated SQL -->
|
||||
<element name="renderMapping" type="jooq-runtime:RenderMapping" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- Whether rendered schema, table, column names, etc should be quoted
|
||||
in rendered SQL. This is set to "true" by default for backwards-compatibility -->
|
||||
<element name="renderQuoted" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
<!-- The type of statement that is to be executed -->
|
||||
<element name="statementType" type="jooq-runtime:StatementType" minOccurs="0" maxOccurs="1" default="PREPARED_STATEMENT"/>
|
||||
|
||||
<!-- The type of statement that is to be executed -->
|
||||
<element name="statementType" type="jooq-runtime:StatementType" minOccurs="0" maxOccurs="1" default="PREPARED_STATEMENT"/>
|
||||
<!-- When set to true, this will add jOOQ's default logging ExecuteListeners -->
|
||||
<element name="executeLogging" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
|
||||
<!-- When set to true, this will add jOOQ's default logging ExecuteListeners -->
|
||||
<element name="executeLogging" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
<!-- The event listeners to be notified upon execution events -->
|
||||
<element name="executeListeners" type="jooq-runtime:ExecuteListeners" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<!-- The event listeners to be notified upon execution events -->
|
||||
<element name="executeListeners" type="jooq-runtime:ExecuteListeners" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
<complexType name="RenderMapping">
|
||||
<all>
|
||||
<!-- The default schema as defined in org.jooq.Schema.getName()
|
||||
This schema will be omitted in rendered SQL -->
|
||||
<element name="defaultSchema" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<complexType name="RenderMapping">
|
||||
<all>
|
||||
<!-- The default schema as defined in org.jooq.Schema.getName()
|
||||
This schema will be omitted in rendered SQL -->
|
||||
<element name="defaultSchema" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
<!-- The mapped schemata configuration -->
|
||||
<element name="schemata" type="jooq-runtime:MappedSchemata" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<!-- The mapped schemata configuration -->
|
||||
<element name="schemata" type="jooq-runtime:MappedSchemata" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
<complexType name="MappedSchemata">
|
||||
<sequence>
|
||||
<element name="schema" type="jooq-runtime:MappedSchema" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedSchemata">
|
||||
<sequence>
|
||||
<element name="schema" type="jooq-runtime:MappedSchema" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
<complexType name="MappedSchema">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Schema.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
|
||||
<complexType name="MappedSchema">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Schema.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
<!-- The output schema as it will be rendered in SQL
|
||||
When this is omitted, you can still apply table mapping -->
|
||||
<element name="output" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- The output schema as it will be rendered in SQL
|
||||
When this is omitted, you can still apply table mapping -->
|
||||
<element name="output" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
<!-- Configure table mapping for runtime table rewriting in
|
||||
generated SQL -->
|
||||
<element name="tables" type="jooq-runtime:MappedTables" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<!-- Configure table mapping for runtime table rewriting in
|
||||
generated SQL -->
|
||||
<element name="tables" type="jooq-runtime:MappedTables" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
<complexType name="MappedTables">
|
||||
<sequence>
|
||||
<element name="table" type="jooq-runtime:MappedTable" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedTables">
|
||||
<sequence>
|
||||
<element name="table" type="jooq-runtime:MappedTable" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
<complexType name="MappedTable">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Table.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
|
||||
<complexType name="MappedTable">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Table.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
<!-- The output schema as it will be rendered in SQL -->
|
||||
<element name="output" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<!-- The output schema as it will be rendered in SQL -->
|
||||
<element name="output" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
<simpleType name="StatementType">
|
||||
<restriction base="string">
|
||||
|
||||
<simpleType name="StatementType">
|
||||
<restriction base="string">
|
||||
<!-- Execute statements with inlined bind values, avoiding JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="STATIC_STATEMENT"/>
|
||||
|
||||
<!-- Execute statements with inlined bind values, avoiding JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="STATIC_STATEMENT"/>
|
||||
<!-- Execute statements with bind values, using JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="PREPARED_STATEMENT"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<!-- Execute statements with bind values, using JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="PREPARED_STATEMENT"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
<complexType name="ExecuteListeners">
|
||||
<sequence>
|
||||
|
||||
<complexType name="ExecuteListeners">
|
||||
<sequence>
|
||||
|
||||
<!-- An event listener implementing org.jooq.ExecuteListener -->
|
||||
<element name="executeListener" type="string" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
<!-- An event listener implementing org.jooq.ExecuteListener -->
|
||||
<element name="executeListener" type="string" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
141
jOOQ/src/main/resources/xsd/jooq-runtime-2.1.0.xsd
Normal file
141
jOOQ/src/main/resources/xsd/jooq-runtime-2.1.0.xsd
Normal file
@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:jooq-runtime="http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd"
|
||||
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
|
||||
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
|
||||
jaxb:version="1.0" jaxb:extensionBindingPrefixes="xjc"
|
||||
targetNamespace="http://www.jooq.org/xsd/jooq-runtime-2.1.0.xsd">
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<jaxb:globalBindings>
|
||||
<xjc:serializable uid="205"/>
|
||||
</jaxb:globalBindings>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
|
||||
<element name="settings" type="jooq-runtime:Settings"/>
|
||||
|
||||
<complexType name="Settings">
|
||||
<all>
|
||||
<!-- Configure render mapping for runtime schema / table rewriting in
|
||||
generated SQL -->
|
||||
<element name="renderMapping" type="jooq-runtime:RenderMapping" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- Whether rendered schema, table, column names, etc should be quoted
|
||||
in rendered SQL, or transformed in any other way.
|
||||
This is set to "QUOTED" by default for backwards-compatibility -->
|
||||
<element name="renderNameStyle" type="jooq-runtime:RenderNameStyle" minOccurs="0" maxOccurs="1" default="QUOTED"/>
|
||||
|
||||
<!-- The type of statement that is to be executed -->
|
||||
<element name="statementType" type="jooq-runtime:StatementType" minOccurs="0" maxOccurs="1" default="PREPARED_STATEMENT"/>
|
||||
|
||||
<!-- When set to true, this will add jOOQ's default logging ExecuteListeners -->
|
||||
<element name="executeLogging" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
|
||||
<!-- The event listeners to be notified upon execution events -->
|
||||
<element name="executeListeners" type="jooq-runtime:ExecuteListeners" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="RenderMapping">
|
||||
<all>
|
||||
<!-- The default schema as defined in org.jooq.Schema.getName()
|
||||
This schema will be omitted in rendered SQL -->
|
||||
<element name="defaultSchema" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- The mapped schemata configuration -->
|
||||
<element name="schemata" type="jooq-runtime:MappedSchemata" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedSchemata">
|
||||
<sequence>
|
||||
<element name="schema" type="jooq-runtime:MappedSchema" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedSchema">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Schema.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
|
||||
<!-- The output schema as it will be rendered in SQL
|
||||
When this is omitted, you can still apply table mapping -->
|
||||
<element name="output" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- Configure table mapping for runtime table rewriting in
|
||||
generated SQL -->
|
||||
<element name="tables" type="jooq-runtime:MappedTables" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedTables">
|
||||
<sequence>
|
||||
<element name="table" type="jooq-runtime:MappedTable" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedTable">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Table.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
|
||||
<!-- The output schema as it will be rendered in SQL -->
|
||||
<element name="output" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<simpleType name="StatementType">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Execute statements with inlined bind values, avoiding JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="STATIC_STATEMENT"/>
|
||||
|
||||
<!-- Execute statements with bind values, using JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="PREPARED_STATEMENT"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="RenderNameStyle">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Render object names quoted, as defined in the database. Use this
|
||||
to stay on the safe side with case-sensitivity and special
|
||||
characters. For instance:
|
||||
Oracle : "SYS"."ALL_TAB_COLS"
|
||||
MySQL : `information_schema`.`TABLES`
|
||||
SQL Server: [INFORMATION_SCHEMA].[TABLES] -->
|
||||
<enumeration value="QUOTED"/>
|
||||
|
||||
<!-- Render object names, as defined in the database. For instance:
|
||||
Oracle : SYS.ALL_TAB_COLS
|
||||
MySQL : information_schema.TABLES
|
||||
SQL Server: INFORMATION_SCHEMA.TABLES -->
|
||||
<enumeration value="AS_IS"/>
|
||||
|
||||
<!-- Force rendering object names in lower case. For instance:
|
||||
Oracle : sys.all_tab_cols
|
||||
MySQL : information_schema.tables
|
||||
SQL Server: information_schema.tables -->
|
||||
<enumeration value="LOWER"/>
|
||||
|
||||
<!-- Force rendering object names in upper case. For instance:
|
||||
Oracle : SYS.ALL_TAB_COLS
|
||||
MySQL : INFORMATION_SCHEMA.TABLES
|
||||
SQL Server: INFORMATION_SCHEMA.TABLES -->
|
||||
<enumeration value="UPPER"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<complexType name="ExecuteListeners">
|
||||
<sequence>
|
||||
|
||||
<!-- An event listener implementing org.jooq.ExecuteListener -->
|
||||
<element name="executeListener" type="string" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
@ -96,6 +96,7 @@ import org.jooq.SimpleSelectQuery;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.Truncate;
|
||||
import org.jooq.UpdateQuery;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.impl.CustomCondition;
|
||||
import org.jooq.impl.CustomField;
|
||||
import org.jooq.impl.Factory;
|
||||
@ -2190,19 +2191,35 @@ public class jOOQTest {
|
||||
RenderContext r_refP = r_refP();
|
||||
RenderContext r_ref = r_ref();
|
||||
|
||||
r_refI.getSettings().setRenderQuoted(false);
|
||||
r_refP.getSettings().setRenderQuoted(false);
|
||||
r_ref.getSettings().setRenderQuoted(false);
|
||||
r_refI.getSettings().setRenderNameStyle(RenderNameStyle.AS_IS);
|
||||
r_refP.getSettings().setRenderNameStyle(RenderNameStyle.AS_IS);
|
||||
r_ref.getSettings().setRenderNameStyle(RenderNameStyle.AS_IS);
|
||||
|
||||
assertEquals("select 3 from TABLE1 where TABLE1.ID1 = 4", r_refI.render(q));
|
||||
assertEquals("select 1 from TABLE1 where TABLE1.ID1 = 2", r_refI.render(q));
|
||||
assertEquals("select :1 from TABLE1 where TABLE1.ID1 = :2", r_refP.render(q));
|
||||
assertEquals("select ? from TABLE1 where TABLE1.ID1 = ?", r_ref.render(q));
|
||||
|
||||
r_refI.getSettings().setRenderQuoted(true);
|
||||
r_refP.getSettings().setRenderQuoted(true);
|
||||
r_ref.getSettings().setRenderQuoted(true);
|
||||
r_refI.getSettings().setRenderNameStyle(RenderNameStyle.LOWER);
|
||||
r_refP.getSettings().setRenderNameStyle(RenderNameStyle.LOWER);
|
||||
r_ref.getSettings().setRenderNameStyle(RenderNameStyle.LOWER);
|
||||
|
||||
assertEquals("select 3 from \"TABLE1\" where \"TABLE1\".\"ID1\" = 4", r_refI.render(q));
|
||||
assertEquals("select 1 from table1 where table1.id1 = 2", r_refI.render(q));
|
||||
assertEquals("select :1 from table1 where table1.id1 = :2", r_refP.render(q));
|
||||
assertEquals("select ? from table1 where table1.id1 = ?", r_ref.render(q));
|
||||
|
||||
r_refI.getSettings().setRenderNameStyle(RenderNameStyle.UPPER);
|
||||
r_refP.getSettings().setRenderNameStyle(RenderNameStyle.UPPER);
|
||||
r_ref.getSettings().setRenderNameStyle(RenderNameStyle.UPPER);
|
||||
|
||||
assertEquals("select 1 from TABLE1 where TABLE1.ID1 = 2", r_refI.render(q));
|
||||
assertEquals("select :1 from TABLE1 where TABLE1.ID1 = :2", r_refP.render(q));
|
||||
assertEquals("select ? from TABLE1 where TABLE1.ID1 = ?", r_ref.render(q));
|
||||
|
||||
r_refI.getSettings().setRenderNameStyle(RenderNameStyle.QUOTED);
|
||||
r_refP.getSettings().setRenderNameStyle(RenderNameStyle.QUOTED);
|
||||
r_ref.getSettings().setRenderNameStyle(RenderNameStyle.QUOTED);
|
||||
|
||||
assertEquals("select 1 from \"TABLE1\" where \"TABLE1\".\"ID1\" = 2", r_refI.render(q));
|
||||
assertEquals("select :1 from \"TABLE1\" where \"TABLE1\".\"ID1\" = :2", r_refP.render(q));
|
||||
assertEquals("select ? from \"TABLE1\" where \"TABLE1\".\"ID1\" = ?", r_ref.render(q));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user