this is my storage:
static auto storage = make_storage(
"mysqlite.sqlite",
make_table("order",
make_column("order_number", &OrderTable::order_number, primary_key()),
make_column("start_time", &OrderTable::start_time),
make_column("end_time", &OrderTable::end_time),
make_column("type", &OrderTable::type),
make_column("renewal_times", &OrderTable::renewal_times),
make_column("status", &OrderTable::status),
make_column("amount", &OrderTable::amount),
make_column("openid", &OrderTable::openid),
make_column("nickname", &OrderTable::nickname),
make_column("parking_space_number", &OrderTable::parking_space_number),
make_column("license_plate_number", &OrderTable::license_plate_number),
make_column("parking_code", &OrderTable::parking_code),
make_column("phone_number", &OrderTable::phone_number),
make_column("appointment_time", &OrderTable::appointment_time),
make_column("arrival_time", &OrderTable::arrival_time),
make_column("leave_parking_lot_time", &OrderTable::leave_parking_lot_time),
make_column("parking_time", &OrderTable::parking_time),
make_column("leave_parking_space_time", &OrderTable::leave_parking_space_time),
make_column("in_barrier_gate_number", &OrderTable::in_barrier_gate_number),
make_column("out_barrier_gate_number", &OrderTable::out_barrier_gate_number),
make_column("parking_duration", &OrderTable::parking_duration),
make_column("create_time", &OrderTable::create_time)
),
make_table("pay_info",
make_column("id", &pay_info::id, primary_key()),
make_column("pay_type", &pay_info::pay_type),
make_column("payment", &pay_info::payment),
make_column("amount", &pay_info::amount),
make_column("pay_time", &pay_info::pay_time),
make_column("order_number", &pay_info::order_number),
foreign_key(&pay_info::order_number).references(&OrderTable::order_number)
));
here are my struct:
struct OrderTable
{
string order_number;
string start_time;
string end_time;
int type;
int renewal_times;
int status;
float amount;
string openid;
string nickname;
string parking_space_number;
string license_plate_number;
string parking_code;
string phone_number;
string appointment_time;
string arrival_time;
string leave_parking_lot_time;
string parking_time;
string leave_parking_space_time;
string in_barrier_gate_number;
string out_barrier_gate_number;
int parking_duration;
string create_time;
};
struct pay_info
{
int id;
int pay_type;
int payment;
float amount;
string pay_time;
std::unique_ptr<string> order_number;
};
what is wrong with it?
I don't know.
I am having trouble with:
storage.sync_schema();
When I use the examples/foreign_key.cpp it can work. But my code can't work.
make_table("artist",
make_column("artistid", &Artist::artistId, primary_key()),
make_column("artistname", &Artist::artistName)),
make_table("track",
make_column("trackid", &Track::trackId, primary_key()),
make_column("trackname", &Track::trackName),
make_column("trackartist", &Track::artistId),
foreign_key(&Track::artistId).references(&Artist::artistId)),
error info : near "order": syntax error: SQL logic error or missing database
Try to change your tables order
Отправлено с iPhone
11 марта 2020 г., в 14:44, daitouguan notifications@github.com написал(а):
error info : near "order": syntax error: SQL logic error or missing database
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
I know what is the problem. Your table name order matches order keyword. I need to add quotes around table name in sync scheme function. I shall fix it today and report about it here. Thank you for posting the issue
Отправлено с iPhone
11 марта 2020 г., в 14:44, daitouguan notifications@github.com написал(а):
error info : near "order": syntax error: SQL logic error or missing database
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
Fix is on the way https://github.com/fnc12/sqlite_orm/pull/480
fixed in dev branch. Please check it out
fixed in
devbranch. Please check it out
It can work.Thanks for your help!