On Mon, Sep 24, 2012 at 09:05:51PM +0400, Yuriy Kaminskiy scratched on the wall:
> Jay A. Kreibich wrote:

> >   And finally, for anyone that really wants strong typing, that's easy
> >   enough to do.  Just add a check constraint to your column defs:
> >   
> >   CREATE TABLE t (
> >     i  integer   CHECK ( typeof( i ) == 'integer' ),
> >     t  text      CHECK ( typeof( t ) == 'text' ),
> >     r  float     CHECK ( typeof( r ) == 'real' ),
> >     b  blob      CHECK ( typeof( b ) == 'blob' )
> >   );
> 
> Won't help with catching error in
> DELETE ... WHERE day >= 2012-03-15 -- oops, just deleted records from 
> 1994 year
> 
> Won't help with catching error when (SELECT ...) >= (SELECT ...) suddenly
> uses string comparison instead of numerical (9 >= 19 vs '9' >= '19').
> 
> Yes, sqlite rules documented, yes, you can always explain why it behaved
> the way it did, still nasty surprises happens, especially with newbies
> (and sometimes not only with newbies).

  The CHECK constraints won't help because these issues have nothing to
  do with SQLite's use of manifest typing.  Making sure all the values
  of a column are the same doesn't change the fact that SQLite doesn't
  support a native date type, and doesn't change the fact that strings
  are compared differently than numbers.

  It might change the fact that a buggy application tried to stuff a
  string into a numeric column and got unexpected results, but that's
  still an issue with the application, not SQLite.  You're blaming
  SQLite for doing what you asked it to do.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to