Add postgresql support

This commit is contained in:
louiz’
2017-12-02 20:08:47 +01:00
parent 5b27cee972
commit 0168b96b79
32 changed files with 1008 additions and 342 deletions
+25 -4
View File
@@ -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;
}