statement for alter table with string default value has double single quotes
I found bug with default value and sync schema. First revision of schema:
make_storage("test_db.sqlite",
make_table("User",
make_column("Id",
&User::userId,
primary_key()),
make_column("Name",
&User::name),
make_column("Age",
&User::age)));
Second revision(with std::string field 'email'):
make_storage("test_db.sqlite",
make_table("User",
make_column("Id",
&User::userId,
primary_key()),
make_column("Name",
&User::name),
make_column("Age",
&User::age),
make_column("Email",
&User::email,
default_value("[email protected]"))));
Single qoutes was added in default_value_extractor and get_table_info.
Generated statement: ALTER TABLE User ADD COLUMN Email TEXT NOT NULL DEFAULT ''[email protected]''
so expected statement is ALTER TABLE User ADD COLUMN Email TEXT NOT NULL DEFAULT '[email protected]' ?
yes
thanks for a bug report. Default value is least tested feature from all library features. So it is time to fix it and cover with tests. I'm gonna fix this in a few days.
Thanks
To take care of use case involving table and column names as numbers(e.g. 1) .
It should be ALTER TABLE "User" ADD COLUMN "Email" TEXT NOT NULL DEFAULT '[email protected]' ? https://www.sqlite.org/lang_keywords.html https://stackoverflow.com/questions/34884362/escape-table-name-in-sqlite https://stackoverflow.com/questions/4007780/sqlite-issue-with-table-names-using-numbers
@Hartigan does storage work after modifying schema with email column?
https://www.sqlite.org/lang_keywords.html
@fnc12 storage not worked because statement ALTER TABLE User ADD COLUMN Email TEXT NOT NULL DEFAULT ''[email protected]'' cannot be prepared
@Hartigan ok. I'll fix it and cover with unit tests