Skip to content

Commit

Permalink
[#3707] UDTRecord.toString() doesn't correctly serialise attribute va…
Browse files Browse the repository at this point in the history
…lues
  • Loading branch information
lukaseder committed Aug 3, 2015
1 parent 071996b commit 1a6e4c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
13 changes: 12 additions & 1 deletion jOOQ/src/main/java/org/jooq/impl/AbstractParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
import static org.jooq.conf.ParamType.INLINED;
import static org.jooq.conf.ParamType.NAMED_OR_INLINED;

// ...
import org.jooq.Clause;
import org.jooq.Context;
import org.jooq.DataType;
import org.jooq.Param;
import org.jooq.UDTRecord;
import org.jooq.tools.StringUtils;

/**
Expand Down Expand Up @@ -88,7 +90,16 @@ abstract class AbstractParam<T> extends AbstractField<T> implements Param<T> {
* </ul>
*/
private static String name(Object value, String paramName) {
return paramName == null ? String.valueOf(value) : paramName;
return paramName != null
? paramName

// [#3707] Protect value.toString call for certain jOOQ types.
: value instanceof UDTRecord
? ((UDTRecord<?>) value).getUDT().getName()
: value instanceof ArrayRecord
? ((ArrayRecord<?>) value).getName()

: String.valueOf(value);
}

// ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
xx xxxxxx xx xxxxx x
xxx xx x x xxxxxx x
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxx x xx xx
x
Expand Down
22 changes: 1 addition & 21 deletions jOOQ/src/main/java/org/jooq/impl/UDTRecordImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,6 @@ private final <T> void setValue(Configuration configuration, Map<Object, Object>

@Override
public String toString() {
StringBuilder result = new StringBuilder();
String separator = "";

result.append(create().render(getUDT()));
result.append("(");

Object[] array = intoArray();

// [#3046] array can be null if custom RecordMapperProviders (illegally) return null
if (array != null) {
for (Object o : array) {
result.append(separator);
result.append(o);

separator = ", ";
}
}

result.append(")");

return result.toString();
return DSL.using(configuration()).renderInlined(DSL.inline(this));
}
}

0 comments on commit 1a6e4c0

Please sign in to comment.