diff options
author | louiz’ <louiz@louiz.org> | 2017-12-16 16:32:32 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-12-16 16:32:32 +0100 |
commit | 2c4016a4898a050c7f6ebd1843b265e209da1704 (patch) | |
tree | b6c57d4fa446fe588cac6999c498dc1d7587dd9e /src/database/query.cpp | |
parent | aaa9de8fe2c67b67310b7ba78c607bddbf4b25bf (diff) | |
parent | b1f850b6395610c738a8e58abcdf2abfca3edd4e (diff) | |
download | biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.gz biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.bz2 biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.tar.xz biboumi-2c4016a4898a050c7f6ebd1843b265e209da1704.zip |
Merge branch 'postgresql' into 'master'
Add postgresql support
Closes #3237
See merge request louiz/biboumi!18
Diffstat (limited to 'src/database/query.cpp')
-rw-r--r-- | src/database/query.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/database/query.cpp b/src/database/query.cpp index ba63a92..6f305b2 100644 --- a/src/database/query.cpp +++ b/src/database/query.cpp @@ -1,9 +1,29 @@ #include <database/query.hpp> #include <database/column.hpp> -template <> -void add_param<Id>(Query&, const Id&) -{} +void actual_bind(Statement& statement, const std::string& value, int index) +{ + log_debug("binding string:", value, " to col ", index); + statement.bind_text(index, value); +} + +void actual_bind(Statement& statement, const std::size_t value, int index) +{ + log_debug("binding size_t:", value); + statement.bind_int64(index, value); +} + +void actual_bind(Statement& statement, const OptionalBool& value, int index) +{ + log_debug("binding optional_t:", value.to_string()); + if (!value.is_set) + statement.bind_int64(index, 0); + else if (value.value) + statement.bind_int64(index, 1); + else + statement.bind_int64(index, -1); +} + void actual_add_param(Query& query, const std::string& val) { @@ -28,7 +48,8 @@ Query& operator<<(Query& query, const char* str) Query& operator<<(Query& query, const std::string& str) { - query.body += "?"; + query.body += "$" + std::to_string(query.current_param); + query.current_param++; actual_add_param(query, str); return query; } |