pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feed[pgjdbc/pgjdbc] issue #3608: Support BigInteger[] in PgPreparedStatement#setObject(int, java.lang.Object)
5+ messages / 2 participants
[nested] [flat]
* [pgjdbc/pgjdbc] issue #3608: Support BigInteger[] in PgPreparedStatement#setObject(int, java.lang.Object)
@ 2025-04-17 15:50 "victornoel (@victornoel)" <[email protected]>
0 siblings, 0 replies; 5+ messages in thread
From: victornoel (@victornoel) @ 2025-04-17 15:50 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
**Describe the issue**
Hi, I noticed that even though I can use `PreparedStatement.setObject` with an array of `BigInteger` I get the following exception:
```
Exception in thread "main" org.postgresql.util.PSQLException: Cannot cast an instance of [Ljava.math.BigInteger; to type Types.ARRAY
at org.postgresql.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:1059)
at default.Test.main(DefaultDomainContext.java:211)
Caused by: java.sql.SQLFeatureNotSupportedException
at org.postgresql.jdbc.PgPreparedStatement.setObjectArray(PgPreparedStatement.java:777)
at org.postgresql.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:1056)
... 1 more
```
If I do the same (see repro below) with `BigDecimal`, it works as expected.
**Driver Version?**
42.7.5
**Java Version?**
21
**OS Version?**
Archlinux
**PostgreSQL Version?**
17
**To Reproduce**
```
public static void main(String[] args) throws Exception {
String url = "jdbc:postgresql://localhost:5432/postgres";
Properties props = new Properties();
props.setProperty("user", "postgres");
props.setProperty("password", "postgres");
try (Connection conn = DriverManager.getConnection(url, props)) {
try (PreparedStatement statement = conn.prepareStatement("select ? = ANY(?)")) {
statement.setObject(1, BigInteger.ONE);
statement.setObject(2, new BigInteger[]{BigInteger.ONE});
try (ResultSet rs = statement.executeQuery()) {
if (rs.next()) {
System.out.println("result: " + rs.getBoolean(1));
}
}
}
}
}
```
**Expected behaviour**
It would work :)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3608: Support BigInteger[] in PgPreparedStatement#setObject(int, java.lang.Object)
@ 2025-04-17 16:12 "davecramer (@davecramer)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: davecramer (@davecramer) @ 2025-04-17 16:12 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
The proper way to do this is use Connection.createArrayOf https://github.com/pgjdbc/pgjdbc/blob/1fb8dd1e06b19b4916b516ecf8aa3eda90bf2fcb/pgjdbc/src/main/java/...
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3608: Support BigInteger[] in PgPreparedStatement#setObject(int, java.lang.Object)
@ 2025-04-17 16:45 "victornoel (@victornoel)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: victornoel (@victornoel) @ 2025-04-17 16:45 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
Hello @davecramer , I am indeed aware of that but I was wondering if we could get support for more of the typical Java types like it is already the case for String[], Long[] or as already mentioned BigDecimal[] in setObject().
I of course understand if this is too much out of the scope of the project.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3608: Support BigInteger[] in PgPreparedStatement#setObject(int, java.lang.Object)
@ 2025-04-17 16:53 "davecramer (@davecramer)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: davecramer (@davecramer) @ 2025-04-17 16:53 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
I have no issue with it if you want to provide a PR
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3608: Support BigInteger[] in PgPreparedStatement#setObject(int, java.lang.Object)
@ 2025-04-18 07:11 "victornoel (@victornoel)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: victornoel (@victornoel) @ 2025-04-18 07:11 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
I started to look at it but it's not as easy to implement as `BigDecimal` because while there is `Oid.NUMERIC` that only matches `BigDecimal`, while for `BigInteger`, we would use `Oid.INT8` but it's already used for `long`/`Long`: so it's hard to reuse existing tests for example to introduce `BigIntegerObjectArraysTest`. I haven't even looked yet at the actual implementation ^^
Any advice here is welcome, but I will anyway try to continue by myself in the next weeks. Thanks!
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2025-04-18 07:11 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-04-17 15:50 [pgjdbc/pgjdbc] issue #3608: Support BigInteger[] in PgPreparedStatement#setObject(int, java.lang.Object) "victornoel (@victornoel)" <[email protected]>
2025-04-17 16:12 ` "davecramer (@davecramer)" <[email protected]>
2025-04-17 16:45 ` "victornoel (@victornoel)" <[email protected]>
2025-04-17 16:53 ` "davecramer (@davecramer)" <[email protected]>
2025-04-18 07:11 ` "victornoel (@victornoel)" <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox