Hi everyone,

when executing the example below, I get "Error: no such column: asdf". This
behavior is surprising to me, as I would have expected "asdf" to be
interpreted as a string and not as a column name.

CREATE TABLE test (c0);
CREATE INDEX index_1 ON test('asdf');

According to the docs, single quotes are reserved for strings: "A string
constant is formed by enclosing the string in single quotes (')." [1]
Although creating an index on a (string) literal does not provide any
value, the documentation seems to allow any expression (with some
restrictions). Thus, indexes on literals of other data types and on
computed strings do not result in an error (see examples below).

CREATE INDEX index_2 ON test(3);
CREATE INDEX index_3 ON test(3.3);
CREATE INDEX index_4 ON test('as'||'df');

Enclosing the string in double quotes does not result in an error either
(see below).

CREATE INDEX index_5 ON test("asdf");

Could this be a bug or an unnoticed inconsistency? I stumbled upon it while
randomly creating SQL statements, and addressing this would allow me to
consistently use single quotes for strings.

Best,
Manuel
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to