[jOOQ/jOOQ#14800] Error when PostgreSQL anonymous block contains dollar

quoted string token
This commit is contained in:
Lukas Eder 2023-03-16 12:09:51 +01:00
parent 50feee7c5a
commit 830e32c791
15 changed files with 60 additions and 18 deletions

View File

@ -74,7 +74,7 @@ public final class Constants {
/**
* The current jooq-runtime XSD file name.
*/
public static final String XSD_RUNTIME = "jooq-runtime-3.18.0.xsd";
public static final String XSD_RUNTIME = "jooq-runtime-3.19.0.xsd";
/**
* The current jooq-runtime XML namespace.

View File

@ -74,7 +74,7 @@ public final class Constants {
/**
* The current jooq-runtime XSD file name.
*/
public static final String XSD_RUNTIME = "jooq-runtime-3.18.0.xsd";
public static final String XSD_RUNTIME = "jooq-runtime-3.19.0.xsd";
/**
* The current jooq-runtime XML namespace.

View File

@ -74,7 +74,7 @@ public final class Constants {
/**
* The current jooq-runtime XSD file name.
*/
public static final String XSD_RUNTIME = "jooq-runtime-3.18.0.xsd";
public static final String XSD_RUNTIME = "jooq-runtime-3.19.0.xsd";
/**
* The current jooq-runtime XML namespace.

View File

@ -28,7 +28,7 @@ public class InterpreterSearchSchema
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
protected String catalog;
@XmlElement(required = true)
protected String schema;

View File

@ -34,7 +34,7 @@ public class MappedCatalog
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
protected String input;
@XmlElement(type = String.class)
@XmlJavaTypeAdapter(RegexAdapter.class)

View File

@ -34,7 +34,7 @@ public class MappedSchema
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
protected String input;
@XmlElement(type = String.class)
@XmlJavaTypeAdapter(RegexAdapter.class)

View File

@ -30,7 +30,7 @@ public class MappedTable
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
protected String input;
@XmlElement(type = String.class)
@XmlJavaTypeAdapter(RegexAdapter.class)

View File

@ -28,7 +28,7 @@ public class MigrationSchema
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
protected String catalog;
@XmlElement(required = true)
protected String schema;

View File

@ -28,7 +28,7 @@ public class ParseSearchSchema
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
protected String catalog;
@XmlElement(required = true)
protected String schema;

View File

@ -28,7 +28,7 @@ public class RenderFormatting
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
@XmlElement(defaultValue = "\n")
protected String newline = "\n";
@XmlElement(defaultValue = " ")

View File

@ -32,7 +32,7 @@ public class RenderMapping
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
protected String defaultCatalog;
protected String defaultSchema;
@XmlElementWrapper(name = "catalogs")

View File

@ -36,7 +36,7 @@ public class Settings
implements Serializable, Cloneable, XMLAppendable
{
private final static long serialVersionUID = 31800L;
private final static long serialVersionUID = 31900L;
@XmlElement(defaultValue = "true")
protected Boolean forceIntegerTypesOnZeroScaleDecimals = true;
@XmlElement(defaultValue = "true")
@ -114,6 +114,8 @@ public class Settings
protected Boolean renderRedundantConditionForSeekClause = false;
@XmlElement(defaultValue = "false")
protected Boolean renderPlainSQLTemplatesAsRaw = false;
@XmlElement(defaultValue = "")
protected String renderDollarQuotedStringToken = "";
@XmlElement(defaultValue = ".")
protected String namePathSeparator = ".";
@XmlElement(defaultValue = "false")
@ -1288,6 +1290,22 @@ public class Settings
this.renderPlainSQLTemplatesAsRaw = value;
}
/**
* The token to place between the <code>$$</code> signs of a PostgreSQL dollar quoted string generated by jOOQ.
*
*/
public String getRenderDollarQuotedStringToken() {
return renderDollarQuotedStringToken;
}
/**
* The token to place between the <code>$$</code> signs of a PostgreSQL dollar quoted string generated by jOOQ.
*
*/
public void setRenderDollarQuotedStringToken(String value) {
this.renderDollarQuotedStringToken = value;
}
/**
* The character(s) to be used as a separator in paths encoded in a {@link Name}
* <p>
@ -6125,6 +6143,15 @@ public class Settings
return this;
}
/**
* The token to place between the <code>$$</code> signs of a PostgreSQL dollar quoted string generated by jOOQ.
*
*/
public Settings withRenderDollarQuotedStringToken(String value) {
setRenderDollarQuotedStringToken(value);
return this;
}
/**
* The character(s) to be used as a separator in paths encoded in a {@link Name}
* <p>
@ -7444,6 +7471,7 @@ public class Settings
builder.append("renderRowConditionForSeekClause", renderRowConditionForSeekClause);
builder.append("renderRedundantConditionForSeekClause", renderRedundantConditionForSeekClause);
builder.append("renderPlainSQLTemplatesAsRaw", renderPlainSQLTemplatesAsRaw);
builder.append("renderDollarQuotedStringToken", renderDollarQuotedStringToken);
builder.append("namePathSeparator", namePathSeparator);
builder.append("bindOffsetDateTimeType", bindOffsetDateTimeType);
builder.append("bindOffsetTimeType", bindOffsetTimeType);
@ -7936,6 +7964,15 @@ public class Settings
return false;
}
}
if (renderDollarQuotedStringToken == null) {
if (other.renderDollarQuotedStringToken!= null) {
return false;
}
} else {
if (!renderDollarQuotedStringToken.equals(other.renderDollarQuotedStringToken)) {
return false;
}
}
if (namePathSeparator == null) {
if (other.namePathSeparator!= null) {
return false;
@ -9622,6 +9659,7 @@ public class Settings
result = ((prime*result)+((renderRowConditionForSeekClause == null)? 0 :renderRowConditionForSeekClause.hashCode()));
result = ((prime*result)+((renderRedundantConditionForSeekClause == null)? 0 :renderRedundantConditionForSeekClause.hashCode()));
result = ((prime*result)+((renderPlainSQLTemplatesAsRaw == null)? 0 :renderPlainSQLTemplatesAsRaw.hashCode()));
result = ((prime*result)+((renderDollarQuotedStringToken == null)? 0 :renderDollarQuotedStringToken.hashCode()));
result = ((prime*result)+((namePathSeparator == null)? 0 :namePathSeparator.hashCode()));
result = ((prime*result)+((bindOffsetDateTimeType == null)? 0 :bindOffsetDateTimeType.hashCode()));
result = ((prime*result)+((bindOffsetTimeType == null)? 0 :bindOffsetTimeType.hashCode()));

View File

@ -323,7 +323,7 @@ final class BlockImpl extends AbstractRowCountQuery implements Block {
if (keyword != null)
ctx.visit(keyword).sql(' ');
ctx.sql("$$")
ctx.sql('$').sql(ctx.settings().getRenderDollarQuotedStringToken()).sql('$')
.formatSeparator()
.data(DATA_FORCE_STATIC_STATEMENT, true);
}
@ -332,7 +332,7 @@ final class BlockImpl extends AbstractRowCountQuery implements Block {
if (decrement(ctx.data(), DATA_BLOCK_NESTING))
ctx.formatSeparator()
.sql("$$")
.sql('$').sql(ctx.settings().getRenderDollarQuotedStringToken()).sql('$')
.paramType(previous);
}

View File

@ -5047,7 +5047,7 @@ final class Tools {
case POSTGRES:
case YUGABYTEDB:
if (increment(ctx.data(), DATA_BLOCK_NESTING))
ctx.visit(K_DO).sql(" $$").formatSeparator();
ctx.visit(K_DO).sql(" $").sql(ctx.settings().getRenderDollarQuotedStringToken()).sql('$').formatSeparator();
ctx.visit(K_BEGIN).formatIndentStart().formatSeparator();
break;
@ -5082,7 +5082,7 @@ final class Tools {
.visit(K_END);
if (decrement(ctx.data(), DATA_BLOCK_NESTING))
ctx.sql(" $$");
ctx.sql(" $").sql(ctx.settings().getRenderDollarQuotedStringToken()).sql('$');
break;
}

View File

@ -1,10 +1,10 @@
<?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-3.18.0.xsd"
xmlns:jooq-runtime="http://www.jooq.org/xsd/jooq-runtime-3.19.0.xsd"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:annox="http://annox.dev.java.net"
targetNamespace="http://www.jooq.org/xsd/jooq-runtime-3.18.0.xsd"
targetNamespace="http://www.jooq.org/xsd/jooq-runtime-3.19.0.xsd"
elementFormDefault="qualified"
jxb:extensionBindingPrefixes="annox"
jxb:version="2.1">
@ -255,6 +255,10 @@ jOOQ may help the optimiser, e.g. <code>(a <= :a) AND (a, b) < ('a', 'b')</code>
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether plain SQL templates ({@link org.jooq.SQL}) are rendered as raw string content.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="renderDollarQuotedStringToken" type="string" minOccurs="0" maxOccurs="1" default="">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The token to place between the <code>$$</code> signs of a PostgreSQL dollar quoted string generated by jOOQ.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="namePathSeparator" type="string" minOccurs="0" maxOccurs="1" default=".">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The character(s) to be used as a separator in paths encoded in a {@link Name}
<p>