On Sep 21, 2010, at 11:51 PM, Michael Hipp wrote:
On 9/21/2010 8:17 PM, Michael Bayer wrote:
It definitely does not attempt an INSERT if id_ is set to a non-None value,
assuming that row already exists in the DB, without something else in your
model/usage causing that to happen.If id_
On 9/22/2010 10:27 AM, Michael Bayer wrote:
Michael, thanks so much for taking the time to compose a very thorough answer.
If you could indulge a few clarifications/suggestions ...
So here, the value of None for car.auction, merges into the session which
becomes a pending change. The
On Sep 22, 2010, at 12:21 PM, Michael Hipp wrote:
On that last note I found that if I do:
new = Car()
new.id_ = old.id_
new = sess.merge(new)
new.auction = old.auction # do this *after* merge
sess.commit()
This seems to work and avoids me having to deal with the cascade stuff (which
here's your new section:
http://www.sqlalchemy.org/docs/orm/session.html#merge-tips
--
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
On 9/22/2010 11:21 AM, Michael Hipp wrote:
new = Car()
new.id_ = old.id_
new = sess.merge(new)
new.auction = old.auction # do this *after* merge
sess.commit()
This seems to work and ...
Bah. I spoke too soon - it just doesn't throw an exception. But without
explicitly setting
On Sep 22, 2010, at 5:17 PM, Michael Hipp wrote:
On 9/22/2010 11:21 AM, Michael Hipp wrote:
new = Car()
new.id_ = old.id_
new = sess.merge(new)
new.auction = old.auction # do this *after* merge
sess.commit()
This seems to work and ...
Bah. I spoke too soon - it just doesn't
On 9/22/2010 5:24 PM, Michael Bayer wrote:
Here's the problem. The term a blank record is meaningless.
Well, no, it's not. It's exactly what I get when I do new=Item() and commit().
It's very well defined, precise, and repeatable.
Trying to make other tools guess this for you seems to be
On Sep 22, 2010, at 6:44 PM, Michael Hipp wrote:
On 9/22/2010 5:24 PM, Michael Bayer wrote:
Here's the problem. The term a blank record is meaningless.
Well, no, it's not. It's exactly what I get when I do new=Item() and
commit(). It's very well defined, precise, and repeatable.
I need to empty an item (row). I thought to do this:
new = Item() # create a new empty object
new.id_ = old.id_ # copy certain other fields also
self.session.expunge(old)
self.session.add(new)
self.session.commit()
But it seems SA still tries to save it with an INSERT. (I
On 9/21/2010 7:31 AM, Michael Hipp wrote:
I need to empty an item (row). I thought to do this:
new = Item() # create a new empty object
new.id_ = old.id_ # copy certain other fields also
self.session.expunge(old)
self.session.add(new)
self.session.commit()
But it seems SA still tries to save
On Sep 21, 2010, at 8:42 PM, Michael Hipp wrote:
class Car(Base):
__tablename__ = 'cars'
id_ = Column(Integer, primary_key=True)
auct_id = Column(Integer, ForeignKey('auctions.id_'), nullable=False)
auction = relationship('Auction', backref=backref('cars', order_by=lane))
On 9/21/2010 8:17 PM, Michael Bayer wrote:
It definitely does not attempt an INSERT if id_ is set to a non-None value,
assuming that row already exists in the DB, without something else in your
model/usage causing that to happen.If id_ is None or the given id_ doesn't
exist in the DB, you
12 matches
Mail list logo