On 7/21/06, Michael Bayer <[EMAIL PROTECTED]
> wrote:
OK well there is one inheritance setup in the unit tests that relies upon a null primary key indicating the row is not valid, and i think that behavior is more general-use. so instead, you get an option:mapper(someclass, someouterjoin, allow_null_pks=True)in rev 1731.this mapper is still not necessarily going to work correctly for inserts/updates (since it doesnt know when you want the outer row inserted and when you dont).On Jul 21, 2006, at 11:32 AM, Jonathan Ellis wrote:Sound like the obvious solution unless it breaks something else...On 7/21/06, Michael Bayer < [EMAIL PROTECTED] > wrote:oh you know what i think someone was asking me a while back if "None" could be considered a valid value within a composite primary key; the fact that the column was *present* would indicate that the primary key is there, but None is an acceptible value. what do you think ? this would appear to require that.On Jul 21, 2006, at 11:06 AM, Jonathan Ellis wrote:That does bring user 9 back, but it breaks user #8's part of the join. (Should be 3 rows since 3 addresses; with user_id PK only one row comes back.)
-J
On 7/21/06, Michael Bayer < [EMAIL PROTECTED] > wrote:without trying it, my instinct is that a join object considers its "primary key" to be the composite of the primary keys of both tables. this means the primary key of "j" below is going to be [ users.user_id, addresses.address_id]. when the mapper loads a row and does not see a complete primary key represented, it assumes it cannot create an entity for the row.so you might want to specify an explicit primary key to the mapper, such as primary_key=[ users.c.user_id] and see if that works.On Jul 20, 2006, at 11:40 PM, Jonathan Ellis wrote:I added the following to test/orm/mapper.py (rev 1730):
def testjoinbyfk(self):
class UserWithAddress(object):
def __repr__(self):
import locale
encoding = locale.getdefaultlocale()[1]
L = []
for k in self.__class__.c.keys():
value = getattr(self, k, '')
if isinstance(value, unicode):
value = value.encode(encoding)
L.append("%s=%r" % (k, value))
return '%s(%s)' % (self.__class__.__name__, ','.join(L))
j = join(users, addresses, isouter=True)
m = mapper(UserWithAddress, j)
q = create_session().query(m)
import sys
sys.stderr.write('%s\n' % list(q.select()))
self.assert_(len(list(q.select())) == 5)
Only four rows come back... the user with no corresponding addresses (#9) doesn't appear even though an outer join was specified.
--
Jonathan Ellis
http://spyced.blogspot.com-------------------------------------------------------------------------Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT & business topics through brief surveys -- and earn cashSqlalchemy-users mailing list
--
Jonathan Ellis
http://spyced.blogspot.com-------------------------------------------------------------------------Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT & business topics through brief surveys -- and earn cashSqlalchemy-users mailing list
--
Jonathan Ellis
http://spyced.blogspot.com-------------------------------------------------------------------------Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT & business topics through brief surveys -- and earn cashSqlalchemy-users mailing list
--
Jonathan Ellis
http://spyced.blogspot.com
------------------------------------------------------------------------- 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 Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users