akarshan2701 / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Wrong column name being returned from ResultSet meta data #172

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1. Apply the patch below to TestResultSet.java
2. Run the tests

What is the expected output? What do you see instead?
I was expecting y for the column name instead of x when running select x as y 
from dual.

What version of the product are you using? On what operating system, file
system, and virtual machine?

H2 1.2.130
Mac OS X
jdk 1.5.0_22

Do you know a workaround?

How important/urgent is the problem for you?

In your view, is this a defect or a feature request?

defect

Please provide any additional information below.

Index: TestResultSet.java
===========================================================
========
--- TestResultSet.java  (revision 2387)
+++ TestResultSet.java  (working copy)
@@ -115,6 +115,13 @@
         rs.next();
         rs.getString("x");
         rs.getString("y");
+   ResultSetMetaData md = rs.getMetaData();
+   int count = md.getColumnCount();
+   assertTrue("Column count was not 1", count == 1);
+
+   String cname = md.getColumnName(count);
+   assertTrue("Column was " + cname + " instead of y", 
cname.equalsIgnoreCase("y"));
+
         rs.close();
         rs = conn.getMetaData().getColumns(null, null, null, null);
         ResultSetMetaData meta = rs.getMetaData();

Original issue reported on code.google.com by shawn.el...@gmail.com on 27 Feb 2010 at 5:18

GoogleCodeExporter commented 8 years ago
Not a bug. See http://www.h2database.com/html/faq.html#column_names_incorrect

Original comment by thomas.t...@gmail.com on 27 Feb 2010 at 5:28