On 12 May 2013, at 7:15pm, Paul van Helden <p...@planetgis.co.za> wrote:

> On Sun, May 12, 2013 at 1:54 PM, Michael Black <mdblac...@yahoo.com> wrote:
> 
>> PRAGMA INTEGER_DIVISION  would probably not have saved you this bug as you
>> would not have known to turn it on (default would have to be OFF for
>> backwards compatibility).
> 
> I will use it on every connection I make in future to avoid future pain. 
> [snip]

The PRAGMAs allow SQLite to switch between different behaviours when the 
standard doesn't say what should happen.  If there was a PRAGMA like that it 
would allow SQLite to stop behaving as the SQL standard says it should.  Doing 
that would let SQLite violate the standard, and lots of people around here 
thinks that would be bad.  

> On Sun, May 12, 2013 at 2:59 PM, Yan Seiner <y...@seiner.com> wrote:
> 
>> If you want floats, you have to specify floats.  If you want integers, you
>> have to specify integers.
> 
> I can live with SELECT 1/2 vs SELECT 1.0/2. The problem is that there is no
> way to specify a float when you insert into a NUMERIC. 1.0 turns into an
> integer.

I think your problem is just that you have columns declared as NUMERIC.  You 
can have REAL behaviour if you want: just declare your columns as REAL instead:

SQLite version 3.7.12 2012-04-03 19:43:07
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE test (a REAL, b REAL);
sqlite> INSERT INTO test VALUES (1,2);
sqlite> INSERT INTO test VALUES (1.0,2.0);
sqlite> SELECT a,b,a/b FROM test;
1.0|2.0|0.5
1.0|2.0|0.5

Works fine: the values inserted were 1 and 2, but the column affinity was REAL, 
so the values were understood as REAL when they were inserted into the table.  

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to