Fixed a problem where the Postgres JDBC driver would call toString() on an
enum, when we need it to be using name() instead. We just take care to send it the results of name() instead of the enum value itself. It would be nice to share this code with BuildVisitor.bindValue, but that would require yet further twisting and factoring of the code, obscuring it even more. We'll just hope that special cases like Enum and ByteEnum aren't going to keep cropping up.
This commit is contained in:
@@ -60,6 +60,11 @@ public class PostgreSQL4Builder extends PostgreSQLBuilder
|
||||
type = "smallint"; // tinyint is in the spec, but PG doesn't recognize?
|
||||
} else if (testValue instanceof Enum<?>) {
|
||||
type = "varchar";
|
||||
// we need to replace the enum values with their name() because otherwise
|
||||
// the Postgres JDBC driver will call toString() on them which is incorrect
|
||||
for (int ii = 0; ii < values.length; ii++) {
|
||||
values[ii] = ((Enum<?>)values[ii]).name();
|
||||
}
|
||||
} else if (testValue instanceof Timestamp) {
|
||||
type = "timestamp";
|
||||
} else if (testValue instanceof Date) {
|
||||
|
||||
Reference in New Issue
Block a user