How can this be? Is this the intended behavior?
ipdb> customer = factory.new_customer(_with_id=True)
ipdb> with Session() as session: customer = session.merge(customer)
ipdb> customer
Customer(id=100000002, first_name=u'Testfirstname100000002',
last_name=u'Testlastname100000002', middle_name=u'Testmiddlename100000002',
email='[email protected]', password='qDV6Za', gender='M',
phone='00100000002', is_active=True, is_deleted=False)
ipdb> subscription = factory.new_subscription(_with_id=True)
ipdb> subscription
Subscription(id=100000001, email='[email protected]',
status='UNSUBSCRIBED', sms_status='UNSUBSCRIBED',
confirm_code='jFw3blG7UD3BdCIPqZ9VacCBEno8NtOOYhfLXef3QvmIQyfvC3',
gender=None)
ipdb> subscription.customer = customer
ipdb> subscription.customer
Customer(id=100000002, first_name=u'Testfirstname100000002',
last_name=u'Testlastname100000002', middle_name=u'Testmiddlename100000002',
email='[email protected]', password='qDV6Za', gender='M',
phone='00100000002', is_active=True, is_deleted=False)
ipdb> subscription.customer_id
`customer` object was committed to the database, it has an id. Why
`subscription.customer` is set, but `subscription.customer_id` is not?
Using SQLAlchemy 0.8.3
class Customer(Base):
id = Column(BigInteger, primary_key=True, autoincrement=False)
...
class Subscription(Base):
id = Column(BigInteger, primary_key=True, autoincrement=False)
customer_id = Column(Integer, ForeignKey(Customer.id,
ondelete='CASCADE'))
customer = relationship(Customer, lazy='joined')
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.