[#2694] Fixed regression
This commit is contained in:
parent
63a11a18bd
commit
fa324447d8
@ -45,9 +45,11 @@ package org.jooq.impl;
|
||||
xxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
xxx
|
||||
x xxxxxxx xxxxx xxxx
|
||||
@ -71,24 +73,37 @@ xxxxx xxxxxxxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxx x
|
||||
x
|
||||
|
||||
xxxxxxxxx
|
||||
xxxxxx xxxxx xxxx xxxxxxxxxxxxxxxxx xxxx x
|
||||
xx xxxxxxxxxxxxxxxx xx xxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxx
|
||||
xxxxxx xxxx xxxxxxxxxxxxxxxxx xxxx x
|
||||
xx xxxx xxxxxxxxxx xxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxx xxxxx
|
||||
xxxx
|
||||
xxxxxxxxxxxxxxxxxx xxxxx
|
||||
x
|
||||
|
||||
xxxxxxxxx
|
||||
xxxxxx xxxxx xxxx xxxxxxxxxxxxxxxxxxx xxxxxxxx x
|
||||
xx xxxxxxxxxxxxxxxxxxxx xx xxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxx
|
||||
|
||||
xxxxxx xxxxxxxxx x xxx
|
||||
xxx xxxxxxx xxxxxx x xxxxxxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
xxxxxxxxx x xx xx
|
||||
x
|
||||
|
||||
xxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxx
|
||||
x
|
||||
xxxx x
|
||||
xxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxx
|
||||
x
|
||||
x
|
||||
|
||||
xxxxxxxxx
|
||||
xxxxxx xxxxx xxxx xxxxxxxxxxxxxxxx xxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxx
|
||||
x
|
||||
x
|
||||
xx [/pro] */
|
||||
@ -44,11 +44,14 @@ package org.jooq.impl;
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.UDT;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -62,17 +65,25 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
public void accept(Context<?> ctx) {
|
||||
if (ctx instanceof RenderContext)
|
||||
toSQL((RenderContext) ctx);
|
||||
else
|
||||
bind((BindContext) ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
switch (context.configuration().dialect().family()) {
|
||||
|
||||
/* [pro] xx
|
||||
xx xxxxxx xxxxxxxx xxxxxxxxxxxxxxxxx xxxxx xxx xxxxxx xxx xx xxxxx
|
||||
xx xx xxx xxxxxxxxxxxxxxxxx xxxxxxxx
|
||||
xxxx xxxxxxx x
|
||||
xx xxxxxxxxxxxxxxxx xx xxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxx
|
||||
xx xxxxxxxxxxxxxxxxxxxx xx xxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxxxxxx
|
||||
x xxxx x
|
||||
xxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxx
|
||||
x
|
||||
|
||||
xxxxxxx
|
||||
@ -82,16 +93,16 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
xxxx xxxx x
|
||||
|
||||
xx xxx xxxxxxxxxx xxx xxxxx xxxxxx xx xxxxxxxxxx xxxx xxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxx
|
||||
|
||||
xxxxxx xxxxxxxxx x xxxxx
|
||||
xxx xxxxxxxxx xxxxx x xxxxxxxxxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxx
|
||||
x
|
||||
|
||||
xxxxxxx
|
||||
@ -101,34 +112,34 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
// Due to lack of UDT support in the Postgres JDBC drivers, all UDT's
|
||||
// have to be inlined
|
||||
case POSTGRES: {
|
||||
toSQLInline(ctx);
|
||||
toSQLInline(context);
|
||||
return;
|
||||
}
|
||||
|
||||
// Assume default behaviour if dialect is not available
|
||||
default:
|
||||
toSQLInline(ctx);
|
||||
toSQLInline(context);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void toSQLInline(Context<?> ctx) {
|
||||
ctx.sql(getInlineConstructor(ctx));
|
||||
ctx.sql("(");
|
||||
private void toSQLInline(RenderContext context) {
|
||||
context.sql(getInlineConstructor(context));
|
||||
context.sql("(");
|
||||
|
||||
String separator = "";
|
||||
for (Field<?> field : value.fields()) {
|
||||
ctx.sql(separator);
|
||||
ctx.visit(val(value.getValue(field), field));
|
||||
context.sql(separator);
|
||||
context.visit(val(value.getValue(field), field));
|
||||
separator = ", ";
|
||||
}
|
||||
|
||||
ctx.sql(")");
|
||||
context.sql(")");
|
||||
}
|
||||
|
||||
private String getInlineConstructor(Context<?> ctx) {
|
||||
private String getInlineConstructor(RenderContext context) {
|
||||
// TODO [#884] Fix this with a local render context (using ctx.literal)
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (context.configuration().dialect().family()) {
|
||||
case POSTGRES:
|
||||
return "ROW";
|
||||
|
||||
@ -140,7 +151,7 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
// Assume default behaviour if dialect is not available
|
||||
default: {
|
||||
UDT<?> udt = value.getUDT();
|
||||
Schema mappedSchema = Utils.getMappedSchema(ctx.configuration(), udt.getSchema());
|
||||
Schema mappedSchema = Utils.getMappedSchema(context.configuration(), udt.getSchema());
|
||||
|
||||
if (mappedSchema != null) {
|
||||
return mappedSchema + "." + udt.getName();
|
||||
@ -151,4 +162,34 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
switch (context.configuration().dialect().family()) {
|
||||
|
||||
/* [pro] xx
|
||||
xx xxxxxx xxxxxxxx xxxxxxxxxxxxxxxxx xxxxx xxx xxxxxx xxx xx xxxxx
|
||||
xx xx xxx xxxxxxxxxxxxxxxxx xxxxxxxx
|
||||
xxxx xxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxx xxxxxx
|
||||
xxxxxx
|
||||
|
||||
xx xx xxx xxx xxxx xxxxxxxx xxxxxx xx xx xxxxxxx xxxx xxx xxxxxxxx xxxxx
|
||||
xxxx xxxx
|
||||
|
||||
xx [/pro] */
|
||||
// Postgres cannot bind a complete structured type. The type is
|
||||
// inlined instead: ROW(.., .., ..)
|
||||
case POSTGRES: {
|
||||
for (Field<?> field : value.fields()) {
|
||||
context.visit(val(value.getValue(field)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new SQLDialectNotSupportedException("UDTs not supported in dialect " + context.configuration().dialect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user