Message-ID: From: "victornoel (@victornoel)" To: "pgjdbc/pgjdbc" Date: Wed, 22 Oct 2025 08:57:33 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3845: Wrong result on equality between Date and Timestamp given as query parameter In-Reply-To: References: List-Id: X-GitHub-Author-Login: victornoel X-GitHub-Comment-Id: 3431203957 X-GitHub-Comment-Type: issue_comment X-GitHub-Edited-At: 2025-10-22T08:58:03Z X-GitHub-Issue: 3845 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3845#issuecomment-3431203957 Content-Type: text/plain; charset=utf-8 @vlsi > What do you mean by "properly"? I guess I mean that when you look at the implementation of `PgPreparedStatement#setDate(int, java.sql.Date, java.util.Calendar)` or `PgPreparedStatement#setTimestamp(int, java.sql.Timestamp, java.util.Calendar)`, you can see it's using `Oid.UNSPECIFIED` most of the time to propagate the type to the server. I just discovered this, I didn't know it when I wrote my first comment but I was intuiting this kind of thing. > Frankly, I would suggest to use java.time types instead of java.sql types. So you mean one should be doing `setObject(LocalDate.of(2013, 03, 21))` instead of `setDate(java.sql.Date.valueOf(LocalDate.of(2013, 03, 21)))` right? It's indeed a good workaround right now, it's unfortunately not followed by libs like Hibernate that will directly use `setTimestamp()` or `setDate()` but I guess it's also workaroundable. > Is there a reason you have to use java.sql types without casts? Is there a reason that we should be using casts? I mean: the only workaround currently is to do use casts, so that's what is going to be done, but we thought there was maybe something wrong going on a the driver level and decided to start a discussion here about it.