-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 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