heres something in rev 1718 you can try:
from sqlalchemy import synonym
mapper(PropertyClass, table,
properties = {
'_hash': table.c.hash,
'hash':synonym('_hash')
},
)
results = session.query(PropertyClass).select_by(hash="a b")
im a little antsy on this feature since its a whole new
MapperProperty which is literally used only by the select_by and
get_by functions...but it seems to be the clearest way to do it.
maybe synonym() will have other uses i havent realized yet.
On Jul 17, 2006, at 9:24 PM, Jamie Wilkinson wrote:
> This one time, at band camp, Michael Bayer wrote:
>> "_hash" is the name of the property now. query like this:
>>
>> results = session.query(PropertyClass).select_by(_hash="a b")
>
> Oh, I see! That's a bit... well it feels dirty because now the
> application using the model needs to know a bit more about the
> internals,
> and there's now two names for that attribute (and I suppose it
> means that
> one can actually set the _hash attribute whilst the hash one is
> protected by
> the setter function on the property).
>
> But I can cope with that in the meantime.
>
>> there are some things we can look into for this, such as "hash" as a
>> synonym for "_hash", or an alternate style of attaching properties,
>> although the way it is now is the most direct and straightforward.
>
> Well, I'd have thought that the Mapper would be able to work out
> that a
> property in a class mapped to the table column; originally I
> thought that it
> was just due to object properties were not treated the same as class
> variables when the mapper did the introspection on the class.
>
> ----------------------------------------------------------------------
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
> share your
> opinions on IT & business topics through brief surveys -- and earn
> cash
> http://www.techsay.com/default.php?
> page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users