[orm-devel] Re: Postgres & Views

Diedrich Vorberg diedrich@tux4web.de
Fri, 22 Nov 2002 12:53:41 +0100


Hi Julio,

nice to hear your voice on the list!

>This solution works with view over a single table. But what about a join
>query?

>  ...

>This view class should create the sql query that join both tables and handle
>the one to many realitons as a list.

I didn't test any of this for lack of time, just an idea.

Inheritance of dbclasses doesn't work, really. The columns attribute
of one class simply gets overwriten by the other. What you'd have to
do is

class person(dbclass):
  ...

class address(dbclass):
  ...

class person_adress(viewclass, person, address):
      columns = person.columns.copy() # copy() is essential!
      column.update(address.columns)  # This will overwrite any column in
                                      # person wich has the same name 
                                      # as a column in address 

Actually I'm not sure if this is going to work at all. I don't know
how the description tuple of the result will look like and orm depends
on this to map result data to dbobj attributes. Also I columns that
have the same name in both tables are not accounted for, I guess. 
However, relationships defined in one of the baseclasses should work 
as expected just like the other columns (if they do).

Diedrich

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