-
Notifications
You must be signed in to change notification settings - Fork 161
Changed the way arguments are chained #29 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Major Changes and General Overhaul of the everything. -Refactored exceptions into its own namespace -removed rvalue references where they are not needed -made prepared statments possible -made them reusable -removed some template magic
This is somewhat related to #29 but it got a bit out of hand so i made a new pull for this. try {
{ // scope somewhere else
// creates a database file 'dbfile.db' if it does not exists.
database db("dbfile.db");
db << "drop table if exists test"; // still works as intended cause the database_binder dies at the semicolon
db <<
"create table if not exists test ("
" id integer primary key autoincrement not null,"
" val int"
");";
} // destroy db
database db("dbfile.db");
std::cout << "auto&\n";
auto& pps = db << "select ?"; // get a prepared parsed and ready statment
int test = 4;
pps << test; // set a bound var
pps >> test; // execute and reset statment
pps << 4; // bind a rvalue
pps >> test; // and execute again
auto& pps2 = db << "select 1,2,3,4,5"; // multiple extract test
pps2 >> [](int a, int b, int c, int d, int e) {
std::cout << "L " << a << b << c << d << e << "\n"; // still works as intended
};
} catch(exception& e) { // and here all statments die...
cout << e.what() << endl;
} |
Changes are good 👍 |
-we are c++11 so no funny bussines with make::unique
Added test for chaining and syntax check. Added new operator++ to database_binder it executes and resets the statment, might be extended to something like an iterator someday.
warnings are errors and unused vars are warnings, thats pedantic for tests...
Ok it took my ~20h but now it looks good! I can confirm VC2015 and gcc-5.2.1 and gcc-4.8.2(travis) can someone test clang? Readme follows... ;) |
@Killili i can confirm that all 5 tests ran successfully on clang 7.0.2 |
if (hresult != SQLITE_DONE) { | ||
throw_sqlite_error(hresult); | ||
} | ||
void set_used(bool state) { execution_started = state; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of two functions overload .used() // getter
and .used(bool) // setter
functions
@Killili i have added some comments on the code, these are all just suggestions, |
@Killili Please go one more iteration on readme file ;) |
Thx. Those examples are valid SQL and work, maybe they are a bit short. But i like having examples that dont go through the whole "create table... yada yada" and get right to the point. |
As much as i hate the word "iteration" in the context of documentation its done ;) As for the connection setter: I think that would add inconsistencies to prepared statements, as they have a copy of the connection after they are created. Consider: database db("orig");
auto ps = db << "select ...";
database db2("new");
db.connection(db2.connection());
auto ps2 = db << "select ...";
ps++; // this will run on DB "orig"
ps2++; // this will run on DB "new" I dont get what you mean with "draft" a release so i leave that "honor" to you ;) |
Changed the way arguments are chained #29
@Killili I just wanted to thank you again 😉 |
Major Changes and General Overhaul of the everything.
-Refactored
exceptions into its own namespace
-removed rvalue references where they
are not needed
-made prepared statments possible
-made them
reusable
-removed some template magic