-
Notifications
You must be signed in to change notification settings - Fork 819
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
createArrayOf
fails if byte[][]
erased to Object[]
#2630
Comments
Interesting @bokken I believe you have some insight into this ? |
There is discussion on #2226. I think it would work to use |
So I guess the issues here is we don't know whether this is an array of bytes or a string? |
There is some ambiguity there, but /assuming/ an array of |
if this is the case should we implement it this way ? |
As an example, one can have Looking at JDBC docs, it doesn't restrict |
Not sure I agree with this opinion; but I'm not ruling it out. There is a considerably amount of ambiguity in the spec. |
That is not part of jdbc spec we are implementing, so not sure how relevant it is.
I agree with @davecramer that there is much leeway/ambiguity in the spec. For example oracle does not support this method at all. This is a specific use case which has never been supported by pgjdbc. It might be reasonable to add support. |
Hi (JDBI code author/maintainer here), What our code does is that we receive a request to bind a varargs list of java.sql.Array sqlArray = statement.getConnection().createArrayOf(typeName, array);
statement.setArray(position, sqlArray); with typeName being "bytea" and the array being an I feel that this is an actual driver limitation, because the DB itself seems to support this just fine. |
Add an explicit array type that creates the postgres internal BYTEA format so that the driver is willing to write arrays. Fixes jdbi#2109, workaround for the problem in pgjdbc/pgjdbc#2630
I think we are open to the implementation. Care to provide a PR ? |
Add an explicit array type that creates the postgres internal BYTEA format so that the driver is willing to write arrays. Fixes jdbi#2109, workaround for the problem in pgjdbc/pgjdbc#2630
Add an explicit array type that creates the postgres internal BYTEA format so that the driver is willing to write arrays. Fixes jdbi#2109, workaround for the problem in pgjdbc/pgjdbc#2630
Add an explicit array type that creates the postgres internal BYTEA format so that the driver is willing to write arrays. Fixes jdbi#2109, workaround for the problem in pgjdbc/pgjdbc#2630
@hgschmie any reason not to provide a PR here ? |
Postgres driver: org.postgresql:postgresql:42.5.0
Reproducer:
Throws:
Original issue in JDBI: jdbi/jdbi#2109
The problem is that the code uses
getComponentType()
to selectArrayEncoder
inArrayEncoding.getArrayEncoder()
which obviously fails for erasedObject[]
and falls back to usingOBJECT_ARRAY
which for some reason doesn't support encodingbyte[]
elements. I think it should be possible to addiitionally use the first element to detect element type falling back toOBJECT_ARRAY
for empty arrays only.The text was updated successfully, but these errors were encountered: