Em Qui, 2008-01-10 às 17:13 -0800, jason kirtland escreveu:
> col.default.arg
Yes, exactly this.
another question
How many levels I can inherit classes/tables without get something
wrong?
let me show a simplest sample hierarchy:
resource
/ \
person material
/ \
employee customer
now, I am creating a type column on resource to map persons and
materials, them I am creating another type column on person, to get
mapped the various types of persons.
by this way, I could get a employee instance, just selecting a resource
but something is going wrong, because the column type on resource is not
filled with correct value, and I am getting NOT NULL CONSTRAINT by
insert an employee.
the tables
resource_table = Table(
Column('id',Integer, primary_key=True),
Column('poly', String(31), nullable=False)
)
person_table = Table(
Column('id',Integer, primary_key=True, ForeignKey('resource.id'),
primary_key=True)),
Column('poly', String(31), nullable=False)
)
employee_table = Table(
Column('id',Integer, primary_key=True, ForeignKey('person.id'),
primary_key=True)),
)
the classes
class Resource(object):
pass
class Person(Resource):
pass
class Employee(Person):
pass
mappers
mapper(Resource, resource_table,
polymorphic_on=resource_table.c.poly,
polymorphic_identity='resource'
)
mapper(Person, person_table,
polymorphic_on=person_table.c.poly,
inherits=Resource, polymorphic_identity='person'
)
mapper(Employee employee_table,
inherits=Person, polymorphic_identity='employee',
)
is all, now when I create an instance of Employee and try to save, I get
back an integrity error, that resource.poly cannot be null
any suggestion?
thank's for previous replies.
--
Alexandre da Silva
Analista de Sistemas - Bacharel em Sistemas de Informação (2003-2007)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---