Thanks for your quick and helpful reply! So if I understood correctly,
there is no way to ensure that a string is not interpreted as a column in
an arbitrary expression, right? In another example, it was the other way
around and I had to use single quotes rather than double quotes to prevent
the string from being interpreted as a column name (see below). Using
double quotes for c1 (i.e., c0 = "c1") results in no rows being returned
(since c1 is interpreted as a column name), while using single quotes
results in the row being fetched.

CREATE TABLE test (c0, c1);
INSERT INTO test(c0, c1) VALUES ("c1", 0);
SELECT * FROM test WHERE c0 = 'c1';

Best,
Manuel

Am Sa., 27. Apr. 2019 um 21:14 Uhr schrieb Richard Hipp <d...@sqlite.org>:

> On 4/27/19, Manuel Rigger <rigger.man...@gmail.com> wrote:
> >
> > 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');
> >
> > Could this be a bug or an unnoticed inconsistency?
>
> This is intentional, though undocumented (or at least I don't recall
> documenting it).  You can, in fact, use a string literal for the name
> of a table or column.  For example:
>
>     CREATE TABLE 'test'('c0');
>
> Which is logically equivalent to your original:
>
>     CREATE TABLE test(c0);
> --
> 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-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to