You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to use a dynamic approach for the do_update called when encountering a conflict? Similar to dynamic_from, dynamic_where, and so on.
Alternatively, is there any way to pass fields from the database to a function using parameters? If I have a function like:
void gen_statement(DB_field...){
......
}
Since each field in each table in the header file generated by ddl2cpp will have a different data type, I'm not sure how to pass multiple fields into my custom function if I need to add them to my statement using parameters.
The text was updated successfully, but these errors were encountered:
I am not sure I understand the first part of the question. Would you like to use a dynamic form of on_conflict(x).do_update(y)? That's currently not implemented, but could be done.
As for the second part: Passing fields to a function is easiest if you make the function a template. Alternatively, you could make use of decltype to declare the parameter types.
Yes, for the first part, I mean like:
auto x = insert_into(DB_foo).set(DB_foo.Id = parameter(DB_foo.Id)).dynamic_on_conflict().dynamic_do_update();
x.on_conflict.add(add_conflict);
x.do_update.add(add_update);
or maybe like boolean_expression:
auto x = boolean_expression(db, DB_foo.Id = "123");
insert_into(DB_foo).set(DB_foo.Id = parameter(DB_foo.Id)).on_conflict(DB_foo.Id).dynamic_do_update(x);
Regarding the second part, I think I may understand what you mean. I will try to implement it according to your suggestion and see how it works. Thank you very much.
Is it possible to use a dynamic approach for the do_update called when encountering a conflict? Similar to dynamic_from, dynamic_where, and so on.
Alternatively, is there any way to pass fields from the database to a function using parameters? If I have a function like:
void gen_statement(DB_field...){
......
}
Since each field in each table in the header file generated by ddl2cpp will have a different data type, I'm not sure how to pass multiple fields into my custom function if I need to add them to my statement using parameters.
The text was updated successfully, but these errors were encountered: