sqlite> insert into weights values (null); Error: CHECK constraint failed: float
<Insert OCD comment about single quotes for strings> How about ...check (cast(float as real) = float)... ? sqlite> insert into weights values (1); sqlite> insert into weights values (0); sqlite> insert into weights values ('Hello'); Error: CHECK constraint failed: float sqlite> insert into weights values (null); sqlite> insert into weights values ('0'); --possible problem here since it takes it, but... sqlite> select float, typeof(float) from weights; float|typeof(float) 1.0|real 0.0|real |null 0.0|real --it stores it as a real anyway Run Time: real 0.000 user 0.000000 sys 0.000000 -----Original Message----- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of R Smith Sent: Wednesday, September 06, 2017 8:15 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] Should the INTEGER not be cast to a REAL On 2017/09/07 12:35 AM, Cecil Westerhof wrote: > It does not, but this does: > CREATE TABLE weights( > float REAL, > > CONSTRAINT float CHECK(TYPEOF(float) IN ("real","integer")) > ); > > Instead of "int" you need "integer". > yes of course... My bad, sorry, but at least you've solved it :) _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users