The following example causes a SQL logic error on the iterate<Test>.
#include "sqlite_orm.h"
#include <vector>
#include <string>
#include <iostream>
using namespace sqlite_orm;
struct Test {
int64_t id;
std::vector<char> key;
};
int main() {
auto db = make_storage("test",
make_table("Test",
make_column("key", &Test::key),
make_column("id", &Test::id, autoincrement(), primary_key()))
);
db.sync_schema(true);
std::vector<char> key;
key.resize(255);
for (int i = 0; i < 255; i++)
key[i] = i;
Test v;
v.key = key;
db.insert(v);
for (auto& w : db.iterate<Test>(
where(c(&Test::key) == key))) {
std::cout << w.id << std::endl;
}
}
@bwesterb hi. Thanks for using the lib. You found a bug. The reason of it is that iterate returns an adapter view_t which stores query is string but blob cannot be presented as a raw string in a query. So to fix this I need to change query representation in view_t. I'll try to make it in a week if you don't mind.
Thanks
I am working on it here https://github.com/fnc12/sqlite_orm/pull/285
Fixed it in dev branch. Please check it out
@fnc12 thanks :)
Most helpful comment
@bwesterb hi. Thanks for using the lib. You found a bug. The reason of it is that
iteratereturns an adapterview_twhich stores query is string but blob cannot be presented as a raw string in a query. So to fix this I need to change query representation inview_t. I'll try to make it in a week if you don't mind.Thanks