On Wed, 6 Apr 2016 06:13:01 +0000
Hick Gunter <hick at scigames.at> wrote:
> You are hopefully aware of the fact that SQLite associates type with
> the actual values and not the containers(columns) used to hold these
> values? This means that a data object of any type may be
> held/returned in a column, irrespective of the declared type (which,
> for expressions, is NULL).
Yes, but some of us are careful to include CHECK constraints to enforce
type-checking. Even when not that careful, many follow the practice of
restricting each column to a single type.
> What would your date routine do with the string 12.17.9.17.15?
It would never see it. Problem solved by prevention:
sqlite> create table T(t TEXT not NULL
check (strftime('%m', t) is not NULL));
sqlite> insert into T values ('2016-04-06');
sqlite> insert into T values ('2016-14-06');
Error: CHECK constraint failed: T
sqlite> insert into T values ('12.17.9.17.15');
Error: CHECK constraint failed: T
--jkl