On Apr 8, 2019, at 9:08 PM, Joshua Thomas Wise <joshuathomasw...@gmail.com> 
wrote:
> 
> there should be a compile-time option to disable all implicit casting done 
> within the SQL virtual machine.

That’d be nice, especially when using SQLite with a strongly- and 
statically-typed programming language and a statically-typed DB interface (e.g. 
ORM), so that the correct mapping is always fixed and known at compile time, so 
the extra flexibility buys that programmer nothing.

Keep in mind that SQLite was born as a Tcl extension, so it shares its 
extremely loose concepts of data typing.

> The option could cause all type-incompatible operations to return NULL

That would overload the already-overloaded keyword NULL with still another 
meaning.  To SQLite, NULL already means:

1. No value given on input.

2. No corresponding value in the “B” table on LEFT JOIN with table “A”.

Then on top of that, there are the libraries that try to map the language’s 
notions of NULL/nullptr/nil, etc. to and from SQL.

Let’s not add still another meaning.

> it could cause these operations to throw hard errors

That’s a much better plan.

> 1. If invoking SUM() would cause integer overflow

…then you’re using the wrong data type.

If you have reason to believe that an idealized implementation of SUM() could 
produce  values of 19 digits or larger given your data, you should not be using 
INTEGER, period.  You might want to be using the recently-announced DECIMAL 
extension instead:

   https://chiselapp.com/user/lifepillar/repository/sqlite3decimal/index

> 2. Many built-in string functions will automatically cast BLOBs to TEXTs

You’ll have my sympathy if you can show a reasonable path where a TEXT column 
can have some of its values accidentally or implicitly converted to BLOB.

As far as I’m aware, your stated problem only occurs when you purposefully do 
that.  You have no sympathy from me if you shoot a hole in your foot while 
*aiming* at it. :)

> 3. Declaring a column with INTEGER affinity does not actually force its 
> values to be integers.

That’s only a problem if you don’t give SQLite integers as input, and if it you 
don’t, this falls under one of the oldest laws of computing: “If you lie to the 
computer, it usually finds a way to get its revenge.”
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to