RE: [SQLObject] request for elaboration on code
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Luke O. <lu...@me...> - 2004-02-16 15:45:03
|
> So when I see 'id' I can think 'primary key'?
Yes, 'id' (or whatever field '_idName' is for you) is the PK and the value
SQLObject uses to uniquely identify objects in its cache etc.
> I have specified the table name and primary key of my main table with
> _table and _idName, but I also have a foreign key to a validation table. Do
> I need to specify the primary key of the foreign table? What does that look
> like? Unlike the examples in the docs this is a many-to-one relationship. The
> validation table will not have an associated object.
If it really won't have an SQLObject class for it, then you don't need to do
anything more than include the field that is in the main table as whatever
datatype it is. (foreign_id = IntCol() or similar).
If you do decide to make in an object in order to use it through SQLObject's
interface, it would fit the example of ForeignKey() Column in the main table
class and MultipleJoin('MainTableName') in the validation table class.
> I'm having a hard time getting my head around why SQLOject needs to do a
> select at
> all. I am trying to create an object- i.e. write a row. My data gets written
> to postgres as I expect, then I get this other error complaining about oid's
> not existing.
SQLObject needs to know the ID value for any object, at least so that future
updates and selects can be made (where idName = idValue), and for the
SQLObject cache. So with oids you will still definitely need a way to get any
auto-generated id column values in this method.
- Luke
|