Re: [sqlite] SQL Syntax fault on UPDATE statement

2016-08-17 Thread flo
Effectively,

Sorry about my mistake.

2016-08-17 10:33 GMT+02:00 Richard Hipp :

> On 8/17/16, flo  wrote:
> >
> > $ sqlite3 test.db "UPDATE test SET id=0 AND name='new_name' AND age=30
> > WHERE id=1;"
>
> The above is parsed like this:
>
>   UPDATE test SET id = (0 AND name='new_name' AND age=30) WHERE id=1;
>
> And since the expression in parentheses always evaluates to 0, the
> above is equivalent to:
>
>   UPDATE test SET id=0 WHERE id=1;
>
> Which is exactly what SQLite is doing.
>
> --
> D. Richard Hipp
> d...@sqlite.org
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQL Syntax fault on UPDATE statement

2016-08-17 Thread flo
Hi everyone,

I found a reproducible bug on the SQL UPDATE statement parsing. Here is the
details.

I 've try to update some data on a SQLite database with a outlandish syntax
with "AND" between the columns to be update.  The SQL didn't fail but the
data update was incomplete.


The SQLite version :

$ sqlite3 -version
3.13.0 2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2


The data base schema :

$ sqlite3 test.db ".schema"
CREATE TABLE test(id interger, name varchar, age integer)


The initial stat of the table :

$ sqlite3 test.db "SELECT * FROM test;"
1|toto|10
2|tita|10
2|tita|10
1|toto|10
2|tita|10


The oulandish SQL UPDATE :

$ sqlite3 test.db "UPDATE test SET id=0 AND name='new_name' AND age=30
WHERE id=1;"


The stat of the table after the outlandish update :

$ sqlite3 test.db "SELECT * FROM test;"
0|toto|10
2|tita|10
2|tita|10
0|toto|10
2|tita|10

==> The "id" column was updated but not the two other columns "name" and
"age".


A common SQL Update syntaxe work perfectly :

$ sqlite3 test.db "UPDATE test SET id=6, name='new_name', age=30 WHERE
id=2;"

$ sqlite3 test.db "SELECT * FROM test;"
0|toto|10
6|new_name|30
6|new_name|30
0|toto|10
6|new_name|30


Good Luck

der.nairolf
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users