Case-sensitive problem in AS clause?
От | Laurent Mazuel |
---|---|
Тема | Case-sensitive problem in AS clause? |
Дата | |
Msg-id | 5004221A.4030508@antidot.net обсуждение исходный текст |
Ответы |
Re: Case-sensitive problem in AS clause?
(dmp <danap@ttc-cmc.net>)
Re: Case-sensitive problem in AS clause? ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>) |
Список | pgsql-jdbc |
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
В списке pgsql-jdbc по дате отправления: