#19 Duplicate unique index values

open
nobody
None
5
2002-11-01
2002-11-01
Andy Todd
No

Duplicating unique index values can corrupt a gadfly
database.

If a unique index is specified on a column and another
row is inserted (or an existing row updated) that
violates the unique index the exception
gadfly.store.StorageError is raised. However, it looks
like the new data is written to the database files
anyway. Unless you explicitly rollback the change the
database becomes unstable and cannot subsequently be
opened.

I'll make a note in the documentation to always use
connection.rollback() but I would like the default
behaviour to change if possible. If any DML operation
causes an error then the DML should not be written to
the database files.

I have attached a sample script (testIndex.py) which
will create a table with a unique index and then try
and insert the same record twice. If you comment out
the last row and run it the database in question will
become unstable.

Discussion

  • Andy Todd
    Andy Todd
    2002-11-01

    testIndex.py

     
    Attachments