Hi,

I'm OK to change it, but I would like to better understand why the current
behavior is a problem. Does anything fail badly because of it? Depending on
the reason, it makes sense to change it earlier (in the next minor release
for example), in the next major release, or a combination (add a feature
toggle in the next minor release, and change the default in the next major
release).

The Java 6 and 7 Javadocs are very clear what the expected behavior should
be, however Java 5 is quite fuzzy:
http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/ResultSet.html#findColumn(java.lang.String)"Maps
the given ResultSet column name to its ResultSet column index."

According to my test, H2 works in the same way as HSQLDB. PostgreSQL,
MySQL, and Apache Derby fail with a SQLException (column "id" not found); I
didn't test other databases so far. So changing the behavior would result
in an incompatibility with HSQLDB, but that's not such a big problem,
because compatibility with PostgreSQL and MySQL are much more important.
Compatibility with old version of H2 is quite important as well however.

Regards,
Thomas






On Fri, May 10, 2013 at 7:05 PM, Christian Bauer <[email protected]
> wrote:

> Version: 1.3.171
>
> select ID as ITEM_ID from ITEM
>
> ResultSetMetaData#getColumnName(1) returns "ID"
> ResultSetMetaData#getColumnLabel(1) returns "ITEM_ID"
>
> This is correct. However, I should not be able to use the name for lookup
> on the ResultSet, only the label:
>
> ResultSet#findColumn("ID") returns 1
> ResultSet#findColumn("ITEM_ID") returns 1
>
> The first findColumn() should fail with an SQLException, the Javadoc for
> the method is: "Maps the given ResultSet column label to its ResultSet
> column index."
>
> The argument of the method is "the label for the column specified with the
> SQL AS clause. If the SQL AS clause was not specified, then the label is
> the name of the column".
>
> This also affects all get*() operations on the ResultSet.
>
> It looks like H2 falls back and searches for the column name when the
> label can't be found. I think it should throw an exception, as per Javadoc
> "if the ResultSet object does not contain a column labeled columnLabel".
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/h2-database?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to