Commit 5d7df8ff authored by Ricardo Andrade's avatar Ricardo Andrade

Fixes the use of PostgreSQL-style casts with ORM (soci::values)

parent 21caa358
......@@ -695,6 +695,15 @@ void test_statement_prepare_failure()
std::cout << "test_statement_prepare_failure passed" << std::endl;
}
// Test the support of PostgreSQL-style casts with ORM
void test_orm_cast()
{
session sql(backEnd, connectString);
values v;
v.set("a", 1);
sql << "select :a::int", use(v); // Must not throw an exception!
}
//
// Support for soci Common Tests
//
......@@ -824,6 +833,7 @@ int main(int argc, char** argv)
test_bytea();
test_json();
test_statement_prepare_failure();
test_orm_cast();
std::cout << "\nOK, all tests passed.\n\n";
......
......@@ -115,7 +115,8 @@ void statement_impl::bind(values & values)
query_[pos + placeholder.size()] : '\0';
if (nextChar == ' ' || nextChar == ',' || nextChar == ';' ||
nextChar == '\0' || nextChar == ')')
nextChar == '\0' || nextChar == ')' ||
nextChar == ':') // This last specific for PostgreSQL-style casts.
{
int position = static_cast<int>(uses_.size());
(*it)->bind(*this, position);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment