Re: Case-sensitive problem in AS clause?

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Laurent Mazuel" <lmazuel(at)antidot(dot)net>,<pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Case-sensitive problem in AS clause?
Date: 2012-07-16 16:18:45
Message-ID: 5003F8950200002500048F68@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Laurent Mazuel <lmazuel(at)antidot(dot)net> wrote:

> I maybe found a problem with the "isCaseSensitive" method in the
> "ResultSetMetadata" class when using it on a "AS" clause.

> I execute the query with the "AS" clause:
>> test=> Select ('Student' || "ID" ) AS StudentId, "ID", "Name"
>> from "Student" ;

> The StudentId regular identifier becomes studentid

Because a non-quoted identifier is folded to lower case in
PostgreSQL.

> but this kind of transformation is not a problem, since a regular
> identifier is not case sensitive.

Yes it is.

> the "isCaseSensitive" flag is "true". I think it is not correct

It is correct, because it will only match the lowercase name. You
can, of course, generate that by leaving off the quotes. It *is*
case sensitive, but there is folding of unquoted identifier names.

The easiest path is to always use lowercase identifiers. Another
path which is not too unreasonable, especially if you have a
framework which can do it for you, is to automatically quote all
identifiers. Using any uppercase letters in any identifiers and not
being consistent about whether or not you quote things, is sure to
cause trouble.

-Kevin

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Johnston 2012-07-16 16:49:05 Re: Case-sensitive problem in AS clause?
Previous Message dmp 2012-07-16 16:05:29 Re: Case-sensitive problem in AS clause?