[sqlalchemy] Relationship id not set automatically?

2013-11-06 Thread Victor Varvariuc
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=10002, first_name=u'Testfirstname10002', last_name=u'Testlastname10002',

[sqlalchemy] Re: Relationship id not set automatically?

2013-11-06 Thread Victor Varvariuc
If I merge `subscription` object into a session, `subscription.customer` is not accessible while `subscription.customer_id` is set: ipdb subscription.__dict__ {'domain': u'ru', 'utm_content': None, 'updated_at': datetime.datetime(2013, 11, 6, 16, 45, 2, 85355), 'confirm_code':

Re: [sqlalchemy] Relationship id not set automatically?

2013-11-06 Thread Victor Varvariuc
Yes, you right! Thank you! -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to

[sqlalchemy] colum with server_default does not have new value after session.merge

2013-10-17 Thread Victor Varvariuc
I have a model: class ExchangeRate(Base): ... created_at = Column(DateTime, nullable=False, server_default=func.now()) updated_at = Column(DateTime, nullable=False, server_default=func.now(), server_onupdate=func.now()) Model fields `created_at` and

[sqlalchemy] Re: colum with server_default does not have new value after session.merge

2013-10-17 Thread Victor Varvariuc
Not sure if this matters, but the model doesn't have an autoincrement primary key: class ExchangeRate(Base): currency_from = Column(CURRENCY_ISO_CODE_TYPE, primary_key=True) currency_to = Column(CURRENCY_ISO_CODE_TYPE, primary_key=True) ... created_at = Column(DateTime,

Re: [sqlalchemy] colum with server_default does not have new value after session.merge

2013-10-17 Thread Victor Varvariuc
I am using sqla 0.8 On Oct 17, 2013 8:46 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 17, 2013, at 10:34 AM, Victor Varvariuc victor.varvar...@gmail.com wrote: Ok, so the answer is to use 'eager_defaults': True : class CommonBase(object): Base model for Apilib db-mapped

[sqlalchemy] Enclose each test in a transaction

2013-06-07 Thread Victor Varvariuc
Hi! I am trying to make a base class for our tests, that after each test case all the changes made by tests and the tested code are rolled back. I saw the pattern here http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#joining-a-session-into-an-external-transaction, but i have some