[orm-devel] select problem

Diedrich Vorberg orm-devel@mailman.tux4web.de
Sat, 1 Mar 2003 12:32:39 +0100


Hi Werner,

>- Column names in the db are in capital letters.
>- Column names in the class definition are in lower case
this is odd: as I remember SQL requires case*in*sensitivity. But I 
don't know for sure to be honest.

>I see in the code that there is a column name and an attribute name - 
>does this mean I can define column name as "WINENAME" and attribute as 
>"winename" to solve this problem?  
Yes, that's the way to go.

>If yes, can you give me a sample class definition to do this, so I can 
>update fbgen.

class test(dbclass):
    columns = { "id": gen(),
                "winename": varchar(columnName="WINENAME") }

orm.columns.varchar is an alias for orm.columns._string which is a 
descendant of datatype so it inherits datatype's __init__. That's 
where the columnName argument is defined (ref: orm/columns.py:269).

>If no, what do you suggest to get over this (using lower case in db does 
>not work, as somewhere along the line they get converted to upper).

If upper case columns names are a rule of the RDBMs it should be put
into the adapter's datasource module. The datasource_base class has a
method selectColumns() which returns a string as "col1, col2, col3"
for any SQL SELECT query generated by orm. The firebird datasource
should probably overload it like this:

    def selectColumns(self, dbclass):
        """
        Firebird expects columns names to be upper case in general.
        """
        return string.upper(datasource_base.dbclass.selectColumns(self))

As a sidenote: That's the same method that's adding the infamous
"oid," to the pgsql's adapter's SELECT queries.

>BTW - just noticed, looking for doc on the class def format,  the spell 
>error on the web page - Sing up .... mailinglist  should be "Sign up".
Fixed. Thanks!

Diedrich

-- 
           _..._                            Diedrich Vorberg
         .'     '.
        /  _   _  \                         http://www.tux4web.de
        | (o)_(o) |                         info@tux4web.de
         \(     ) /            .---.
         //'._.'\ \           /     \       Internet Dienstleistungen
        //   .   \ \          \.@-@./       und 'Consulting'.
       ||   .     \ \         /`\_/`\
       |\   :     / |        //  _  \\      Linux Rules!
       \ `) '   (`  /_      | \     )|_
     _)``".____,.'"` (_    /`\_`>  <_/ \
     )     )'--'(     (    \__/'---'\__/
      '---`      `---`