Skip to content

Commit

Permalink
Temporary ODBC debug commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zann1x committed Jun 3, 2022
1 parent 94d3217 commit 02888cc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
11 changes: 7 additions & 4 deletions src/backends/odbc/standard-into-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "soci-exchange-cast.h"
#include "soci-mktime.h"
#include <ctime>
#include <cstdio>
#include <stdint.h>

using namespace soci;
Expand Down Expand Up @@ -67,13 +68,15 @@ void odbc_standard_into_type_backend::define_by_pos(
size = sizeof(uint16_t);
break;
case x_int32:
case x_uint32:
fprintf(stdout, "define_by_pos x_[u]int32\n");
odbcType_ = SQL_C_SLONG;
size = sizeof(int32_t);
break;
case x_uint32:
odbcType_ = SQL_C_ULONG;
size = sizeof(uint32_t);
break;
// case x_uint32:
// odbcType_ = SQL_C_ULONG;
// size = sizeof(uint32_t);
// break;
case x_int64:
if (use_string_for_bigint())
{
Expand Down
13 changes: 8 additions & 5 deletions src/backends/odbc/standard-use-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdio>
#include <sstream>
#include <stdint.h>

Expand Down Expand Up @@ -45,15 +46,17 @@ void* odbc_standard_use_type_backend::prepare_for_bind(
size = sizeof(uint16_t);
break;
case x_int32:
case x_uint32:
fprintf(stdout, "prepare_for_bind x_[u]int32\n");
sqlType = SQL_INTEGER;
cType = SQL_C_SLONG;
size = sizeof(int32_t);
break;
case x_uint32:
sqlType = SQL_INTEGER;
cType = SQL_C_ULONG;
size = sizeof(uint32_t);
break;
// case x_uint32:
// sqlType = SQL_INTEGER;
// cType = SQL_C_ULONG;
// size = sizeof(uint32_t);
// break;
case x_int64:
if (use_string_for_bigint())
{
Expand Down
2 changes: 1 addition & 1 deletion src/backends/odbc/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void odbc_statement_backend::describe_column(int colNum, data_type & type,
type = is_unsigned == SQL_TRUE ? dt_uint16 : dt_int16;
break;
case SQL_INTEGER:
type = is_unsigned == SQL_TRUE ? dt_uint32 : dt_int32;
type = /*is_unsigned == SQL_TRUE ? dt_uint32 :*/ dt_int32;
break;
case SQL_BIGINT:
type = is_unsigned == SQL_TRUE ? dt_uint64 : dt_int64;
Expand Down
16 changes: 11 additions & 5 deletions tests/common-tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <algorithm>
#include <cassert>
#include <clocale>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
Expand Down Expand Up @@ -1758,19 +1759,24 @@ TEST_CASE_METHOD(common_tests, "Use type conversion", "[core][use]")

SECTION("unsigned long")
{
if (!tc_.has_unsigned_type_support())
{
WARN("unsigned long not fully supported by the database, skipping the test.");
return;
}
fprintf(stdout, "start unsigned long\n");
// if (!tc_.has_unsigned_type_support())
// {
// WARN("unsigned long not fully supported by the database, skipping the test.");
// return;
// }

fprintf(stdout, "use unsigned long\n");
unsigned long ul = 4000000000ul;
sql << "insert into soci_test(ul) values(:num)", use(ul);

fprintf(stdout, "into unsigned long\n");
unsigned long ul2 = 0;
sql << "select ul from soci_test", into(ul2);

CHECK(ul2 == 4000000000ul);

fprintf(stdout, "end unsigned long\n");
}

SECTION("int64_t")
Expand Down

0 comments on commit 02888cc

Please sign in to comment.