Add postgresql support
This commit is contained in:
+25
-4
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user