Hey,

Michael Bayer wrote:
> the program works for me, I get:

That's interesting. I've tested the script with Python 2.4, Python 2.5, 
and Python 2.6, with SQLAlchemy 0.5.5 and trunk. sqlite version is 
3.4.2. I get the assertion error each time.

The output I get when echo is True (on SA trunk/Python 2.5) is this:

2009-08-25 15:19:18,637 INFO sqlalchemy.engine.base.Engine.0x...974c 
PRAGMA table_info("user")
2009-08-25 15:19:18,637 INFO sqlalchemy.engine.base.Engine.0x...974c ()
2009-08-25 15:19:18,638 INFO sqlalchemy.engine.base.Engine.0x...974c
CREATE TABLE user (
        code INTEGER NOT NULL,
        status INTEGER NOT NULL,
        username VARCHAR NOT NULL,
        PRIMARY KEY (code, status)
)


2009-08-25 15:19:18,638 INFO sqlalchemy.engine.base.Engine.0x...974c ()
2009-08-25 15:19:18,638 INFO sqlalchemy.engine.base.Engine.0x...974c COMMIT
2009-08-25 15:19:18,640 INFO sqlalchemy.engine.base.Engine.0x...974c BEGIN
2009-08-25 15:19:18,640 INFO sqlalchemy.engine.base.Engine.0x...974c 
INSERT INTO user (code, status, username) VALUES (?, ?, ?)
2009-08-25 15:19:18,641 INFO sqlalchemy.engine.base.Engine.0x...974c [0, 
1, u'a']
2009-08-25 15:19:18,641 INFO sqlalchemy.engine.base.Engine.0x...974c COMMIT
2009-08-25 15:19:18,641 INFO sqlalchemy.engine.base.Engine.0x...974c BEGIN
2009-08-25 15:19:18,642 INFO sqlalchemy.engine.base.Engine.0x...974c 
INSERT INTO user (code, status, username) VALUES (?, ?, ?)
2009-08-25 15:19:18,642 INFO sqlalchemy.engine.base.Engine.0x...974c [0, 
2, u'a']
2009-08-25 15:19:18,642 INFO sqlalchemy.engine.base.Engine.0x...974c COMMIT
2009-08-25 15:19:18,643 INFO sqlalchemy.engine.base.Engine.0x...974c BEGIN
2009-08-25 15:19:18,643 INFO sqlalchemy.engine.base.Engine.0x...974c 
SELECT user.code AS user_code, user.status AS user_status, user.username 
AS user_username
FROM user
WHERE user.code = ? AND user.status = ?
2009-08-25 15:19:18,644 INFO sqlalchemy.engine.base.Engine.0x...974c [0, 1]
2009-08-25 15:19:18,645 INFO sqlalchemy.engine.base.Engine.0x...974c 
SELECT user.code AS user_code, user.status AS user_status, user.username 
AS user_username
FROM user
WHERE user.code = ? AND user.status = ?
2009-08-25 15:19:18,645 INFO sqlalchemy.engine.base.Engine.0x...974c [0, 2]
2009-08-25 15:19:18,646 INFO sqlalchemy.engine.base.Engine.0x...974c 
UPDATE user SET status=? WHERE user.code = ? AND user.status = ?
2009-08-25 15:19:18,646 INFO sqlalchemy.engine.base.Engine.0x...974c [3, 
0, 1]
2009-08-25 15:19:18,646 INFO sqlalchemy.engine.base.Engine.0x...974c 
UPDATE user SET status=? WHERE user.code = ? AND user.status = ?
2009-08-25 15:19:18,646 INFO sqlalchemy.engine.base.Engine.0x...974c [1, 
0, 2]
Traceback (most recent call last):
   File "bin/devpython", line 25, in <module>
     execfile(sys.argv[0])
   File "reproduce.py", line 44, in <module>
     session.commit()
   File ".../sqlalchemy/orm/session.py", line 673, in commit
     self.transaction.commit()
   File ".../sqlalchemy/orm/session.py", line 378, in commit
     self._prepare_impl()
   File ".../sqlalchemy/orm/session.py", line 362, in _prepare_impl
     self.session.flush()
   File ".../sqlalchemy/orm/session.py", line 1358, in flush
     self._flush(objects)
   File ".../sqlalchemy/orm/session.py", line 1445, in _flush
     flush_context.finalize_flush_changes()
   File ".../sqlalchemy/orm/unitofwork.py", line 288, in 
finalize_flush_changes
     self.session._register_newly_persistent(elem.state)
   File ".../sqlalchemy/orm/session.py", line 1021, in 
_register_newly_persistent
     self.identity_map.remove(state)
   File ".../sqlalchemy/orm/identity.py", line 135, in remove
     raise AssertionError("State %s is not present in this identity map" 
% state)
AssertionError: State <sqlalchemy.orm.state.InstanceState object at 
0x84228ac> is not present in this identity map

At first glance that looks identical to yours, until the session tries
to do the commit in the end.

What's the difference?

Regards,

Martijn


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to