On 9 Sep 2010, at 1:13am, Igor Tandetnik wrote:

> Simon Slavin <slav...@bigfraud.org> wrote:
>> What would happen if you wrote a row with '1.1' for every value, then used 
>> sqlite3_column_type when you read it back out ? 
>> Assuming that it was possible (i.e. no TRIGGER or UNIQUE prevented it). 
> 
> It depends. If you meant those apostrophes literally, you would get 
> SQLITE_TEXT. If you meant to insert 1.1 without apostrophes, that would be 
> SQLITE_FLOAT. However, it is possible that the value got coerced to some 
> other type upon insertion, due to column affinity. I guess I don't quite 
> understand the question.

If the column affinity is numeric, and the value represents a number, SQLite 
coerces the value before it saves the value.  Similarly for integer and real.  
See section 2.3 of

<http://www.sqlite.org/datatype3.html>

I was attempting to find a value which would always coerce directly to the 
affinity of the column, so when you read it back out it would always be the 
'proper' type.  My theory would be that this one value could be used to betray 
the affinity of every column in a table.

Unfortunately I don't think I can tell REAL from NUMERIC with the same value 
that can tell REAL from INTEGER.  You would have to test both the value you 
read back out and sqlite3_column_type().

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

Reply via email to