IGNITE-5939: ODBC: SQLColAttributes now works with legacy attribute codes.
authorIgor Sapego <isapego@gridgain.com>
Fri, 4 Aug 2017 15:34:27 +0000 (18:34 +0300)
committerIgor Sapego <isapego@gridgain.com>
Fri, 4 Aug 2017 15:35:26 +0000 (18:35 +0300)
modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp
modules/platforms/cpp/odbc/src/meta/column_meta.cpp

index 5b7ae59..454a989 100644 (file)
@@ -186,4 +186,55 @@ BOOST_AUTO_TEST_CASE(TestGetTypeInfoAllTypes)
         BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
 }
 
+BOOST_AUTO_TEST_CASE(TestColAttributesColumnLength)
+{
+    Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache");
+
+    SQLCHAR req[] = "select strField from TestType";
+    SQLExecDirect(stmt, req, SQL_NTS);
+
+    SQLLEN intVal;
+    SQLCHAR strBuf[1024];
+    SQLSMALLINT strLen;
+
+    SQLRETURN ret = SQLColAttribute(stmt, 1, SQL_COLUMN_LENGTH, strBuf, sizeof(strBuf), &strLen, &intVal);
+
+    if (!SQL_SUCCEEDED(ret))
+        BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+}
+
+BOOST_AUTO_TEST_CASE(TestColAttributesColumnPresicion)
+{
+    Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache");
+
+    SQLCHAR req[] = "select strField from TestType";
+    SQLExecDirect(stmt, req, SQL_NTS);
+
+    SQLLEN intVal;
+    SQLCHAR strBuf[1024];
+    SQLSMALLINT strLen;
+
+    SQLRETURN ret = SQLColAttribute(stmt, 1, SQL_COLUMN_PRECISION, strBuf, sizeof(strBuf), &strLen, &intVal);
+
+    if (!SQL_SUCCEEDED(ret))
+        BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+}
+
+BOOST_AUTO_TEST_CASE(TestColAttributesColumnScale)
+{
+    Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache");
+
+    SQLCHAR req[] = "select strField from TestType";
+    SQLExecDirect(stmt, req, SQL_NTS);
+
+    SQLLEN intVal;
+    SQLCHAR strBuf[1024];
+    SQLSMALLINT strLen;
+
+    SQLRETURN ret = SQLColAttribute(stmt, 1, SQL_COLUMN_SCALE, strBuf, sizeof(strBuf), &strLen, &intVal);
+
+    if (!SQL_SUCCEEDED(ret))
+        BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+}
+
 BOOST_AUTO_TEST_SUITE_END()
index 12dbfc1..97fdf80 100644 (file)
@@ -179,6 +179,7 @@ namespace ignite
 
                     case SQL_DESC_LENGTH:
                     case SQL_DESC_OCTET_LENGTH:
+                    case SQL_COLUMN_LENGTH:
                     {
                         value = type_traits::BinaryTypeTransferLength(dataType);
 
@@ -200,6 +201,7 @@ namespace ignite
                     }
 
                     case SQL_DESC_PRECISION:
+                    case SQL_COLUMN_PRECISION:
                     {
                         value = type_traits::BinaryTypeColumnSize(dataType);
 
@@ -207,6 +209,7 @@ namespace ignite
                     }
 
                     case SQL_DESC_SCALE:
+                    case SQL_COLUMN_SCALE:
                     {
                         value = type_traits::BinaryTypeDecimalDigits(dataType);