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
Following example success compiled with latest dev sqlite_orm, but on runtime gives 'testtable' is not a function: SQL logic error
#include <cstdint>
#include <string>
#include "sqlite_orm_dev.h"
namespace orm = sqlite_orm;
struct testtable
{
std::int64_t id = 0;
std::int64_t value = 0;
};
static inline auto init_storage(const std::string &path){
return orm::make_storage(path,
orm::make_table("testtable",
orm::make_column("id", &testtable::id, /*orm::autoincrement(),*/ orm::primary_key().autoincrement()),
orm::make_column("value", &testtable::value)
)
);
}
using storage_t = decltype(init_storage(""));
int main(){
storage_t storage = init_storage("database.sql");
storage.sync_schema();
testtable table;
table.id = 20;
table.value = 1;
storage.replace<testtable>(table);
auto list = storage.get_all<testtable>(
//orm::where( //--> Imagine that, I forgotten write there orm::where
orm::and_(orm::is_equal(&testtable::id, 20),
orm::is_equal(&testtable::value, 1)
),
//),
orm::limit( 1 )
);
for (auto&& row : list)
{
printf("id = %lld value = %lld\n", (long long)row.id, (long long)row.value);
}
return 0;
}
OUTPUT:
$ ./main
terminate called after throwing an instance of 'std::system_error'
what(): 'testtable' is not a function: SQL logic error
Aborted (core dumped)
Q: Can be detect this error in compile time ?
The text was updated successfully, but these errors were encountered:
Hi @raidenluikang . Thanks for submitting this issue. It is a very good suggestion. get_all can't accept everything but argument check logic is forwarded to SQLite engine at run-time. Of course we can update static checks and add static_assert. The easiest way is to add static_assert which checks that get_all arguments list don't contain and product but it is not right cause we better fix it in a different way: to mark some expressions available as get_all arguments (they are called already select constraints inside the code) and allow passing only select constraints inside. It must not break existing working queries but it will break compilation for existing queries which contain run-time error. Is it what you expect?
Following example success compiled with latest dev sqlite_orm, but on runtime gives 'testtable' is not a function: SQL logic error
OUTPUT:
Q: Can be detect this error in compile time ?
The text was updated successfully, but these errors were encountered: