Hello,

I am having trouble getting just the data I need from a query. I have
a one-to-many relationship between two classes Content and Section,
such that one Content has many Sections.

I want to retrieve a (or many) content object and populate on it a
property called section_ids which will be a list ids ([1,2,3,...]) of
the sections for that content

my mappings looks like this

class Section(object):
    pass

class Content(object):
    pass

section_table = Table('section', metadata,
    Column('id', Integer, primary_key=True),
    Column('title', Unicode(length=250)),
    Column('content_id', Integer, ForeignKey('content.id')),
)

content_table = Table('content', metadata,
    Column('id', Integer, primary_key=True),
    Column('title', Unicode(length=250))
)

mapper(Section, section_table)
mapper(Content, content_table, properties={
    'sections' : relation(Section, order_by=section_table.c.order,
backref="content")
})


I have tried using the column_property to no avail, though it feela
like that may be the key to the solution.

Any help much appreciated!!!
Sammy

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to