On 8/7/18, Dirkjan Ochtman <dirk...@ochtman.nl> wrote:
>
> If INTEGER PRIMARY KEYs are always NOT NULL, I'd reasonably expect that it
> will be `notnull` even if NOT NULL is not explicitly specified. Is this a
> bug?

I don't think so.  INTEGER PRIMARY KEYs have another magic property in
that if you insert a NULL into them, they automatically convert that
NULL into a valid integer primary key.  So  the "notnull" column in
PRAGMA table_info does not mean "is this column always non-null when
read" but rather as "is it an error to insert a NULL into this
column".  For ordinary columns that are marked NOT NULL, the answer
will be "yes" according to both meanings.  But for an INTEGER PRIMARY
KEY, the answer according to the second meaning is "no".

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to