Dear list,

I have been upgrading an application I wrote with SQLAlchemy 0.4 to
0.5.8. Currently I'm fighting a strange effect. In some places of my
application I can't insert data into the database any more. I get error
messages like:

IntegrityError: (IntegrityError) null value in column "myobject_id"
violates not-null constraint 'INSERT INTO myobject (id, related_id,
text) VALUES (%(id)s, %(related_id)s, %(text)s)' {'related_id': 1, 'id':
None, 'text': 'The quick brown fox'}

So apparently SQLAlchemy tries to insert a new row with the "id" field
being "None". This is obviously wrong because the field is supposed to
contain the next serial value. I enabled debugging and saw that before
the insert SQLAlchemy runs:

___SQL___ sqlalchemy.engine.base.Engine.0x...3b8c: select
                                  nextval('"myobject_id_seq"')
___SQL___ sqlalchemy.engine.base.Engine.0x...3b8c: None

I was curious and ran that SELECT statement in a "psql" shell directly
on the database server and correctly received:

mydatabase=# select nextval('"myobject_id_seq"');
 nextval
---------
     358
(1 row)

After hours of digging around in my code, reinstalling psycopg2 and
writing test cases I'm stuck somehow. How come SQLAlchemy fails to find
the next ID of that column?

Thanks in advance for any insight.

Regards
 Christoph

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to