Commit 45eaff9e authored by Maciej Sobczak's avatar Maciej Sobczak

Added handling of big string in DDL.

parent f7b11ca7
......@@ -345,7 +345,15 @@ struct oracle_session_backend : details::session_backend
case dt_string:
{
std::ostringstream oss;
oss << "varchar(" << precision << ")";
if (precision == 0)
{
oss << "clob";
}
else
{
oss << "varchar(" << precision << ")";
}
res += oss.str();
}
......
......@@ -326,7 +326,15 @@ public:
case dt_string:
{
std::ostringstream oss;
oss << "varchar(" << precision << ")";
if (precision == 0)
{
oss << "text";
}
else
{
oss << "varchar(" << precision << ")";
}
res += oss.str();
}
......
......@@ -1188,6 +1188,7 @@ TEST_CASE("Oracle DDL with metadata", "[oracle][ddl]")
}
sql.add_column(ddl_t1, "K", soci::dt_integer);
sql.add_column(ddl_t1, "BIG", soci::dt_string, 0); // "unlimited" length -> CLOB
sql.drop_column(ddl_t1, "I");
// or with constraint as in t2:
......@@ -1224,6 +1225,7 @@ TEST_CASE("Oracle DDL with metadata", "[oracle][ddl]")
i_found = false;
j_found = false;
bool k_found = false;
bool big_found = false;
other_found = false;
soci::statement st3 = (sql.prepare_column_descriptions(ddl_t1), into(ci));
st3.execute();
......@@ -1241,6 +1243,12 @@ TEST_CASE("Oracle DDL with metadata", "[oracle][ddl]")
CHECK(ci.nullable);
k_found = true;
}
else if (ci.name == "BIG")
{
CHECK(ci.type == soci::dt_string);
CHECK(ci.precision == 0); // "unlimited" for strings
big_found = true;
}
else
{
other_found = true;
......@@ -1250,6 +1258,7 @@ TEST_CASE("Oracle DDL with metadata", "[oracle][ddl]")
CHECK(i_found == false);
CHECK(j_found);
CHECK(k_found);
CHECK(big_found);
CHECK(other_found == false);
// check if ddl_t2 has the right structure:
......
......@@ -805,6 +805,7 @@ TEST_CASE("PostgreSQL DDL with metadata", "[postgresql][ddl]")
}
sql.add_column(ddl_t1, "k", soci::dt_integer);
sql.add_column(ddl_t1, "big", soci::dt_string, 0); // "unlimited" length -> text
sql.drop_column(ddl_t1, "i");
// or with constraint as in t2:
......@@ -841,6 +842,7 @@ TEST_CASE("PostgreSQL DDL with metadata", "[postgresql][ddl]")
i_found = false;
j_found = false;
bool k_found = false;
bool big_found = false;
other_found = false;
soci::statement st3 = (sql.prepare_column_descriptions(ddl_t1), into(ci));
st3.execute();
......@@ -858,6 +860,12 @@ TEST_CASE("PostgreSQL DDL with metadata", "[postgresql][ddl]")
CHECK(ci.nullable);
k_found = true;
}
else if (ci.name == "big")
{
CHECK(ci.type == soci::dt_string);
CHECK(ci.precision == 0); // "unlimited" for strings
big_found = true;
}
else
{
other_found = true;
......@@ -867,6 +875,7 @@ TEST_CASE("PostgreSQL DDL with metadata", "[postgresql][ddl]")
CHECK(i_found == false);
CHECK(j_found);
CHECK(k_found);
CHECK(big_found);
CHECK(other_found == false);
// check if ddl_t2 has the right structure:
......
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