[sqlalchemy] Re: Making it possible to use custom properties in query.filter expressions.

2008-01-03 Thread andresj
It works! :) Now I can do this: model.Resource.query.filter(model.Resource.parent == ... model.Resource.query.filter_by(url='example.com').one()).one() Resource at 'example.com/mypage' Just so people know how to fix this if they have the same problem, here is my mapper code, using SQLAlchemy

[sqlalchemy] Re: Making it possible to use custom properties in query.filter expressions.

2008-01-02 Thread andresj
I just upgraded to 0.4.2, and tried to take advantage of the fix available, but I'm confused. I have this code: mapper(Resource, resources, polymorphic_on=resources.c.type, polymorphic_identity=empty, column_prefix='_', properties={ 'id': resources.c.id, 'url':

[sqlalchemy] Re: Making it possible to use custom properties in query.filter expressions.

2008-01-02 Thread andresj
map_column is shorthand for this: table = Table('sometable', metadata, ... Column('somecolumn', ...) ) mapper(Class, table, properties= { '_somecolumn':table.c.somecolumn, 'somecolumn':synonym('_somecolumn') }) so the argument does not apply to your parent relation

[sqlalchemy] Re: Making it possible to use custom properties in query.filter expressions.

2008-01-02 Thread andresj
in the case of parent, what happens if you just dont use a synonym ? if it works then, there might be some silliness occuring when backrefs get set up. the synonym for relation() is only important if youre really looking for the extra querying attributes on parent. you might also try

[sqlalchemy] Changing the type/class of an object using polymorphic tables in ORM

2007-12-22 Thread andresj
I don't know if I'm too clear, but I'll try to explain it. I'm using a set up similar to the one in http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_inheritance_joined . I want to be able to change the type of an object. For example, in the example in the link above, I want to

[sqlalchemy] Re: Changing the type/class of an object using polymorphic tables in ORM

2007-12-22 Thread andresj
Thanks, I will use the approach you describe here when I get to that point in the development proccess :). So for now, your best bet is to issue the SQL directly to the database for the particular class change you want to do, remove the objects in question from the session using expunge(),

[sqlalchemy] Re: Making it possible to use custom properties in query.filter expressions.

2007-12-22 Thread andresj
On Dec 22, 5:07 pm, Michael Bayer [EMAIL PROTECTED] wrote: a synonym() is used so that your attributes are properly available in filter(). This functionality has been vastly improved in the current SVN trunk which resolves all the issues you outline above, and will be available in release