the program works for me, I get:

2009-08-24 16:12:56,797 INFO sqlalchemy.engine.base.Engine.0x...1830
PRAGMA table_info("user")
2009-08-24 16:12:56,806 INFO sqlalchemy.engine.base.Engine.0x...1830 ()
2009-08-24 16:12:56,807 INFO sqlalchemy.engine.base.Engine.0x...1830
CREATE TABLE user (
        code INTEGER NOT NULL,
        status INTEGER NOT NULL,
        username VARCHAR NOT NULL,
        PRIMARY KEY (code, status)
)


2009-08-24 16:12:56,808 INFO sqlalchemy.engine.base.Engine.0x...1830 ()
2009-08-24 16:12:56,808 INFO sqlalchemy.engine.base.Engine.0x...1830 COMMIT
2009-08-24 16:12:56,812 INFO sqlalchemy.engine.base.Engine.0x...1830 BEGIN
2009-08-24 16:12:56,813 INFO sqlalchemy.engine.base.Engine.0x...1830
INSERT INTO user (code, status, username) VALUES (?, ?, ?)
2009-08-24 16:12:56,813 INFO sqlalchemy.engine.base.Engine.0x...1830 [0,
1, u'a']
2009-08-24 16:12:56,814 INFO sqlalchemy.engine.base.Engine.0x...1830 COMMIT
2009-08-24 16:12:56,814 INFO sqlalchemy.engine.base.Engine.0x...1830 BEGIN
2009-08-24 16:12:56,815 INFO sqlalchemy.engine.base.Engine.0x...1830
INSERT INTO user (code, status, username) VALUES (?, ?, ?)
2009-08-24 16:12:56,815 INFO sqlalchemy.engine.base.Engine.0x...1830 [0,
2, u'a']
2009-08-24 16:12:56,816 INFO sqlalchemy.engine.base.Engine.0x...1830 COMMIT
2009-08-24 16:12:56,817 INFO sqlalchemy.engine.base.Engine.0x...1830 BEGIN
2009-08-24 16:12:56,818 INFO sqlalchemy.engine.base.Engine.0x...1830
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-24 16:12:56,818 INFO sqlalchemy.engine.base.Engine.0x...1830 [0, 1]
2009-08-24 16:12:56,820 INFO sqlalchemy.engine.base.Engine.0x...1830
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-24 16:12:56,820 INFO sqlalchemy.engine.base.Engine.0x...1830 [0, 2]
2009-08-24 16:12:56,822 INFO sqlalchemy.engine.base.Engine.0x...1830
UPDATE user SET status=? WHERE user.code = ? AND user.status = ?
2009-08-24 16:12:56,822 INFO sqlalchemy.engine.base.Engine.0x...1830 [3,
0, 1]
2009-08-24 16:12:56,823 INFO sqlalchemy.engine.base.Engine.0x...1830
UPDATE user SET status=? WHERE user.code = ? AND user.status = ?
2009-08-24 16:12:56,823 INFO sqlalchemy.engine.base.Engine.0x...1830 [1,
0, 2]
2009-08-24 16:12:56,824 INFO sqlalchemy.engine.base.Engine.0x...1830 COMMIT


Martijn Faassen wrote:
> Hi there,
>
> I'm experimenting with a composite primary key to see whether it might
> help implement a workflow system, where the primary key consists of an
> identifier (code) and a workflow status.
>
> I run into an error with the ORM (in 0.5.5 and trunk) when I modify part
> of the primary key (the workflow status). It looks like the session
> somehow retains a reference to something that isn't around anymore. The
> documentation claims primary keys can be mutated, but perhaps I'm doing
> something that really shouldn't be done after all?
>
> I've attached the code to reproduce the issue (reproduce.py). The error
> is during the commit on the last line, when the primary keys of two
> items are modified.
>
> Here is the traceback:
>
> Traceback (most recent call last):
>    File "bin/devpython", line 25, in ?
>      execfile(sys.argv[0])
>    File "reproduce.py", line 44, in ?
>      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
> 0xb769ae4c> is not present in this identity map
>
> 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