hmmm, im not seeing that behavior. when I do it like this: p = Person() p.key = 'default' pr = Prefs() pr.email = '[EMAIL PROTECTED]' p.Prefs = pr objectstore.flush()
objectstore.clear()
p = Person.mapper.get('default')
print p.key
print p.Prefs.person
i get these queries (sqlite):
INSERT INTO people (key, firstname, lastname) VALUES (?, ?, ?)
['default', None, None]
INSERT INTO prefs (person, email) VALUES (?, ?)
['default', '[EMAIL PROTECTED]']
SELECT people.lastname AS people_lastname, people.firstname AS
people_firstname, people.key AS people_key
FROM people
WHERE people.key = ? ORDER BY people.lastname
SELECT prefs.person AS prefs_person, prefs.email AS prefs_email
FROM prefs
WHERE prefs.person = ?
[u'default']
test program is attached. see if you can modify it to illustrate the
problem youre having (also make sure youre on the trunk/0.1.6).
Dimi Shahbaz wrote:
>
> I'm having trouble with inheritance. I think I've followed the
> examples/polymorph2.py paradigm, but I'm still getting issues. Here
> is my boiled-down test case:
>
> people = Table("people", pg_engine,
> Column('key', String, primary_key=True),
> Column('firstname', String),
> Column('lastname', String),
> )
>
> bornpeople = Table("bornpeople", pg_engine,
> Column('person', String, ForeignKey("people.key"),
> primary_key=True, ),
> Column('birthdate', DateTime, nullable=False),
> )
>
> prefs = Table("prefs", pg_engine,
> Column('person', String, primary_key=True),
> Column('email', String),
> )
>
> class Prefs(object):
> pass
>
> class Person(object):
> pass
>
> class BornPerson(Person):
> pass
>
> Prefs.mapper = mapper(Prefs, prefs)
>
> Person.mapper = mapper(Person, people, order_by=people.c.lastname,
> properties = {
> 'Prefs' : relation(Prefs.mapper, uselist=False,
> primaryjoin=prefs.c.person==people.c.key,
> foreignkey=prefs.c.person),
> },
> )
>
> BornPerson.mapper = mapper(BornPerson, bornpeople,
> inherits=Person.mapper,
> )
>
>
>
>
> Notice that BornPerson derives from Person, and I've used
> inherits=Person.mapper in BornPerson.mapper. When I run the following:
>
>
> p = Person.mapper.get('default')
> print p.key
> print p.Prefs.person
>
> with Echo on, I get the following select statements:
>
> [engine]: SELECT people.lastname AS people_lastname, people.firstname
> AS people_firstname, people.key AS people_key
> FROM people
> WHERE people.key = %(pk_key)s ORDER BY people.lastname
> [2006-04-12 17:05:35,157] [engine]: {'pk_key': 'default'}
> default
> [2006-04-12 17:05:35,164] [engine]: SELECT prefs.person AS
> prefs_person, prefs.email AS prefs_email
> FROM prefs, people
> WHERE prefs.person = people.key
> [2006-04-12 17:05:35,165] [engine]: {}
> manager
>
>
>
> Notice the second select statement is missing a "WHERE prefs.person =
> 'default'". If I change BornPeople to derive from 'object' instead:
>
> class BornPerson(object):
> pass
>
> I get the correct select statements:
>
> [2006-04-12 17:07:31,243] [engine]: SELECT people.lastname AS
> people_lastname, people.firstname AS people_firstname, people.key AS
> people_key
> FROM people
> WHERE people.key = %(pk_key)s ORDER BY people.lastname
> [2006-04-12 17:07:31,243] [engine]: {'pk_key': 'default'}
> default
> [2006-04-12 17:07:31,251] [engine]: SELECT prefs.person AS
> prefs_person, prefs.email AS prefs_email
> FROM prefs
> WHERE prefs.person = %(pk_person)s
> [2006-04-12 17:07:31,251] [engine]: {'pk_person': 'default'}
>
>
>
> My inheritance structure or procedure is flawed somewhere, but I'm
> not sure where. Do I need MapperExtension to accomplish what I'm
> trying to do? Any clues?
>
> TIA,
>
> --
> Dimi Shahbaz, Software Engineer Specialist
> California PASS Program
> www.cyberhigh.fcoe.k12.ca.us
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>
test.py
Description: Binary data

