[sqlalchemy] Re: column 'title' used in key specification without a key length
On Mar 1, 2008, at 11:36 AM, Victor Lin wrote: It says that I should set the length of key of title. I know I can solve this problem by setting the length of key. But the problem is : How to set the length for key? I can't find method to do so in document. try using : from sqlalchemy.databases.mysql import MSText MSText(length=somelength) since length is not standard for the Text type. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] new joined-table polymorphic helpers available in trunk
hey alchemers - I want to direct your attention to some new features in trunk which I'll also be demonstrating at this years Advanced SQLAlchemy tutorial. these features apply primarily to joined-table inheritance scenarios, and are in response to the need to specify criterion against subclasses as well as to join to/from joined-table classes where a specific subclass is required. I've put some new docs at http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_inheritance_joined_querying . the two methods are with_polymorphic() and of_type(). with_polymorphic() may very well replace the need for select_table in almost all cases, and it creates the joins for you. It allows filtering criterion to be against subclasses, *and* allows the mapper to load the full subclass instance without the need for a second query against the joined table. Assume the usual Person / Engineer(Person) / Manager(Person) example : # query for Person objects, but specify criterion against Engineer session .query (Person ).with_polymorphic(Engineer).filter(Engineer.engineer_name=='dilbert') # query for Person objects but specify criterion against both Manager and Engineer session.query(Person).with_polymorphic([Engineer, Manager]).filter(or_(Engineer.engineer_name=='dilbert', Manager.manager_name=='dogbert')) # eagerly load all joined-table subclasses session.query(Person).with_polymorphic('*').filter(...filter on any table..).all() of_type() is an operator applied to relations and is useful for joining, as well as the any() and has() operators. Assume Company objects contain a collection called employees' which contains Person objects: # join from Company to Engineer along its employees relation session .query (Company ).join (Company .employees.of_type(Engineer)).filter(Engineer.engineer_name=='dilbert') # query for Company objects where dilbert works session .query (Company ).join (Company .employees.of_type(Engineer).any(Engineer.engineer_name=='dilbert')) So once again, all of these methods are designed to work with joined- table inheritance. For concrete inheritance, we still arent generating those UNIONs automatically, though you can use with_polymorphic() if you send along a second argument which is a selectable to pull rows from. If folks want to get on trunk and test out these features, that would be great. - mike --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: new joined-table polymorphic helpers available in trunk
I want to direct your attention to some new features in trunk which I'll also be demonstrating at this years Advanced SQLAlchemy tutorial. these features apply primarily to joined-table inheritance scenarios, and are in response to the need to specify criterion against subclasses as well as to join to/from joined-table classes where a specific subclass is required. I've put some new docs at http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mappe r_inheritance_joined_querying . the two methods are with_polymorphic() and of_type(). with_polymorphic() may very well replace the need for select_table in almost all cases, and it creates the joins for you. It allows filtering criterion to be against subclasses, *and* allows the mapper to load the full subclass instance without the need for a second query against the joined table. Assume the usual Person / Engineer(Person) / Manager(Person) example : # query for Person objects, but specify criterion against Engineer session .query (Person ).with_polymorphic(Engineer).filter(Engineer.engineer_name=='dilber t') # query for Person objects but specify criterion against both Manager and Engineer session.query(Person).with_polymorphic([Engineer, Manager]).filter(or_(Engineer.engineer_name=='dilbert', Manager.manager_name=='dogbert')) # eagerly load all joined-table subclasses session.query(Person).with_polymorphic('*').filter(...filter on any table..).all() let me see if i got it... does this mean that, in the a-b-c-.. mapper hierarchy i do not have anymore to use the selecttable= a.outerjoin(b) (and eventualy .outerjoin(c) etc) on each level, but instead use only one mapper (a) for everything, just having different query.with_poly(x) for each subclass x? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---