Re: [sqlite] Prevent non-Integers going into int fields.

2014-08-09 Thread Richard Warburton
Thanks Peter, that's exactly what I wanted. I've gone with your first (more strict) solution. Cheers. Date: Sat, 02 Aug 2014 22:42:41 -0700 From: Peter Aronson <pbaron...@att.net> To: sqlite-users@sqlite.org Subject: Re: [sqlite] Prevent non-Integers going into int fields. Mess

Re: [sqlite] Prevent non-Integers going into int fields.

2014-08-02 Thread Peter Aronson
If you don't mind requiring that the value being inserted be typed integer, you can use: create table t1 (c1 integer check (typeof(c1) = 'integer')); But this means that values that could be converted to integers by the integer affinity of the column, like 4.0 or '1' will be cause a check

[sqlite] Prevent non-Integers going into int fields.

2014-08-02 Thread Richard Warburton
Whilst any type going into a field is often seen as a big plus, there are occasions where this may be undesirable. For such occasions, I'm currently thinking that: NOT NULL CHECK( ROUND(fieldname)=fieldname ) looks ok, but I'm wondering if there's a case that still gets through or if there's a