[jOOQ/jOOQ#13161] Fix inlining of user types

This commit is contained in:
Lukas Eder 2022-03-07 16:50:43 +01:00
parent d4d04c27d9
commit c1f9680dc3
2 changed files with 17 additions and 2 deletions

View File

@ -37,6 +37,8 @@
*/
package org.jooq.postgres.extensions.bindings;
import static org.jooq.impl.DSL.keyword;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
@ -44,6 +46,7 @@ import org.jooq.BindingGetSQLInputContext;
import org.jooq.BindingSQLContext;
import org.jooq.BindingSetSQLOutputContext;
import org.jooq.impl.AbstractBinding;
import org.jooq.impl.DSL;
/**
* A common base class for bindings in this module.
@ -65,7 +68,19 @@ public abstract class AbstractPostgresBinding<T, U> extends AbstractBinding<T, U
@Override
protected void sqlInline(BindingSQLContext<U> ctx) throws SQLException {
super.sqlInline(ctx);
if (ctx.value() instanceof Object[]) {
ctx.render().visit(keyword("ARRAY")).sql('[');
String separator = "";
for (Object value : ((Object[]) ctx.value())) {
ctx.render().sql(separator).visit(value == null ? keyword("NULL") : DSL.inline("" + value));
separator = ", ";
}
ctx.render().sql(']');
}
else
super.sqlInline(ctx);
String castType = castType();
if (castType != null)

View File

@ -105,6 +105,6 @@ public final class Hstore implements Serializable {
@Override
public String toString() {
return String.valueOf(data);
return org.postgresql.util.HStoreConverter.toString(data);
}
}