Using SQLite 3.7.15.2. The following statements execute with no error:

CREATE TABLE [test1] (
  [id] INTEGER,
  [name] CHAR DEFAULT 'test');

CREATE TABLE [test2] (
  [id] INTEGER,
  [name] CHAR DEFAULT ('test'));

CREATE TABLE [test3] (
  [id] INTEGER,
  [name] CHAR DEFAULT "test");


However, the following returns "default value of column [name] is not
constant."

CREATE TABLE [test4] (
  [id] INTEGER,
  [name] CHAR DEFAULT ("test"));


There are no identifiers in this context named "test" - no other tables or
columns, and "test" is not a keyword. Changing "test" to a keyword like
"key" or "glob" returns the same error.

The SQLite documentation reads:

"If a keyword in double quotes (ex: "key" or "glob") is used in a context
where it cannot be resolved to an identifier but where a string literal is
allowed, then the token is understood to be a string literal instead of an
identifier."

So in the last statement, "test" (or "key") is used in a context where it
cannot be resolved to an identifier but the token is *not* understood to be
a string literal.

 To resume: while "test" is evaluated correctly as a string literal, after
enclosing it in parenthesis ("test") it no longer is.

Does this work as intended?

BTW, in my opinion the above quote should be changed to:

"If a string in double quotes (be it keyword or not) is used in a context
where it cannot be resolved to an identifier but where a string literal is
allowed, then the token is understood to be a string literal instead of an
identifier."

Regards,
Bogdan Ureche
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to