Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Richard Hipp
On 7/9/18, R Smith wrote: > a - Does it affect the UPSERT statement's ON CONFLICT clause? i.e. does > INSERT ON CONFLICT... trigger the conflict resolution when the > CHECK fails? No UPSERT only works for uniqueness constraints (UNIQUE or PRIMARY KEY). > b - If so, would it be real hard

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread R Smith
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

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Richard Hipp
On 7/9/18, Thomas Kurz wrote: > Hello, > > 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

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Simon Slavin
On 9 Jul 2018, at 10:21pm, Thomas Kurz wrote: > However, this is a bit confusing as e.g. this works fine: > > CREATE TABLE test (col1 TEXT UNIQUE ON CONFLICT IGNORE); There is actually a way to do what you want. You do it with a TRIGGER which does the test and drops the offending row using

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Simon Slavin
On 9 Jul 2018, at 10:21pm, Thomas Kurz wrote: > However, this is a bit confusing as e.g. this works fine: > > CREATE TABLE test (col1 TEXT UNIQUE ON CONFLICT IGNORE); By 'works fine' do you mean you didn't get a syntax error, or do you mean that the clause actually does what you want, both to

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Thomas Kurz
> Yes. The ON CONFLICT clause goes in the INSERT command. Ok, thank you very much. However, this is a bit confusing as e.g. this works fine: CREATE TABLE test (col1 TEXT UNIQUE ON CONFLICT IGNORE); May I suggest the appropriate extension for CHECK ON CONFLICT IGNORE or is there a thoughtful

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Simon Slavin
On 9 Jul 2018, at 10:00pm, Thomas Kurz wrote: > I get a "syntax error near on": > CREATE TABLE test (col1 TEXT CHECK (col1<>'') ON CONFLICT IGNORE); > > Am I using a wrong syntax? Yes. The ON CONFLICT clause goes in the INSERT command. CREATE TABLE test (col1 TEXT CHECK (col1<>''));

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Thomas Kurz
Thank you, but I think there is a misunderstanding. I do want the constraint to be checked, but I want to ignore the attempt to insert values that would violate the check constraint. According to the "on conflict" documentation (https://sqlite.org/lang_conflict.html), "The ON CONFLICT clause

Re: [sqlite] CHECK IGNORE?

2018-07-09 Thread Richard Hipp
On 7/9/18, Thomas Kurz wrote: > is there a way to have Sqlite ignore check violations? > https://www.sqlite.org/pragma.html#pragma_ignore_check_constraints -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list