/ View Ticket
Login
Ticket UUID: 23b212820161c6599cbf414aa99bf8a5bfa5e7a3
Title: Uninformative error message on check constraint failure
Status: Fixed Type: Feature_Request
Severity: Minor Priority: Immediate
Subsystem: Virtual_Machine Resolution: Fixed
Last Modified: 2014-03-11 13:14:19
Version Found In: 3.3.2
Description:
http://www.sqlite.org/cvstrac/tktview?tn=1648

If a check constraint fails then all you get is "constraint failed". Even if you name your constraints, have more than one etc you don't get any useful information in the error message such as the constraint name or columns. The original ticket included a poster who had a partial patch to fix this.

sqlite> create table emp(id text unique, sex text constraint chk_sex check(sex in ('m','f')));
sqlite> insert into emp values('1','x');
ConstraintError: constraint failed

You do get more useful information in simple circumstances:

sqlite> insert into emp values('1','m');
sqlite> insert into emp values('1','m');
ConstraintError: column id is not unique
sqlite> create table foo(x not null, y not null);
sqlite> insert into foo values(null, 1);
ConstraintError: foo.x may not be NULL

anonymous added on 2009-10-08 11:23:51:
The same applies to foreign key constraints: error messages which are generated by the .genfkey triggers are also not very informative. That would be easy to fix.


anonymous claiming to be BuschnicK added on 2009-11-19 12:06:32:
+1 for this feature request. I have quite a complex database schema maintained in parallel on various different server backends (Postgres, SQLServer, SQLite) and SQLite stands out in a bad way due to it's non-descript error messages. It would be tremendously helpful to know more information about the actual constrained that failed.