However, this may be horribly confusing to anyone else who has to understand your programming. They may be trying to insert a row and magically nothing happens. It may be better to have the IGNORE command in the INSERT command that they will be looking at rather than in a part of the schema they may not be thinking about.
On the other hand, it might better suit the way your software works.
On 7/9/18, Thomas Kurz <[hidden email]> wrote:
> is there a way to have Sqlite ignore check violations?
> I would like to do:
> CREATE TABLE .... (name TEXT NOT NULL CHECK (name<>'') ON CONFLICT IGNORE
> but the "on conflict" is not accepted here.
It does not appear that SQLite has ever acted upon "ON CONFLICT"
exceptions on CHECK constraints. Such clauses are accepted for CHECK
constraints not associated with a particular column. For example:
CREATE TABLE t1(x INT, CHECK(x!=5) ON CONFLICT IGNORE);
On 2018/07/10 12:53 AM, Richard Hipp wrote:
> CREATE TABLE t1(x INT, CHECK(x!=5) ON CONFLICT IGNORE);
> However, the parser silently discards the ON CONFLICT clause. I think
> this has always been the case.
Well, I feel embarrassed, I have used this CHECK conflict clause a good
number of times (usually the FAIL option) and simply never tested it for
actual in-use failure, and I'm usually the first to warn about the
dangers of assumption. :)
a - Does it affect the UPSERT statement's ON CONFLICT clause? i.e. does
INSERT.... ON CONFLICT... trigger the conflict resolution when the
b - If so, would it be real hard to make it so for column ... CHECK(...)
ON CONFLICT... too?