pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
11+ messages / 2 participants
[nested] [flat]

* [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-12 20:30 "vwassan (@vwassan)" <[email protected]>
  0 siblings, 0 replies; 11+ messages in thread

From: vwassan (@vwassan) @ 2025-09-12 20:30 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Addresses: https://github.com/pgjdbc/pgjdbc/issues/367

### Problem:
  When calling numeric getters (getByte(), getInt(), getLong(), getShort(), getFloat(), getDouble(), getBigDecimal()) on PostgreSQL boolean columns, the driver
  throws PSQLException: Bad value for type byte : f. 

  ### Solution:
  Added a new connection property `convertBooleanToNumeric` that enables automatic conversion of PostgreSQL boolean values to numeric types:
  - 't' → 1
  - 'f' → 0
  - Works with boolean columns
  - Property cached per connection for optimal performance
  - Boolean column type detection prevents false positive conversions

  ### Usage:
  // JDBC URL
  jdbc:postgresql://host:5432/db?convertBooleanToNumeric=true

  // HikariCP
  config.addDataSourceProperty("convertBooleanToNumeric", "true");

  // Spring Boot
  spring.datasource.hikari.data-source-properties.convertBooleanToNumeric=true

  ### Backward Compatibility:
  - Default: false (maintains existing behavior)
  - getBoolean() continues working regardless of property setting
  - No changes to existing application behavior unless explicitly enabled


### All Submissions:

* [x] Have you followed the guidelines in our [Contributing](https://github.com/pgjdbc/pgjdbc/blob/master/CONTRIBUTING.md) document?
* [x] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?

<!-- You can erase any parts of this template not applicable to your Pull Request. -->

### New Feature Submissions:

1. [x] Does your submission pass tests?
2. [x] Does `./gradlew styleCheck` pass ?
3. [x] Have you added your new test classes to an existing test suite in alphabetical order?

### Changes to Existing Features:

* [x] Does this break existing behaviour? If so please explain.
* [x] Have you added an explanation of what your changes do and why you'd like us to include them?
* [x] Have you written new tests for your core changes, as applicable?
* [x] Have you successfully run tests with your changes locally?


^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-12 21:33 ` "davecramer (@davecramer)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: davecramer (@davecramer) @ 2025-09-12 21:33 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java)

this has already been checked by the time you get here

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-12 21:34 ` "davecramer (@davecramer)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: davecramer (@davecramer) @ 2025-09-12 21:34 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java)

I don't believe there is a way for Postgres to return a capital T

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-12 21:39 ` "davecramer (@davecramer)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: davecramer (@davecramer) @ 2025-09-12 21:39 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

The conversions by ResultSet getter methods says get Float, Double, and BigDecimal should support this

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-14 00:41 ` "vwassan (@vwassan)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: vwassan (@vwassan) @ 2025-09-14 00:41 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java)

Thank you for the review comment. Made the changes. 

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-14 00:42 ` "vwassan (@vwassan)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: vwassan (@vwassan) @ 2025-09-14 00:42 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java)

Thank you for the review comment. Made the changes. 

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-14 11:28 ` "davecramer (@davecramer)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: davecramer (@davecramer) @ 2025-09-14 11:28 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on docs/content/documentation/use.md)

Should probably update the comment here to include double, float, bigdecimal

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-14 11:28 ` "davecramer (@davecramer)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: davecramer (@davecramer) @ 2025-09-14 11:28 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/PGProperty.java)

same note about the comment

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-14 13:58 ` "vwassan (@vwassan)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: vwassan (@vwassan) @ 2025-09-14 13:58 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on docs/content/documentation/use.md)

Updated.

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-14 13:59 ` "vwassan (@vwassan)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: vwassan (@vwassan) @ 2025-09-14 13:59 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

(on pgjdbc/src/main/java/org/postgresql/PGProperty.java)

Updated. 

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters
@ 2025-09-14 16:31 ` "vwassan (@vwassan)" <[email protected]>
  9 siblings, 0 replies; 11+ messages in thread

From: vwassan (@vwassan) @ 2025-09-14 16:31 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

@davecramer Made the changes. One SSL-related test on CI is failing. Not sure about it. 

^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2025-09-14 16:31 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-09-12 20:30 [pgjdbc/pgjdbc] PR #3796: Add configurable boolean-to-numeric conversion for ResultSet getters "vwassan (@vwassan)" <[email protected]>
2025-09-12 21:33 ` "davecramer (@davecramer)" <[email protected]>
2025-09-12 21:34 ` "davecramer (@davecramer)" <[email protected]>
2025-09-12 21:39 ` "davecramer (@davecramer)" <[email protected]>
2025-09-14 00:41 ` "vwassan (@vwassan)" <[email protected]>
2025-09-14 00:42 ` "vwassan (@vwassan)" <[email protected]>
2025-09-14 11:28 ` "davecramer (@davecramer)" <[email protected]>
2025-09-14 11:28 ` "davecramer (@davecramer)" <[email protected]>
2025-09-14 13:58 ` "vwassan (@vwassan)" <[email protected]>
2025-09-14 13:59 ` "vwassan (@vwassan)" <[email protected]>
2025-09-14 16:31 ` "vwassan (@vwassan)" <[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