On Jan 23, 2008, at 3:28 PM, MattQc wrote:
> > Object query returns an empty set: > > In <3>: jLane = tblspotbandsol.outerjoin(tbllane, > tbllane.c.laneid==tblspotbandsol.c.laneid) > In <4>: mapper(LaneClass,jLane) > Out<4>: <sqlalchemy.orm.mapper.Mapper object at 0xb36f382c> > In <5>: > Session.query(LaneClass).filter(LaneClass.spotbandsolid==32978).all() in this case the mapper will attept to compute the "natural" primary key amongst all the columns that are being mapped; by default, it will be the primary key columns of "tblspotbandsol" combined with that of "tbllane". If a row does not contain non-null columns for all primary key columns, no instance will be returned. You can see this happening if you turn on sqlalchemy.orm.mapper=DEBUG logging. The three ways to modify this behavior are to specify "allow_null_pks=True" on the mapper so that a primary key with some NULL columns is accepted as a valid primary key, to specify the "primary_key=[<some columns>]" option to the mapper which indicates which columns should be counted as part of the primary key and overriding the auto-calculation of such, or to remove the primary key columns of "tbllane" from the columns clause of the selectable which you are mapping to which has a similar effect to providing an explicit primary key argument. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---