Re: [sqlite] Constraint Error Messages

2012-03-01 Thread Pete
Thanks for all the responses - I seem to have opened up a can of worms! Looking into his further, I see differences in how constraint failures are reported. In the case of a NOT NULL constraint, I got an error ". may not be NULL". In the case of a UNIQUE constraint, the error was "column is not

Re: [sqlite] Constraint error messages

2012-03-01 Thread Petite Abeille
On Mar 1, 2012, at 4:08 PM, Marc L. Allen wrote: >> I don't understand why you need to have constraint declaration. Do you >> have some kind of parser of table definition and your application >> relies on it to find all constraints that SQLite enforces? > > I believe it irks him that he cannot,

Re: [sqlite] Constraint error messages

2012-03-01 Thread Petite Abeille
On Mar 1, 2012, at 3:13 PM, Igor Tandetnik wrote: >> I would if I could. Unfortunately, in SQLite, in the case of unique >> constraints, this cannot be done as far as I know. Or? > > Just create a unique index, in lieu of unique constraint. I would rather see SQLite support some sort of USING

Re: [sqlite] Constraint error messages

2012-03-01 Thread Marc L. Allen
> I don't understand why you need to have constraint declaration. Do you > have some kind of parser of table definition and your application > relies on it to find all constraints that SQLite enforces? I believe it irks him that he cannot, in his own mind, provide a complete table definition. I

Re: [sqlite] Constraint error messages

2012-03-01 Thread Pavel Ivanov
On Thu, Mar 1, 2012 at 9:01 AM, Petite Abeille wrote: > On Mar 1, 2012, at 2:51 PM, Pavel Ivanov wrote: > >>> (2) If one create an unique, named index, one cannot use an unique >>> constraint as there is no way to add constraints after the table creation >>> (i.e. no alter add constraint …). >>

Re: [sqlite] Constraint error messages

2012-03-01 Thread Igor Tandetnik
Petite Abeille wrote: > On Mar 1, 2012, at 2:27 PM, Igor Tandetnik wrote: > >> If you want to refer to an index by name, I suggest you explicitly create >> this index with the name of your choosing. > > I would if I could. Unfortunately, in SQLite, in the case of unique > constraints, this can

Re: [sqlite] Constraint error messages

2012-03-01 Thread Petite Abeille
On Mar 1, 2012, at 2:51 PM, Pavel Ivanov wrote: >> (2) If one create an unique, named index, one cannot use an unique >> constraint as there is no way to add constraints after the table creation >> (i.e. no alter add constraint …). > > You don't need to create a unique constraint when you crea

Re: [sqlite] Constraint error messages

2012-03-01 Thread Pavel Ivanov
> (2) If one create an unique, named index, one cannot use an unique constraint > as there is no way to add constraints after the table creation (i.e. no alter > add constraint …). You don't need to create a unique constraint when you created a unique index. Unique index implies that you can't i

Re: [sqlite] Constraint error messages

2012-03-01 Thread Petite Abeille
On Mar 1, 2012, at 2:27 PM, Igor Tandetnik wrote: > If you want to refer to an index by name, I suggest you explicitly create > this index with the name of your choosing. I would if I could. Unfortunately, in SQLite, in the case of unique constraints, this cannot be done as far as I know. Or?

Re: [sqlite] Constraint error messages

2012-03-01 Thread Igor Tandetnik
Petite Abeille wrote: > For example, one can define a named unique key constraint: > > constraint header_uk unique( name ), > > This will result in SQLite automagically creating an unique index to support > the constraint. What's the name of that index? No > one knows for sure, as it's aut

Re: [sqlite] Constraint error messages

2012-03-01 Thread Petite Abeille
On Feb 29, 2012, at 10:28 PM, Richard Hipp wrote: > But that would require a lot of > extra code space, which is not "lite". There is a fine line between being parsimonious and cutting corners. For example, one can define a named unique key constraint: constraint header_uk unique( name )

Re: [sqlite] Constraint error messages

2012-02-29 Thread Petite Abeille
On Mar 1, 2012, at 12:20 AM, Roger Binns wrote: > There is a reason developers have gone to the trouble of naming their > constraints! Indeed. All these constraint names are meant to convey information. They are not decorative. ___ sqlite-users maili

Re: [sqlite] Constraint error messages

2012-02-29 Thread Jean-Christophe Deschamps
Me too. Either as a new standard way of working, or as something which can be turned on and off with a PRAGMA. I accept that SQLite is meant to be fast, but having SQLite spit out which check was violated will result in my app running faster and more dependably than when I build the same lo

Re: [sqlite] Constraint error messages

2012-02-29 Thread Simon Slavin
On 1 Mar 2012, at 12:38am, Mario Becroft wrote: > Just adding my voice to the choir. The constraints are of limited value > if you can't tell which one failed, and the system is not much more > 'lite' if the constraints have to be duplicated using CHECK clauses > anyway. Me too. Either as a ne

Re: [sqlite] Constraint error messages

2012-02-29 Thread Mario Becroft
Just adding my voice to the choir. The constraints are of limited value if you can't tell which one failed, and the system is not much more 'lite' if the constraints have to be duplicated using CHECK clauses anyway. -- Mario Becroft ___ sqlite-users ma

Re: [sqlite] Constraint error messages

2012-02-29 Thread BareFeetWare
On 01/03/2012, at 8:28 AM, Richard Hipp wrote: > SQLite implements CHECK constraints by concatenating all expressions from all > CHECK constraints on the table using AND and then evaluating the resulting > boolean to see if it is false. If it is false, an SQLITE_CONSTRAINT error is > raised. >

Re: [sqlite] Constraint error messages

2012-02-29 Thread BareFeetWare
I've also tried also using it in an SQL transaction (eg a batch import script), but SQLite doesn't allow it. So, in a transaction, one approach I've used is to create a temp table, a temp trigger and then insert some test data just to be able to use the raise function to abort the transaction an

Re: [sqlite] Constraint error messages

2012-02-29 Thread BareFeetWare
On 01/03/2012, at 4:22 AM, Pete wrote: > I would like to include as much error checking as possible in my database > schema. That's an admirable aim. The whole point of constraints is to bring the error checking as close to the data model as possible. > The problem I have is that the error mes

Re: [sqlite] Constraint error messages

2012-02-29 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 29/02/12 13:28, Richard Hipp wrote: >> We *could* keep track of each separate CHECK expression and remember >> the constraint name and evaluate each expression separately and >> output a customized error message for each failure. But that would >>

Re: [sqlite] Constraint error messages

2012-02-29 Thread Richard Hipp
On Wed, Feb 29, 2012 at 2:25 PM, Roger Binns wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 29/02/12 09:22, Pete wrote: > > The problem I have is that the error messages that come back from > > constraint violations are extremely generic (e.g. "constraint failed") > > and would m

Re: [sqlite] Constraint error messages

2012-02-29 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 29/02/12 09:22, Pete wrote: > The problem I have is that the error messages that come back from > constraint violations are extremely generic (e.g. "constraint failed") > and would mean nothing to a user. An issue first reported in 2006: http:/