Re: Possible bug related to primary keys autogeneration

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Andrea Bergia <a(dot)bergia(at)list-group(dot)com>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Possible bug related to primary keys autogeneration
Date: 2016-07-15 14:58:42
Message-ID: CAKFQuwY_imooJ=YEF7RkDdwboQpG2RSSkzXrjm4w-TR208EB5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Fri, Jul 15, 2016 at 10:41 AM, Andrea Bergia <a(dot)bergia(at)list-group(dot)com>
wrote:

> Being consistent with cases is generally good advice, but unfortunately my
> code has to run on multiple databases and it's very hard to control cases
> in all the code.
>
> Besides, it seems to me that the behavior is inconsistent. I can use
> whatever case I want in the INSERT INTO clause:
>
> INSERT INTO Documents (name) VALUES ('abc');
>

​If you were to write that "INSERT INTO Documents (name) VALUES ('abc')
RETURNING ID" you wouldn't have a problem because the server is going to
lowercase everything for you anyway. But as soon as you ask Java to append
the returning clause for you it doesn't choose to apply PostgreSQL's case
normalization rules but instead assumes that the case you provided in the
code is the case that you desire - and adds quotes to enforce that
decision. This is nice when you use quote-required identifiers since you
don't have to go escaping them in Java. Maybe a PostgreSQL JDBC
implementation could do this but I don't see it happening in this driver.

I could see maybe having a driver config to toggle this behavior...the
specifics would be important.

David J.

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andrea Bergia 2016-07-15 15:06:04 Re: Possible bug related to primary keys autogeneration
Previous Message Andrea Bergia 2016-07-15 14:52:05 Re: Possible bug related to primary keys autogeneration