From: Ed J Date: Sat, 4 Jan 2020 20:31:20 +0000 (+0000) Subject: SQLite parser to understand CHECK with parens X-Git-Tag: v1.61~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc769efaadf170fde55df126432a108620c1ebb1;p=dbsrgits%2FSQL-Translator.git SQLite parser to understand CHECK with parens --- diff --git a/lib/SQL/Translator/Parser/SQLite.pm b/lib/SQL/Translator/Parser/SQLite.pm index d1c7b6f..8f09464 100644 --- a/lib/SQL/Translator/Parser/SQLite.pm +++ b/lib/SQL/Translator/Parser/SQLite.pm @@ -477,7 +477,8 @@ column_list : field_name(s /,/) parens_value_list : '(' VALUE(s /,/) ')' { $item[2] } -expr : /[^)]+/ +expr : /[^)]* \( [^)]+ \) [^)]*/x # parens, balanced one deep + | /[^)]+/ sort_order : /(ASC|DESC)/i diff --git a/t/data/sqlite/named.sql b/t/data/sqlite/named.sql index 3654690..a48686f 100644 --- a/t/data/sqlite/named.sql +++ b/t/data/sqlite/named.sql @@ -8,6 +8,6 @@ create table pet ( constraint fk_person_id_3 references person(person_id) on update NO ACTION, "name" varchar(30), "age" int, - constraint age_under_100 check ( age < 100 ), + constraint age_under_100 check ( age < 100 and age not in (101, 102) ), constraint pk_pet primary key (pet_id, person_id) );