How to chain/assign conditions?
Closed this issue · 4 comments
figaro-smartotum commented
Hi,
in order to prevent the duplications of long code fragments, I am looking for a way to chain where conditions in switch/if clauses.
Please look at the following code snippet:
using namespace sqlite_orm;
auto condition = c(&HaccpDetail::event) == HACCP_EVENT_START or c(&HaccpDetail::event) == HACCP_EVENT_STOP;
switch (typeFilter) {
case HACCP_TYPE_EVERYTHING:
break;
case HACCP_TYPE_COOKINGS:
// Missing operator= error
condition = condition and c(&Haccp::type) == HaccpType::HACCP_TYPE_COOKING;
break;
case HACCP_TYPE_ALARMS:
// Missing operator= error
condition = condition and c(&Haccp::type) == HaccpType::HACCP_TYPE_ALARM;
break;
}
auto result = this->storage->iterate<HaccpSamples>(where(condition));
// Iterate results
Is there a way to achieve this coding style?
fnc12 commented
figaro-smartotum commented
Many thanks,
alternatively, is there a way to perform raw-queries instead?
fnc12 commented
is there a way to perform raw-queries instead?
no. To use raw query you can always use any other regular ORM or libsqlite
fnc12 commented
@figaro-smartotum I am closing this issue cause it doesn't look like something that requires commits to be made. If you have something else please feel free to reopen it