[Sqlalchemy-tickets] [sqlalchemy] #1151: changing primary key value on expired instance fails to lo
Brought to you by:
zzzeek
From: sqlalchemy <mi...@zz...> - 2008-08-22 14:12:41
|
#1151: changing primary key value on expired instance fails to load the old PK version --------------------+------------------------------------------------------- Reporter: zzzeek | Owner: zzzeek Type: defect | Status: new Priority: medium | Milestone: Component: (none) | Severity: no triage selected yet Keywords: | Status_field: awaiting triage --------------------+------------------------------------------------------- {{{ from sqlalchemy import create_engine, Table, Column, Integer, String, MetaData from sqlalchemy.orm import mapper, sessionmaker engine = create_engine("sqlite:///:memory:",echo=True) class User(object): def __init__(self,name="anonymous"): self.id = 2 self.name = name def __repr__(self): return "<User ID : %s, Name : %s>" % (repr(self.id),self.name) metadata = MetaData() usertable = Table('users',metadata, Column('id',Integer,primary_key=True), Column('name',String(50)) ) metadata.create_all(engine) mapper(User,usertable) Session = sessionmaker(bind=engine,autocommit=False,autoflush=False) #expireoncommit is True session = Session() u = User("One") session.add(u) session.commit() #session.refresh(u) u.id = 1 session.add(u) session.commit() }}} -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1151> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |