Re: [Sqlalchemy-tickets] [sqlalchemy] #2501: the DELETE before INSERT problem
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2014-01-22 01:07:14
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by zzzeek):
here's a test that illustrates the feature working against the primary
key, a change to the patch coming will handle this:
{{{
#!python
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String, Float, UniqueConstraint,
ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session, relationship, backref
from sqlalchemy.orm.dependency import OneToManyDP, attributes
Base = declarative_base()
class ParentEntity(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
name = Column(String)
__mapper_args__ = {
"maintain_unique_attributes": [("id",)]
}
engine = create_engine('sqlite://', echo=True)
Base.metadata.create_all(engine)
sess = Session(engine)
p1 = ParentEntity(id=1, name='p1')
sess.add(p1)
sess.commit()
p2 = ParentEntity(id=1, name='p2')
sess.delete(p1)
sess.add(p2)
sess.commit()
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:21>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|