Ok, I've set up a complete test case: http://pastebin.com/W08w6Hg6

-----Original Message-----
From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On 
Behalf Of Audrius Kazukauskas
Sent: Tuesday, January 22, 2013 8:18 PM
To: sqlalchemy@googlegroups.com
Subject: Re: [sqlalchemy] Couple of questions about filtering...

On Tue, 2013-01-22 at 19:58:15 +0200, Alexey Vihorev wrote:
> > That's what you want in this case, that this hybrid property would 
> > get a class, because Query works with classes.  Try adding echo=True 
> > to create_engine() to see the actual SQL emitted, it should be 
> > correct.
> 
> No, that's definitely not what I want. My hybrid property relies on a 
> content of an instance to return a value, so it needs that 'self'
> parameter to be an instance.

But the whole idea of hybrid properties and methods is to work on both classes 
and their instances.  Since you're using class in a query, you get a class as 
self argument.  When that query returns a result (an instance of this class), 
the hybrid property will work on that instance as well.

I also recreated your hybrid example and I can't see any problems: the query 
emits correct SQL, and hybrid on returned instance also works.

--
Audrius Kažukauskas
http://neutrino.lt/

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