This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jftuga
Recipients ghaering, jftuga
Date 2012-08-21.14:36:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345559787.18.0.3645038202.issue15754@psf.upfronthosting.co.za>
In-reply-to
Content
According to:
http://www.sqlite.org/releaselog/3_7_12.html

SQLite has the ability to, "Report the name of specific CHECK constraints that fail."

CPython 3.3.0b2 which uses SQLite version 3.7.12 does not report which constraint failed.
--
import platform, sqlite3

print("Platform : %s %s" % (platform.python_implementation(),platform.python_version()))
print("SQLite   : %s" % (sqlite3.sqlite_version))
print()

tbl="""\
create table test1 (
        db_insert_date       timestamp,
        check( cast(substr(db_insert_date,1,4) as integer) >= 2000 and cast(substr(db_insert_date,1,4) as integer) <= 2025),
        check( cast(substr(db_insert_date,6,2) as integer) >= 1    and cast(substr(db_insert_date,6,2) as integer) <= 12),
        check( cast(substr(db_insert_date,9,2) as integer) >= 1    and cast(substr(db_insert_date,9,2) as integer) <= 31)
)
"""

conn = sqlite3.connect(":memory:")
c = conn.cursor()
c.execute(tbl)

query = "insert into test1 values( ? )"
c.execute(query, ("2012-08-20", ) )
conn.commit() # this works

c.execute(query, ("2012-18-20", ) )
conn.commit() # returns: sqlite3.IntegrityError: constraint failed (but which constraint?)

"""
Traceback (most recent call last):
  File "C:bug.py", line 34, in <module>
    c.execute(query, ("2012-18-20", ) )
sqlite3.IntegrityError: constraint failed
"""
History
Date User Action Args
2012-08-21 14:36:27jftugasetrecipients: + jftuga, ghaering
2012-08-21 14:36:27jftugasetmessageid: <1345559787.18.0.3645038202.issue15754@psf.upfronthosting.co.za>
2012-08-21 14:36:26jftugalinkissue15754 messages
2012-08-21 14:36:25jftugacreate