[Zope-dev] dupe column names not supported (Shared.DC.ZRDB) ?

Ross J. Reedstrom reedstrm@rice.edu
Tue, 17 Dec 2002 13:40:50 -0600


On Tue, Dec 17, 2002 at 02:25:27PM -0500, Casey Duncan wrote:
> The semantics of Zope's database functionality is such that duplicate column 
> names are not (and probably never will be) possible in the same result set. 
> This is because Zope expects to access columns by name rather than position. 
> Therefore each one must have a distinct name. 

Oh, I understand the problem: just reporting that PostgreSQL isn't the
only one doing it.

> The only workaround I can see would be some sort of automatic renaming of 
> columns, but that sounds like a bad idea since it introduces some serious bug 
> potential if the columns are renamed differently then the application 
> expects.

Yeah, that'd suck.

> Just for curiousity, what is the use case for returning multiple columns with 
> the same name? Sounds dubious to me.

I'm not aware of a use case, per se. It comes about from implementing this 
bit of the SQL92 standard:


            7.9.9.b) If the i-th <derived column> in the <select list>
                 does not specify an <as clause> and the <value
                 expression> of that <derived column> is a single <column
                 reference>, then the <column name> of the i-th column
                 of the result is C.

Note that that says 'C', not 'CR'. i.e. is _must_ be the undecorated 
column name, not the column reference (schema.table.column)

The next subclause (7.9.9.c) handles the case of it not being a single
column reference (like a function, or somthing), and says it's then
'implementation dependent' and only needs to be unique in the set of
tables referenced by the SQL. It's not clear whether that's supposed
to include the 'derived table' that is the output of this 'query
specification'.

Ross
-- 
Ross Reedstrom, Ph.D.                                 reedstrm@rice.edu
Research Scientist                                  phone: 713-348-6166
The Connexions Project      http://cnx./rice.edu      fax: 713-348-6182
Rice University MS-39
Houston, TX 77005