-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Postgres custom type #55
Comments
Thanks for the nice design, I found a workaround for this issue. Here is the solution in case anyone facing the same problem:
Sample usage:
The code is written in Scala. |
@zhenwenc , can you explain what to do further with this code? how to include/replace original |
Hi @panser , the value of
Let me know if you need more help. |
I also ran into this situation, with a jsonb field... Here's roughly the java equivalent of what @zhenwenc did - slowteetoe@bf8cd6c (I didn't create a PR because it adds a dependency on postgres, don't know how you feel about that) |
@slowteetoe Thanks very much for the Java version. A suggestion, I would like to recommend making a wrapper for DBSetup to use with this custom binder, rather than adding it to the DBSetup library as this binder is very Postgres specific. Just an example, here is what my code looks like:
|
A Java sample code (thanks to @zhenwenc):
|
Thanks @mnafshin, will give it a try! |
Any plans to support this? |
Recently have a requirement on using custom Enum type on Postgres database, but when I trying to insert test data with DbSetup, the following exception thrown:
Cause: org.postgresql.util.PSQLException: ERROR: column "animal_type" is of type currency but expression is of type character varying
The reason is that, to insert data with JDBC prepared statement, the query needs to be in form:
INSERT INTO pet (pet_id, pet_type, name) VALUES (?, ?::animal_type, ?);
Please refer this site for more details: http://www.gotoquiz.com/web-coding/programming/java-programming/convert-between-java-enums-and-postgresql-enums/
By digging into the source code, the only way I found to solve this problem is hacking the Insert#execute method (
DbSetup/src/main/java/com/ninja_squad/dbsetup/operation/Insert.java
Line 257 in f9f9fd5
I am wondering, is there any other convenient way to achieve this?
Thanks in advance!
The text was updated successfully, but these errors were encountered: