On 17/07/2009 1:30 AM, Simon Slavin wrote:
> On 16 Jul 2009, at 2:35pm, Uijtdewilligen, Freek wrote:
> 
>> Okay, way too much time after discovering the problem, I found the
>> cause: a simple typo :)
>>
>> In the String where it was storing the column-names, it said (x, y, x,
>> etc..), and somewhere this created the null..
> 
> Congratulations and well spotted.  We've all done it.
> 
> 
> On 16 Jul 2009, at 3:36pm, John Machin wrote:
> 
>> This sounds like a bug somewhere -- having a column name twice  
>> should be
>> met with an error message, not with setting the integer column to  
>> NULL.
> 
> It's doing The Right Thing.  The SQL standard states that things like
> 
> INSERT INTO favouriteColour (person,person) VALUES ('Fred', 'Joan')
> 
> must work.  And if a default value for the other field is not declared  
> it naturally gets NULL.  It's silly, but it's right.
> 

Thanks for that, Simon; that's news to me, and rather mind-boggling:

sqlite> create table foo (x, y, z);
sqlite> insert into foo (x, y, x) values ('first', 'second', 'third');
sqlite> insert into foo values ('first', 'second', 'third');
sqlite> select * from foo;
first|second|
first|second|third
sqlite>

I always though the first variety of INSERT was preferred because it did 
some error checking that was not possible with the second variety of 
INSERT :-(

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

Reply via email to