Permalink
Browse files

Make INT UNSIGNED play nicely with soci::rowset<>.

  • Loading branch information...
Pawel Aleksander Fedorynski
Pawel Aleksander Fedorynski committed Apr 11, 2012
1 parent 631977a commit 28eff6744f91c073ded5728f7c7b945ccd5e6e24
Showing with 36 additions and 1 deletion.
  1. +3 −1 src/backends/mysql/statement.cpp
  2. +33 −0 src/backends/mysql/test/test-mysql.cpp
@@ -376,10 +376,12 @@ void mysql_statement_backend::describe_column(int colNum,
{
case FIELD_TYPE_CHAR: //MYSQL_TYPE_TINY:
case FIELD_TYPE_SHORT: //MYSQL_TYPE_SHORT:
case FIELD_TYPE_LONG: //MYSQL_TYPE_LONG:
case FIELD_TYPE_INT24: //MYSQL_TYPE_INT24:
type = dt_integer;
break;
case FIELD_TYPE_LONG: //MYSQL_TYPE_LONG:
type = field->flags & UNSIGNED_FLAG ? dt_long_long : dt_integer;
break;
case FIELD_TYPE_LONGLONG: //MYSQL_TYPE_LONGLONG:
type = dt_long_long;
break;
@@ -493,6 +493,38 @@ void test8()
std::cout << "test 8 passed" << std::endl;
}
struct unsigned_value_table_creator : table_creator_base
{
unsigned_value_table_creator(session & sql)
: table_creator_base(sql)
{
sql << "create table soci_test(val int unsigned)";
}
};
// rowset<> should be able to take INT UNSIGNED.
void test9()
{
{
session sql(backEnd, connectString);
unsigned_value_table_creator tableCreator(sql);
unsigned int mask = 0xffffff00;
sql << "insert into soci_test set val = " << mask;
soci::rowset<> rows(sql.prepare << "select val from soci_test");
int cnt = 0;
for (soci::rowset<>::iterator it = rows.begin(), end = rows.end();
it != end; ++it)
{
cnt++;
}
assert(cnt == 1);
}
std::cout << "test 9 passed" << std::endl;
}
// DDL Creation objects for common tests
struct table_creator_one : public table_creator_base
{
@@ -603,6 +635,7 @@ int main(int argc, char** argv)
test6();
test7();
test8();
test9();
std::cout << "\nOK, all tests passed.\n\n";
return EXIT_SUCCESS;

0 comments on commit 28eff67

Please sign in to comment.