diff options
author | tomsmeding <hallo@tomsmeding.nl> | 2015-05-23 21:38:20 +0200 |
---|---|---|
committer | tomsmeding <hallo@tomsmeding.nl> | 2015-05-23 21:38:20 +0200 |
commit | 934e7d22b43247ebe7ec5f4990814117baab7fda (patch) | |
tree | 91e17d6b37b751f3cf9e4af035c3e4b0163bfe36 /engine.cpp | |
parent | bd0fac9d424ccec65942c81c11b7aefe25c8a829 (diff) |
UpdateQuery finish
Diffstat (limited to 'engine.cpp')
-rw-r--r-- | engine.cpp | 74 |
1 files changed, 60 insertions, 14 deletions
@@ -44,6 +44,20 @@ int main(int argc,char **argv){ Table *hoitb=&tables.at("hoi"); + + + //Shitty. Works. +#define FINDQUERYEVERYTHING(PAR_tnm) \ + { \ + FindQuery fqu; \ + fqu.tablename= PAR_tnm ; \ + QueryResult res=fqu.execute(tables); \ + cout<<"Find in \"" PAR_tnm "\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; \ + for(const Row &r : res.rows)cout<<"- "<<r<<endl; \ + } + + + { Row row(3,hoitb); row.items[0].v.rh_int32=UINT_MAX; @@ -56,7 +70,7 @@ int main(int argc,char **argv){ QueryResult res=iqu.execute(tables); - cout<<"Insert [-1 uint_max \"hallo daar\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; + cout<<"Insert [UINT_MAX UINT_MAX \"hallo daar\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; for(const Row &r : res.rows)cout<<"- "<<r<<endl; } @@ -72,22 +86,52 @@ int main(int argc,char **argv){ QueryResult res=iqu.execute(tables); - cout<<"Insert [42 uint_max \"doei\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; + cout<<"Insert [42 UINT_MAX \"doei\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; for(const Row &r : res.rows)cout<<"- "<<r<<endl; } + FINDQUERYEVERYTHING("hoi") + { - FindQuery fqu; - fqu.tablename="hoi"; - RowItem ri; ri.v.rh_uint32=UINT_MAX; - fqu.where.emplace_back(1,ri); + UpdateQuery uqu; + uqu.tablename="hoi"; + + RowItem ri; + ri.v.rh_bytes=new unsigned char[10]; + memcpy(ri.v.rh_bytes,"hallo daar",10); + uqu.where.push_back({2,ri}); + + delete[] ri.v.rh_bytes; + ri.v.rh_int32=20; + uqu.updates.push_back({0,ri}); - QueryResult res=fqu.execute(tables); + QueryResult res=uqu.execute(tables); - cout<<"Find in \"hoi\" where {1}=uint_max, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; + cout<<"Update in \"hoi\" where {2}=\"hallo daar\" {0}->20, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; for(const Row &r : res.rows)cout<<"- "<<r<<endl; } + FINDQUERYEVERYTHING("hoi") + + { + UpdateQuery uqu; + uqu.tablename="hoi"; + + RowItem ri; + ri.v.rh_uint32=UINT_MAX; + uqu.where.push_back({1,ri}); + + ri.v.rh_uint32=12345; + uqu.updates.push_back({1,ri}); + + QueryResult res=uqu.execute(tables); + + cout<<"Update in \"hoi\" where {1}=UINT_MAX {1}->12345, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; + for(const Row &r : res.rows)cout<<"- "<<r<<endl; + } + + FINDQUERYEVERYTHING("hoi") + { DeleteQuery dqu; dqu.tablename="hoi"; @@ -100,17 +144,19 @@ int main(int argc,char **argv){ for(const Row &r : res.rows)cout<<"- "<<r<<endl; } + FINDQUERYEVERYTHING("hoi") + { - FindQuery fqu; - fqu.tablename="hoi"; - RowItem ri; ri.v.rh_uint32=UINT_MAX; - fqu.where.emplace_back(1,ri); + DropQuery drqu; + drqu.tablename="hoi"; - QueryResult res=fqu.execute(tables); + QueryResult res=drqu.execute(tables); - cout<<"Find in \"hoi\" where {1}=uint_max, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; + cout<<"Drop table \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; for(const Row &r : res.rows)cout<<"- "<<r<<endl; } + FINDQUERYEVERYTHING("hoi") + return 0; } |