nalgeon / sqlean

The ultimate set of SQLite extensions
MIT License
3.72k stars 118 forks source link

sqlean flags `lower()` as non-deterministic #109

Closed mikeschinkel closed 8 months ago

mikeschinkel commented 8 months ago

Running sqlean version 3.45.0 on macOS I get this error:

Parse error near line 120: non-deterministic functions prohibited in generated columns
      domain       VARCHAR(24) GENERATED ALWAYS AS (lower(substr(email, instr(em
                                      error here ---^

The DDL for the table is:

create table email
(
   email_id     INTEGER
      primary key autoincrement,
   source       CHAR(1), -- A=Account,C=Contact
   source_email VARCHAR(48),
   is_valid     CHAR(1),
   email        VARCHAR(48),
   domain       VARCHAR(24) GENERATED ALWAYS AS (lower(substr(email, instr(email, '@') + 1)))
);

I am assuming that lower(), substr(), and instr() are all deterministic, right?

This DDL works in sqlite3 v3.37.0.

nalgeon commented 8 months ago

Sure! Fixed in 0.21.9.

mikeschinkel commented 8 months ago

Wow, talk about service! Thanks.

P.S. I have another one for you, slightly harder I expect. Issue pending.