Hi everyone, I am trying to get access to attributes which are hidden by a join:
I have two tables
intervals_table = Table("intervals", metadata,
Column("interval_id", Integer, primary_key=True),
Column("sentence_id", Integer,
ForeignKey("sentences.sentence_id")),
Column("start", Integer, nullable=False),
Column("end", Integer, nullable=False),
Column("deleted", Integer(1), default=0))
entities_table = Table("entities", metadata,
Column("entity_id", Integer, primary_key=True),
Column("interval_id", Integer,
ForeignKey("intervals.interval_id")),
Column("type", String(20), nullable=False),
Column("deleted", Integer(1), default=0),
)
and I have two classes:
class Interval(object):
pass
class Entity(object):
pass
which are mapped to these tables:
mapper(Interval, intervals_table)
mapper(Entity, entities_table.join(intervals_table,
intervals_table.c.interval_id == entities_table.c.interval_id))
this leaves Entity with one deleted attribute (the one in the
entities_table....sensible)...but I would like to make it so I could
access the interval.deleted in the interval_table. Is there an easy
way to allow this?
If I then wanted to extend this so the Interval class has a derived
attribute deleted ( the or of interval.deleted and entity.deleted ) is
this possible to do aswell?
Many thanks in advance
Nathan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---