Subject: [pgjdbc/pgjdbc] issue #367: BOOLEAN field treated as BIT

From: "gtors (@gtors)" <[email-masked]>
Date: Mon, 07 Sep 2015 11:43:27 +0000

This issue cause bugs in third-party libraries. For example: [stackoverflow question](https://stackoverflow.com/questions/26298295/unneccessary-database-changeset-related-to-boolean-after-grails-2-4-3-upgrade)

The root of the evil consists in [TypeInfoCache.java#L87](https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/jdbc2/TypeInfoCache.java#L87)

I know it was for backward compatibility, but please make it configurable at least.

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Mon, 07 Sep 2015 21:03:31 +0000

I'm looking at when this was changed and AFAICT it hasn't. This has been like this for a while ?Certainly before hibernate changed their code last

---

From: "chris-baynes (@chris-baynes)" <[email-masked]>
Date: Wed, 07 Nov 2018 13:12:00 +0000

I've recently encountered this problem when querying boolean columns. 
There's some logic in our code that says if the column type is `bit` (which is what the driver reports for boolean cols) then get the value using `getByte`. This throws an exception when the underlying column is actually a boolean: 
```
org.postgresql.util.PSQLException: Bad value for type byte : f
```
It works as expected if the column is really `bit`.
Is there anything that can be done on the driver side? Or does this have to remain as is due to backwards compatibility?

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Wed, 07 Nov 2018 13:25:44 +0000

@chris-baynes 

Someone is always on the wrong side of an opinion... I'm loathe to change it permanently but could be convinced to make it configurable.

---

From: "vintop95 (@vintop95)" <[email-masked]>
Date: Wed, 04 Jan 2023 17:49:43 +0000

A framework I'm working on infers the type of a column from a select query with jdbc, and this problem makes it impossible for boolean types to be inferred correctly.

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Thu, 05 Jan 2023 13:56:12 +0000

a PR would be useful here

---

From: "vwassan (@vwassan)" <[email-masked]>
Date: Fri, 12 Sep 2025 20:53:01 +0000

> a PR would be useful here

@davecramer Could you take a look at https://github.com/pgjdbc/pgjdbc/pull/3796?

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Fri, 12 Sep 2025 21:45:43 +0000

already did