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 chris.jerdonek
Recipients chris.jerdonek, ghaering, jftuga, ned.deily, r.david.murray
Date 2012-08-21.20:29:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345580965.18.0.721042457783.issue15754@psf.upfronthosting.co.za>
In-reply-to
Content
I haven't been able to test this via Python because my system sqlite3 version isn't new enough.  But I was able to test this against sqlite3 directly.  I suspect there may be no issue.

John, have you tried naming your constraint?

http://www.sqlite.org/syntaxdiagrams.html#column-constraint

Specifically, if I try your example in sqlite3 3.7.13 (from the command-line, independent of Python), I get the generic error message:

"Error: constraint failed"

But if I add "CONSTRAINT name" to your test case SQL, e.g.

create table test1 (
        db_insert_date       timestamp,
        CONSTRAINT test_constraint1
        check(cast(substr(db_insert_date,1,4) as integer) <= 2025),
        CONSTRAINT test_constraint2
        check(cast(substr(db_insert_date,6,2) as integer) <= 12)
);

I get the error message "Error: constraint test_constraint2 failed".

I suspect things will work fine in Python because the Python code seems simply to use whatever error message sqlite3 provides it:

case SQLITE_CONSTRAINT:
case SQLITE_MISMATCH:
    PyErr_SetString(pysqlite_IntegrityError, sqlite3_errmsg(db));
    break;

(from http://hg.python.org/cpython/file/ca54c27a9045/Modules/_sqlite/util.c#l92 )
History
Date User Action Args
2012-08-21 20:29:25chris.jerdoneksetrecipients: + chris.jerdonek, ghaering, ned.deily, r.david.murray, jftuga
2012-08-21 20:29:25chris.jerdoneksetmessageid: <1345580965.18.0.721042457783.issue15754@psf.upfronthosting.co.za>
2012-08-21 20:29:24chris.jerdoneklinkissue15754 messages
2012-08-21 20:29:23chris.jerdonekcreate