It appears sqlite only accept single quote for default string values, which requires the code below to use single quote when serializing:
template<>
struct statement_serializator<std::string, void> {
using statement_type = std::string;
template<class C>
std::string operator()(const statement_type &c, const C &context) const {
if(context.replace_bindable_with_question) {
return "?";
} else {
return "'" + c + "'";
}
}
};
how can I reproduce the bug?
Try this code (with sqlite_orm 1.6):
```c++
struct Contact {
int id = 0;
std::string firstName;
std::string lastName;
std::string phone;
};
using namespace sqlite_orm;
auto storage = make_storage("/tmp/test.sqlite",
make_table("contacts",
make_column("contact_id", &Contact::id, primary_key()),
make_column("first_name", &Contact::firstName, default_value
make_column("last_name", &Contact::lastName, default_value
make_column("phone", &Contact::phone)));
storage.sync_schema();
````
The error would be:
default value of column [first_name] is not constant in "CREATE TABLE 'contacts' ( 'contact_id' INTEGER PRIMARY KEY NOT NULL , 'first_name' TEXT DEFAULT ("") NOT NULL , 'last_name' TEXT DEFAULT ("") NOT NULL
@taurusai does it reproduce in dev branch?
@taurusai does it reproduce in
devbranch?
yes
@taurusai ok thanks. I shall fix it today
the fix is on its way https://github.com/fnc12/sqlite_orm/pull/642
the fix is on its way #642
Great, thanks!
@taurusai merged in dev branch. Please check it out
@taurusai does everything work?
@taurusai does everything work?
Yes, dev is working now, thanks!
Looking forward to 1.7 release.