From: Kris Jurka <books@ejurka.com>
To: Mike Martin <mmartin@vieo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Wrong column names in ResultSetMetaData
Date: Wed, 28 Jul 2004 22:20:46 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0407282213330.155@leary.csoft.net> (raw)
In-Reply-To: <ce9jk0$15mb$1@news.hub.org>
References: <ce9dna$pne$1@news.hub.org>
<ce9jk0$15mb$1@news.hub.org>
On Wed, 28 Jul 2004, Mike Martin wrote:
> I wrote:
> > [new driver returns a column alias as the label, not name]
>
> I'm almost certain this is wrong from a JDBC standpoint.
>
> rsmd.getColumnName() is supposed to return the given name of
> the *result* column, which SQL has rules to define.
> rsmd.getColumnLabel() is "for use in printouts and displays"
> and will often equate to the column name unless the DBMS has
> some "prettier" column title for display purposes.
>
> For programmatic purposes the column name concept is pretty
> well defined by the docs on ResultSet. They're supposed to
> behave such that:
>
> String colname = rsmd.getColumnName(col);
> return rs.getXXX(colname);
>
> is equivalent to:
>
> return rs.getXXX(col);
>
I am not sure I see where it states that. Your logic makes some sense,
but I don't see anywhere it says the above explicity. The problem is how
to return both pieces of information (the alias and the underlying column
name) within the JDBC API. Certainly the alias makes more sense as the
label when you have to pick between the two of them.
Would you expect the results of getTableName() to return the underlying
table or the table's alias in the query? To be consistent with your
argument you'd have to claim the alias name which is useless here.
Further code doesn't make a whole lot of sense doing:
rs.getString(rsmd.getColumnName(1));
Why wouldn't it just do:
rs.getString(1);
Kris Jurka
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: books@ejurka.com, mmartin@vieo.com
Subject: Re: Wrong column names in ResultSetMetaData
In-Reply-To: <Pine.BSO.4.56.0407282213330.155@leary.csoft.net>
References: <ce9dna$pne$1@news.hub.org> <ce9jk0$15mb$1@news.hub.org> <Pine.BSO.4.56.0407282213330.155@leary.csoft.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