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

2002-12-17 Thread Casey Duncan
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. 

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.

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

-Casey

On Tuesday 17 December 2002 02:11 pm, Ross J. Reedstrom wrote:
 Same problem has been reported with Oracle 8.1, since it too will return
 duplicate names. The SQL92 spec is a bit ambiguous about whether all
 returned column names must be unique.
 
 Ross
 
 On Tue, Dec 17, 2002 at 01:09:13PM -0500, Adam Manock wrote:
  
  specifically with:
  
  SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high,
  W2.city, W2.temp_lo AS low, W2.temp_hi AS high
  FROM weather W1, weather W2
  WHERE W1.temp_lo  W2.temp_lo
  AND W1.temp_hi  W2.temp_hi;
  
  
  Error, exceptions.ValueError: Duplicate column name, city
  
  Traceback (innermost last):
Module ZPublisher.Publish, line 98, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module Shared.DC.ZRDB.Connection, line 115, in manage_test
Module Shared.DC.ZRDB.Results, line 52, in __init__
  ValueError: Duplicate column name, city


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



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

2002-12-17 Thread Ross J. Reedstrom
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. [EMAIL PROTECTED]
Research Scientist  phone: 713-348-6166
The Connexions Project  http://cnx./rice.edu  fax: 713-348-6182
Rice University MS-39
Houston, TX 77005

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



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

2002-12-17 Thread Adam Manock
 Just for curiousity, what is the use case for returning multiple columns with 
 the same name? Sounds dubious to me.

A self join will return multiple columns with the same name unless AS
keyword is used. The use of AS keyword is supposed to be optional.
Assuming that a user does use AS, labeling of the returned columns will
be at the discretion of the user, and therefore again not guaranteed to
be unique.

I would guess that if Zope assumes that column names are unique,
changing that assumption now would be a major p.i.t.a. :-)

Adam


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )