Re: stringtype=unspecified is null check problem - Mailing list pgsql-jdbc
From | David G. Johnston |
---|---|
Subject | Re: stringtype=unspecified is null check problem |
Date | |
Msg-id | CAKFQuwZrn0F9RyM=WL9Z=pioGX5pwH1+mbBe-jGNnjy_J2E+Jw@mail.gmail.com Whole thread Raw |
In response to | AW: stringtype=unspecified is null check problem (Martin Handsteiner <martin.handsteiner@sibvisions.com>) |
Responses |
Re: stringtype=unspecified is null check problem
|
List | pgsql-jdbc |
There are 3 use cases, where I would need one setting, that always ensures, that null can be bound…
(setNull(1, <setting>) and stringtype=<setting>)
select 1 where 1=? -- setNull(1, Types.VARCHAR) and stringtype=unspecified
select 1 where 'A'=? -- setNull(1, Types.VARCHAR) and stringtype doesn’t matter
select 1 where ? is null -- setNull(1, Types.VARCHAR) and stringtype=VARCHAR
That there is no way to binding null in a simple way is a bug for me, because the following will work, and the database has also to decide, how to map null:
select 1 where 1=null -- now the database converts null to a number
select 1 where 'A'=null -- now the database converts null to a varchar
select 1 where null is null – now the database doesn’t care… so everthing works.
The question is, what is the difference between the two, and why should the caller parse the statement, if he uses jdbc. These examples are easy, but in real world, in 1=? the 1 could also be a sub select (select max(id) from …)
pgsql-jdbc by date: