See this script, running 0.6.0: ================================================== from sqlalchemy import * from sqlalchemy.orm import *
engine = create_engine('oracle://user:passw...@localhost:1521/xe? use_ansi=False',echo=True) metadata = MetaData() Session = sessionmaker(bind=engine) session = Session() order_table = Table("orders", metadata, Column("orderid", Unicode, primary_key=True) ) orderdetail_table = Table("orderdetails",metadata, Column("orderid", Unicode, ForeignKey('orders.orderid'), primary_key=True), Column("lineid", Integer, primary_key=True), Column("saleprice", Numeric, nullable=False) ) class Order(object): pass class OrderDetail(object): pass order_mapper = mapper(Order, order_table, properties=dict(orderdetails=relation(OrderDetail, cascade='all,delete-orphan', single_parent=True, lazy=False, backref=backref('parentorder', cascade='refresh-expire,expunge')))) orderdetail_mapper = mapper(OrderDetail, orderdetail_table, allow_partial_pks=False) o=Order() o.orderid = u'SALE000' # not in database line=OrderDetail() line.lineid = 1 # not in database o.orderdetails = [line] merged=session.merge(o) merged.orderdetails[0].saleprice # <---- referencing this, with allow_partial_pks=False should not go to database ================================================== Following is the pasted output, starting with merge(): ---------------------------------------------------------------------------- >>> merged=session.merge(o) 2010-05-06 09:44:49,648 INFO sqlalchemy.engine.base.Engine.0x...5790 SELECT USER FROM DUAL 2010-05-06 09:44:49,652 INFO sqlalchemy.engine.base.Engine.0x...5790 {} 2010-05-06 09:44:49,656 INFO sqlalchemy.engine.base.Engine.0x...5790 BEGIN 2010-05-06 09:44:49,657 INFO sqlalchemy.engine.base.Engine.0x...5790 SELECT orders.orderid AS orders_orderid, orderdetails_1.orderid AS orderdetails_1_orderid, orderdetails_1.lineid AS orderdetails_1_lineid, orderdetails_1.saleprice AS orderdetails_1_saleprice FROM orders, orderdetails orderdetails_1 WHERE orders.orderid = :param_1 AND orders.orderid = orderdetails_1.orderid(+) 2010-05-06 09:44:49,657 INFO sqlalchemy.engine.base.Engine.0x...5790 {'param_1': u'SALE000'} >>> >>> merged.orderdetails[0].saleprice # <---- referencing this, with >>> allow_partial_pks=False should not go to database 2010-05-06 09:44:49,664 INFO sqlalchemy.engine.base.Engine.0x...5790 SELECT orderdetails.saleprice AS orderdetails_saleprice FROM orderdetails WHERE orderdetails.orderid IS NULL AND orderdetails.lineid = :param_1 2010-05-06 09:44:49,664 INFO sqlalchemy.engine.base.Engine.0x...5790 {'param_1': 1} >>> ---------------------------------------------------------------------------- I think this is related to the ticket 1789 in that saleprice shouldn't have been expired on a pending instance anyway. However, I wanted to report this because it seems to me there is *also* potentially something broken with "allow_partial_pks=False" in that, regardless of the expired status, I would have expected the query to not be issued with a pk that is partially None. Thanks in advance. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.