pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurent Mazuel <lmazuel@antidot.net>
To: pgsql-jdbc@postgresql.org
Subject: Case-sensitive problem in AS clause?
Date: Mon, 16 Jul 2012 16:15:54 +0200
Message-ID: <5004221A.4030508@antidot.net> (raw)

Dear all,

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

With the following test DB:
> test=> CREATE TABLE "Student" ("ID" INTEGER,"Name" VARCHAR(15));
> CREATE TABLE
> test=> INSERT INTO "Student" ("ID", "Name") VALUES(10,'Venus');
> INSERT 0 1
I execute the query with the "AS" clause:
> test=> Select ('Student' || "ID" ) AS StudentId, "ID", "Name" from 
> "Student" ;
>  studentid | ID | Name
> -----------+----+-------
>  Student10 | 10 | Venus
> (1 ligne)

The StudentId regular identifier becomes studentid, but this kind of 
transformation is not a problem, since a regular identifier is not case 
sensitive.

The problem is where I execute my query in JDBC:
>     @Test
>     public void testAsCaseSensitive() throws Exception {
>     Connection conn = 
> DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test","root","root");
>     java.sql.Statement s = conn.createStatement(
>         ResultSet.HOLD_CURSORS_OVER_COMMIT, ResultSet.CONCUR_READ_ONLY);
>     s.executeQuery("Select ('Student' || \"ID\" ) AS StudentId from 
> \"Student\";");
>     ResultSet rs = s.getResultSet();
>     ResultSetMetaData metaData = rs.getMetaData();
>     int n = metaData.getColumnCount();
>     for (int i = 1; i <= n; i++) {
>         System.out.println("Column: "+metaData.getColumnLabel(i)+" 
> "+metaData.isCaseSensitive(i));
>     }
>     }
I obtain the output:
> Column: studentid true

Then, the column name is changed from StudentId to studentid, but the 
"isCaseSensitive" flag is "true". I think it is not correct, since it is 
impossible from now, when a user ask for the StudentId column to 
retrieve it from a resultset. The "isCaseSensitive" don't authorize to 
accept the string StudentId as a valid column name for the studentid 
column in the ResultSet.

This on: psql (PostgreSQL) 9.1.4 (debian-squeeze backport packages), 
with Maven dependency on JDBC plugin:
> <dependency>
> <groupId>postgresql</groupId>
> <artifactId>postgresql</artifactId>
> <version>9.1-901.jdbc4</version>
> </dependency>


I hope that I don't have miss something and I don't bother you....

Best regards,

Laurent Mazuel

-- 
Laurent Mazuel (lmazuel@antidot.net)
Ingénieur R&D, Web Sémantique
Antidot - Solutions de recherche d'information
29 avenue Jean Monnet, 13410 LAMBESC (FRANCE)
Tel: (33) 4 42 63 67 90 / Fax: (33) 4 42 28 61 03





view thread (9+ messages)  latest in thread

Message-ID: <5004221A.4030508@antidot.net>
Permalink:  ../5004221A.4030508@antidot.net/
Also on:    postgresql.org/message-id/5004221A.4030508@antidot.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: lmazuel@antidot.net
  Subject: Re: Case-sensitive problem in AS clause?
  In-Reply-To: <5004221A.4030508@antidot.net>
  References: <5004221A.4030508@antidot.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox