diff --git a/test/odbc/psqlodbc/test_pg_bpchar.cpp b/test/odbc/psqlodbc/test_pg_bpchar.cpp index 380971d37e..ab9f61be33 100644 --- a/test/odbc/psqlodbc/test_pg_bpchar.cpp +++ b/test/odbc/psqlodbc/test_pg_bpchar.cpp @@ -7,17 +7,17 @@ const string COL2_NAME = "data"; const string DATATYPE = "sys.bpchar"; -vector> TABLE_COLUMNS_1 = { +const vector> TABLE_COLUMNS_1 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(1)"} }; -vector> TABLE_COLUMNS_4000 = { +const vector> TABLE_COLUMNS_4000 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(4000)"} }; -vector> TABLE_COLUMNS_20 = { +const vector> TABLE_COLUMNS_20 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(20)"} }; diff --git a/test/odbc/psqlodbc/test_pg_nchar.cpp b/test/odbc/psqlodbc/test_pg_nchar.cpp index 82e1a16899..018efdf670 100644 --- a/test/odbc/psqlodbc/test_pg_nchar.cpp +++ b/test/odbc/psqlodbc/test_pg_nchar.cpp @@ -7,17 +7,17 @@ const string COL2_NAME = "data"; const string DATATYPE = "sys.nchar"; -vector> TABLE_COLUMNS_1 = { +const vector> TABLE_COLUMNS_1 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(1)"} }; -vector> TABLE_COLUMNS_4000 = { +const vector> TABLE_COLUMNS_4000 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(4000)"} }; -vector> TABLE_COLUMNS_20 = { +const vector> TABLE_COLUMNS_20 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(20)"} }; diff --git a/test/odbc/psqlodbc/test_pg_ntext.cpp b/test/odbc/psqlodbc/test_pg_ntext.cpp new file mode 100644 index 0000000000..25f1fadd50 --- /dev/null +++ b/test/odbc/psqlodbc/test_pg_ntext.cpp @@ -0,0 +1,361 @@ +#include "psqlodbc_tests_common.h" + +const string TABLE_NAME = "master_dbo.ntext_table_odbc_test"; +const string COL1_NAME = "pk"; +const string COL2_NAME = "data"; +const string DATATYPE = "sys.ntext"; +const string VIEW_NAME = "master_dbo.ntext_view_odbc_test"; + +const string STRING_4000 = "TQR6vCl9UH5qg2UEJMleJaa3yToVaUbhhxQ7e0SgHjrKg1TYvyUzTrLlO64uPEj572WjgLK6X5muDjK64tcWBr4bBp8hjnV" + "ftzfLIYFEFCK0nAIuGhnjHIiB8Qc3ywbWqARbphlli11dyPOJi5KRTPMh1c5zMxyXEiyDhLxP5Hs96hIHOgV29e06vBaDJ2xSE2Pve32aX8EDLFDOial7t7ya2CluTP" + "lL0TMH8Tbcb58if64Hp4Db5clDdD3HdcFAGPJpkI69IhZHbJZXZLrYJ1iP00Nt63DPhEMOgrKeKzv4ByEjWKYkbCqAFqG5MyQ98QotkKgLwTYcn2x9Zv9IqKTFFBg5I" + "Yl3yQByGke2RMLjImDqYnMbkPzcAhSU25VuhM4sZ6K5vvOyPzIx1vmpbgX7lj8CDwFFIbMjghJLEIsqRBA2gQ6RXYLbsj62JqedNVrJiByhkrfSybsEG9o24UXT9MJZ" + "dthKPjIU7gDKSB6LIiO9axy9z93Xc7CuyxHHx9eHFXgHO9ZqyBwU24iUri9chQFVUGyPtHwSFtMqjtVBrzj04jXnc7WQPWKGzcbWBNnApQah1glDfXJoDGzNHcay7pD" + "E2OVgbF5uGVWDzXrj7o5ZLSLgwbRwgNfbb3TAwofa9Ju1XyRkvHBXPEUieYAR4Uvu1WAFHsvOlNqarmgECTon5zbSjYEA7oBhhZ4oimJyaHAE3xXHOcbOoComfzLdMz" + "hnLzoAQj4RHkfMQxx84ADJqIBOi3lW313NdFpEzDD2ZCiAynPVJHEbWAlllp4YRJIMe3cbPvIDw6C2uUHgifgwy1F61clEFzG2Z9QTM7mOBDBOldEjYeAoOLWPZlpyr" + "CNL6MgV2yj0MdIEFUzITJ68kAWXd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H0CPnV2i9qLCclXi6I3ZX7rCTq" + "b7VnxLJ1KYS0wT8Fhh4jR1dXQq9SyvAMnQmx0Qm0ufJvTT1LC4nWN7OInFJXUtI4TY2fvpUm2pnXkTYtwMQVACX0oKsIVEkXuxrSB7ozA4n0q0ym751Pj4U8hNuRPv4ZP" + "ZXVW5gcQj7jtGfIvLHArPOJEPpyquljImYjSifCvfwxiHpRgjaHyYLQczOAVEs9ibflD1Chb7Ogd1I3UyqbQEgAOwzgXJTpeCfvrQI02Zqa43jc3Ah0fcSggpi2iil7XY" + "W658CbpzwT2rMNyPFuWWYtHsQibx3es4soysasVz8AMQw55XJsRCK7Fz8KRaMIVrpp8jt1dIs26eUGcV0TA1NxdTdF7ZlgVlaxqswtaQ2aMfvzVmkM0aAfiH0YB7JlJJa" + "1u0Z7UsQXlBAKkf9T2vNjUCe14geYyLMusk45KJvGVGJzZ12YGuZ8NRTVlaHDuEYsizKw6aZRBBjP5DCBZZznU2xsUerJnWt9rEooGTraF0X4tnU6JCZVpTF4WV2iDAm2" + "OgNCfo6qt5wOsXoAbtG4BxV6SjekfufQW0OSiIIEOvOuDcnYfa4q80ibBt642k6WVc6ExZT9y9KvlfNFzfmqQHk6OkhqQVSWkCfTTSCyC5bpskW2p8hPpZAISEI49GMVM" + "dKPMgxXq6XHYjdGnI5titO9a9Fw0ud1vGZDLV6PhlVl7Lelsn8WxRnHufoXvK2xNVXXuPd6sd5gqr90z3B1oV1sNRQRIIRfHSxAx1gmPMSuNWooRz9zVEYfDegrIKZFQb" + "7a5RbDg2OWxrWcX4KmfsgIozSpCGUoMv15WHuGeZrPvAmk3nyr7BrMhYqvMg13JceO82rER67IOxVXTM9KnVwlOxbmSnH1w3CzWrZVqzpKY5W0UPZB2tQXezqqMFHRhWG" + "L5KUxdTyPGBrTIyo1VesEBvkqgKzIiROBK6UVaP24WGl74nyGX5YGg9Cqs"; +const string STRING_1 = "a"; +const string STRING_20 = "0123456789abcdefghij"; + +const vector> TABLE_COLUMNS = { + {COL1_NAME, " int PRIMARY KEY"}, + {COL2_NAME, DATATYPE} +}; + +class PSQL_DataTypes_Ntext: public testing::Test { + void SetUp() override { + if(!Drivers::DriverExists(ServerType::PSQL)) { + GTEST_SKIP() << "PSQL Driver not present: skipping all tests for this fixture."; + } + + OdbcHandler test_setup(Drivers::GetDriver(ServerType::PSQL)); + test_setup.ConnectAndExecQuery(DropObjectStatement("TABLE", TABLE_NAME)); + } + + void TearDown() override { + if(!Drivers::DriverExists(ServerType::PSQL)) { + GTEST_SKIP() << "PSQL Driver not present: skipping tear down."; + } + OdbcHandler test_cleanup(Drivers::GetDriver(ServerType::PSQL)); + test_cleanup.ConnectAndExecQuery(DropObjectStatement("VIEW", VIEW_NAME)); + test_cleanup.ExecQuery(DropObjectStatement("TABLE", TABLE_NAME)); + } + +}; + +TEST_F(PSQL_DataTypes_Ntext, Table_Creation) { + const vector LENGTH_EXPECTED = {4, 8190}; + const vector PRECISION_EXPECTED = {0, 0}; + const vector SCALE_EXPECTED = {0, 0}; + const vector NAME_EXPECTED = {"int4", "text"}; + const vector PREFIX_EXPECTED = {"int4", "'"}; + const vector SUFFIX_EXPECTED = {"int4", "'"}; + + const vector IS_CASE_SENSITIVE = {0, 1}; + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS); + testCommonCharColumnAttributes(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS.size(), COL1_NAME, LENGTH_EXPECTED, + PRECISION_EXPECTED, SCALE_EXPECTED, NAME_EXPECTED, IS_CASE_SENSITIVE, PREFIX_EXPECTED, SUFFIX_EXPECTED); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, Table_Create_Fail) { + const vector>> invalid_columns { + {{"invalid1", DATATYPE + "(4)"}} // Cannot specify a column width on data type datatime. + }; + + // Assert that table creation will always fail with invalid column definitions + testTableCreationFailure(ServerType::PSQL, TABLE_NAME, invalid_columns); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, Insertion_Success) { + const vector INSERTED_VALUES = { + "NULL", // NULL value + STRING_1, + STRING_4000, + STRING_20, + "" // blank value + }; + + const vector expected = { + "NULL", // NULL value + STRING_1, + STRING_4000, + STRING_20, + "" // blank value + }; + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS); + testInsertionSuccess(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, expected); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, Update_Success) { + const vector INSERTED_VALUES = { + "a" + }; + + const vector UPDATED_VALUES = { + "NULL", + STRING_1, + STRING_20, + STRING_4000, + "" // blank value + }; + + const vector expected_UPDATED_VALUES = { + "NULL", + STRING_1, + STRING_20, + STRING_4000, + "" // blank value + }; + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS); + testInsertionSuccess(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, INSERTED_VALUES); + testUpdateSuccess(ServerType::PSQL, TABLE_NAME, COL1_NAME, COL2_NAME, UPDATED_VALUES, expected_UPDATED_VALUES); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, View_creation) { + const vector INSERTED_VALUES = { + "NULL", // NULL values + STRING_1, + STRING_20, + STRING_4000, + "" // blank value + }; + + const string VIEW_QUERY = "SELECT * FROM " + TABLE_NAME; + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS); + testInsertionSuccess(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, INSERTED_VALUES); + + createView(ServerType::PSQL, VIEW_NAME, VIEW_QUERY); + verifyValuesInObject(ServerType::PSQL, VIEW_NAME, COL1_NAME, INSERTED_VALUES, INSERTED_VALUES); + + dropObject(ServerType::PSQL, "VIEW", VIEW_NAME); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, Table_Single_Primary_Keys) { + + const vector> TABLE_COLUMNS = { + {COL1_NAME, "INT"}, + {COL2_NAME, DATATYPE} + }; + + const string PKTABLE_NAME = TABLE_NAME.substr(TABLE_NAME.find('.') + 1, TABLE_NAME.length()); + const string SCHEMA_NAME = TABLE_NAME.substr(0, TABLE_NAME.find('.')); + + const vector PK_COLUMNS = { + COL2_NAME + }; + + string tableConstraints = createTableConstraint("PRIMARY KEY ", PK_COLUMNS); + + const vector INSERTED_VALUES = { + STRING_1, + STRING_20, + "" // blank value + }; + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS, tableConstraints); + testPrimaryKeys(ServerType::PSQL, SCHEMA_NAME, PKTABLE_NAME, PK_COLUMNS); + testInsertionSuccess(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, INSERTED_VALUES); + testInsertionFailure(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, false, 0, false); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, Table_Composite_Primary_Keys) { + const vector> TABLE_COLUMNS = { + {COL1_NAME, "INT"}, + {COL2_NAME, DATATYPE} + }; + const string PKTABLE_NAME = TABLE_NAME.substr(TABLE_NAME.find('.') + 1, TABLE_NAME.length()); + const string SCHEMA_NAME = TABLE_NAME.substr(0, TABLE_NAME.find('.')); + + const vector PK_COLUMNS = { + COL1_NAME, + COL2_NAME + }; + + string tableConstraints = createTableConstraint("PRIMARY KEY ", PK_COLUMNS); + + const vector INSERTED_VALUES = { + STRING_1, + STRING_20, + "" // blank value + }; + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS, tableConstraints); + testPrimaryKeys(ServerType::PSQL, SCHEMA_NAME, PKTABLE_NAME, PK_COLUMNS); + testInsertionSuccess(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, INSERTED_VALUES); + testInsertionFailure(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, false, 0, false); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, Table_Unique_Constraint) { + + const vector> TABLE_COLUMNS = { + {COL1_NAME, "INT"}, + {COL2_NAME, DATATYPE} + }; + + const vector UNIQUE_COLUMNS = { + COL2_NAME + }; + + string tableConstraints = createTableConstraint("UNIQUE", UNIQUE_COLUMNS); + + // Insert valid values into the table and assert affected rows + const vector INSERTED_VALUES = { + STRING_1, + STRING_20, + "" // blank value + }; + + // table name without the schema + const string tableName = TABLE_NAME.substr(TABLE_NAME.find('.') + 1, TABLE_NAME.length()); + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS, tableConstraints); + testUniqueConstraint(ServerType::PSQL, tableName, UNIQUE_COLUMNS); + testInsertionSuccess(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, INSERTED_VALUES); + testInsertionFailure(ServerType::PSQL, TABLE_NAME, COL1_NAME, INSERTED_VALUES, false, INSERTED_VALUES.size(), false); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, Comparison_Operators) { + const vector> TABLE_COLUMNS = { + {COL1_NAME, DATATYPE + " PRIMARY KEY"}, + {COL2_NAME, DATATYPE} + }; + + const vector INSERTED_PK = { + "One", + "BBBB", + "CCCC" + }; + + const vector INSERTED_DATA = { + "One", + "AAAA", + "DDDD" + }; + const int NUM_OF_DATA = INSERTED_DATA.size(); + + // insertString initialization + string insertString{}; + string comma{}; + for (int i = 0; i < NUM_OF_DATA; i++) { + insertString += comma + "(\'" + INSERTED_PK[i] + "\',\'" + INSERTED_DATA[i] + "\')"; + comma = ","; + } + + const vector OPERATIONS_QUERY = { + COL1_NAME + "=" + COL2_NAME, + COL1_NAME + "<>" + COL2_NAME, + COL1_NAME + "<" + COL2_NAME, + COL1_NAME + "<=" + COL2_NAME, + COL1_NAME + ">" + COL2_NAME, + COL1_NAME + ">=" + COL2_NAME + }; + + // initialization of expected_results + vector> expected_results = {}; + + for (int i = 0; i < NUM_OF_DATA; i++) { + expected_results.push_back({}); + const char *date_1 = INSERTED_PK[i].data(); + const char *date_2 = INSERTED_DATA[i].data(); + expected_results[i].push_back(strcmp(date_1, date_2) == 0 ? '1' : '0'); + expected_results[i].push_back(strcmp(date_1, date_2) != 0 ? '1' : '0'); + expected_results[i].push_back(strcmp(date_1, date_2) < 0 ? '1' : '0'); + expected_results[i].push_back(strcmp(date_1, date_2) <= 0 ? '1' : '0'); + expected_results[i].push_back(strcmp(date_1, date_2) > 0 ? '1' : '0'); + expected_results[i].push_back(strcmp(date_1, date_2) >= 0 ? '1' : '0'); + } + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS); + insertValuesInTable(ServerType::PSQL, TABLE_NAME, insertString, NUM_OF_DATA); + testComparisonOperators(ServerType::PSQL, TABLE_NAME, COL1_NAME, COL2_NAME, INSERTED_PK, INSERTED_DATA, + OPERATIONS_QUERY, expected_results, false, true); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} + +TEST_F(PSQL_DataTypes_Ntext, String_Operators) { + + const vector INSERTED_DATA = { + " One Two!" + }; + + const vector INSERTED_PK = { + "1" + }; + + const int NUM_OF_DATA = INSERTED_DATA.size(); + + // insertString initialization + string insertString{}; + string comma{}; + for (int i = 0; i < NUM_OF_DATA; i++) { + insertString += comma + "(" + INSERTED_PK[i] + ",\'" + INSERTED_DATA[i] + "\')"; + comma = ","; + } + + const vector OPERATIONS_QUERY = { + "lower(" + COL2_NAME + ")", + "upper(" + COL2_NAME + ")", + COL1_NAME +"||" + COL2_NAME, + "Trim(" + COL2_NAME + ")", + "Trim(TRAILING '!' from " + COL2_NAME + ")", + "Trim(TRAILING ' ' from " + COL2_NAME + ")" + }; + const int NUM_OF_OPERATIONS = OPERATIONS_QUERY.size(); + + // initialization of EXPECTED_RESULTS + vector> EXPECTED_RESULTS = {}; + + for(int i = 0; i < NUM_OF_OPERATIONS; i++){ + EXPECTED_RESULTS.push_back({}); + } + + string current = INSERTED_DATA[0]; + transform(current.begin(), current.end(), current.begin(), ::tolower); + EXPECTED_RESULTS[0].push_back(current); + EXPECTED_RESULTS[1].push_back(" ONE TWO!"); + EXPECTED_RESULTS[2].push_back(INSERTED_PK[0] + INSERTED_DATA[0]); + EXPECTED_RESULTS[3].push_back("One Two!"); + EXPECTED_RESULTS[4].push_back(" One Two"); + EXPECTED_RESULTS[5].push_back(" One Two!"); + + createTable(ServerType::PSQL, TABLE_NAME, TABLE_COLUMNS); + insertValuesInTable(ServerType::PSQL, TABLE_NAME, insertString, NUM_OF_DATA); + testStringFunctions(ServerType::PSQL, TABLE_NAME, OPERATIONS_QUERY, EXPECTED_RESULTS, NUM_OF_DATA, COL1_NAME); + dropObject(ServerType::PSQL, "TABLE", TABLE_NAME); +} diff --git a/test/odbc/psqlodbc/test_pg_varchar.cpp b/test/odbc/psqlodbc/test_pg_varchar.cpp index 7dba035a0e..e88439f117 100644 --- a/test/odbc/psqlodbc/test_pg_varchar.cpp +++ b/test/odbc/psqlodbc/test_pg_varchar.cpp @@ -7,17 +7,17 @@ const string COL2_NAME = "data"; const string DATATYPE = "sys.varchar"; -vector> TABLE_COLUMNS_1 = { +const vector> TABLE_COLUMNS_1 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(1)"} }; -vector> TABLE_COLUMNS_8000 = { +const vector> TABLE_COLUMNS_8000 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(8000)"} }; -vector> TABLE_COLUMNS_20 = { +const vector> TABLE_COLUMNS_20 = { {COL1_NAME, " int PRIMARY KEY"}, {COL2_NAME, DATATYPE + "(20)"} };