That is useful for mapping single or combined columns to an attribute.
Here, I want to map entire objects.

On Nov 10, 10:20 pm, Eric Ongerth <[email protected]> wrote:
> Good point, Sergey.
>
> Here is the relevant documentation regarding mapping attributes to
> selects:http://www.sqlalchemy.org/docs/orm/mapper_config.html?highlight=arbit...
>
> On Nov 10, 4:46 pm, "Sergey V." <[email protected]> wrote:
>
> > > The twist is that I've spread out my tables and ORM classes across
> > > several files. I've tried to keep it so that I don't have circular
> > > dependencies. That means I've defined Merchant first, and then Deal
> > > later, in separate files
>
> > To avoid problems with imports and dependencies you can pass strings
> > to the relationship function instead of the actual classes:
>
> > mapper(Deal, deals, properties=dict(
> >       merchant=relationship('Merchant', backref='deals'),
> >   ))
>
> > This greatly simplifies everything if you split your classes into
> > separate files.
>
> > Regarding 'available_deals', 'deleted_deals' etc. - the approach with
> > properties is sub-optimal. Consider a merchant having thousands of
> > deals, only a few of which are available - the method would have to
> > fetch all those deals only to discard most of them. Also, that won't
> > work with eager loading. The optimal way would be to make SA to
> > generate a query like "SELECT ... FROM Deals WHERE ... AND deleted=1"
> > which would return only the records we're interested in. I'm sure it's
> > possible but I'll leave it to you to find it in SA docs :) When you
> > find it please post it here :)

-- 
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.

Reply via email to