On 10 Dec 2010, at 12:20am, Ryan Johnson wrote:

> On 12/9/2010 4:56 PM, Igor Tandetnik wrote:
>> On 12/9/2010 6:42 PM, Ryan Johnson wrote:
>>> create table a(x,y INTEGER);
>> This creates a table with column x having no affinity, and column y
>> having integer affinity. Is this what you meant?
> Doh! That explains why I couldn't repro with only a single column...

Yes, you got mixed up.  The command-line example you give works exactly as 
expected.  The thing that may be confusing you is that the INSERT ... SELECT 
form does work in an unexpected way.


> Just for clarification, though, how do comparisons work when there is no 
> affinity? I thought it did a string compare, but that should have worked 
> in the above case...
> 
> In general, is "1"=1 ever true? With all the talk of dynamic typing, 
> etc. I would have expected so, but now I wonder...

You now have it right.  A string is never a number.  SQLite generally does the 
conversion to a number when initially setting the value of the field.  This 
means it doesn't have to keep doing it for every comparison.  You may find this 
useful:

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

for example, sequences like

"When text data is inserted into a NUMERIC column, the storage class of the 
text is converted to INTEGER or REAL (in order of preference) if such 
conversion is lossless and reversible."

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

Reply via email to