Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-10 Thread James K. Lowden
On Thu, 9 Oct 2014 11:16:25 -0400 Stephen Chrzanowski pontia...@gmail.com wrote: On Wed, Oct 8, 2014 at 8:38 PM, James K. Lowden jklow...@schemamania.org wrote: The problem I see with your suggestion is that I can't think of another situation, with or without NULL, with or without

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-09 Thread Stephen Chrzanowski
I wouldn't call it 'magical' if the definition is right on the field declaration, and depending on the 'worth' of that particular bit of data (Booleans in this case, and I've got absolutely zero concern to the actual state of said boolean, but taking into consideration the typeless nature of

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-08 Thread Stephen Chrzanowski
On Wed, Oct 8, 2014 at 1:26 AM, Simon Slavin slav...@bigfraud.org wrote: You could probably use a TRIGGER that detects the type of row you don't want and replaces it with your preferred form. This doesn't do exactly what you want, but it is something like it. That'd work, but extra effort

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-08 Thread Simon Slavin
On 8 Oct 2014, at 1:22pm, Stephen Chrzanowski pontia...@gmail.com wrote: Can one not also put a constraint up on the field to say that the field can only be of a certain value, kind of to emulate ENUM? Sure you can. You can do anything expressible in SQL which turns into a BOOLEAN value.

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-08 Thread Markus Schaber
Hi, It can even compare two fields in the same row and test one against the other so you can, for example, make sure you don't have any people who are both male and pregnant. Actually, this restriction could be problematic: https://en.wikipedia.org/wiki/Transgender_pregnancy Best regards

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-08 Thread Petite Abeille
On Oct 8, 2014, at 6:14 AM, Stephen Chrzanowski pontia...@gmail.com wrote: When adding a NULL value to a table that has the NOT NULL flag set on that field, instead of raising an exception, if the field definition were to have the word USE between ON CONFLICT and DEFAULT in its declaration,

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-08 Thread Stephen Chrzanowski
If the field def'n were to be changed to [ col2 NUMBER DEFAULT ON NULL 0 ] and then when I insert/update something that becomes NULL and the result becomes 0 for that field, then yeah, bingo. On Wed, Oct 8, 2014 at 2:14 PM, Petite Abeille petite.abei...@gmail.com wrote: On Oct 8, 2014, at 6:14

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-08 Thread Petite Abeille
On Oct 8, 2014, at 8:51 PM, Stephen Chrzanowski pontia...@gmail.com wrote: If the field def'n were to be changed to [ col2 NUMBER DEFAULT ON NULL 0 ] and then when I insert/update something that becomes NULL and the result becomes 0 for that field, then yeah, bingo. Yep, that’s exactly what

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-08 Thread James K. Lowden
On Wed, 8 Oct 2014 00:14:51 -0400 Stephen Chrzanowski pontia...@gmail.com wrote: When adding a NULL value to a table that has the NOT NULL flag set on that field, instead of raising an exception, if the field definition were to have the word USE between ON CONFLICT and DEFAULT in its

[sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-07 Thread Stephen Chrzanowski
I'm making up a small database (for yet another tool I never plan on releasing) and during the table creation, I had a thought about the Not Null and On Conflict resolution mechanism. When adding a NULL value to a table that has the NOT NULL flag set on that field, instead of raising an

Re: [sqlite] Possible automatic ON CONFLICT resolution via DEFAULTS

2014-10-07 Thread Simon Slavin
On 8 Oct 2014, at 5:14am, Stephen Chrzanowski pontia...@gmail.com wrote: The one downside I just realized is that ON CONFLICT can be used outside of the table declarations as well, so perhaps a different word or signal might be needed for it to make linguistic sense, or, this version of ON