[orm-devel] No such attribute or function 'oid'

Ross J. Reedstrom orm-devel@mailman.tux4web.de
Mon, 13 Jan 2003 08:56:28 -0600


On Mon, Jan 13, 2003 at 02:50:29PM +0100, Diedrich Vorberg wrote:
> Hi Eric,
> 
> >I guess that I can't work with PostgreSQL views as orm objects because 
> >views don't have oid's(?).  It seems orm is reliant on oid (at least for 
> >PostgreSQL).  It might be nice to be able to specify the primary key in 
> >when creating the dbclass subclass and having it us the pk instead of 
> >the oid.  Just a thought.
> Yes, the pgsql adapter uses oids. It will add 'oid,' to any SELECT 
> statement it creates.

Yeah, this was the one thing I was thinking about bringing up, though it's
probably a post-1.0 thing (perhaps not). Oids are now optional on
user tables, and are not guaranteed to be unique, anyway, unless you add
a unique index on the column. So this problem will start to bite lots of
people using regular tables, not just views. My take on it from the orm
point of view is to use a PrimaryKey wherever it is defined, and only fall
back to oid if there is no such key. This gets complicated when the pkey
is compound: more than one column. One answer would be not to support
such tables. 

> Check out this thread on orm-devel:
> 
>    http://mailman.tux4web.de/pipermail/orm-devel/2002-November/000013.html
> 
> which contains a patch to adapters.pgsql.datasource that you might
> find helpfull. 
<snip>
> Take a look at the patch: do you think it should be included with 
> orm? After Mike found a solution he thought satisfactory the patch  
> didn't make it to the distribution...

To be honest, I didn't dig into this patch, since it seemed to me that
the right solution is not to distinguish between table and view, but
rather with and without oids. And views are _always_ readonly: you can
make them writeable with some extra ON INSERT and ON UPDATE rules.

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