SQLite Forum

Why Sqlite parse error: line 1:94: expecting RPAREN, found 'OR' in CHECK constraint?
Login
Dear SQLite users and developers,

thanks a lot for this awesome software!

I'm really a beginner with SQL but I managed to work with SQLite quite nicely (or so I think). Now I've met a warning that raises my concern. When I open my database file with sqlitebrowser3, it complains:
```
Sqlite parse error: line 1:94: expecting RPAREN, found 'OR'(CREATE TABLE images_raw(identifier_s1 VARCHAR UNIQUE PRIMARY KEY CHECK(identifier_s1 IS NULL OR (typeof(identifier_s1)='text')), path_s1 VARCHAR UNIQUE CHECK(path_s1 IS NULL OR (typeof(path_s1)='text')), is_internal_b0 INTEGER CHECK(is_internal_b0 IS NULL OR (typeof(is_internal_b0)='integer' AND is_internal_b0 BETWEEN 0 AND 1))))
```

I assume something is wrong in my `CHECK` statements but I fail to see what. I've googled for a while but all the examples I find are similar to mine (as close as I can see). Maybe there should be more (or less) bracketing of the statements?

I want to achieve with `CHECK`s that entries can only be of their corresponding C++ type. In this case, `identifier_s1` corresponds to a std::string, `path_s1` corresponds to a std::string and `is_internal_b0` corresponds to a bool.

Is my syntax (and logic) correct? Or how to do this better?