summaryrefslogtreecommitdiff
path: root/dbaccess/qa
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2018-06-26 13:15:07 +0200
committerTamás Bunth <btomi96@gmail.com>2018-07-06 10:37:36 +0200
commita91fe8558b4c8aa163069ebdb117d58239da74f2 (patch)
treee3700a21d2e9866dbcedb9542c4eebb817178834 /dbaccess/qa
parent815b2130c86d5a0aa07bdddb252fbd6ae5d64a62 (diff)
dbahsql: Look for properties only after name
Additional properties in SQL string like "DEFAULT" or "NOT NULL" should be searched only after column name, because what if a column name is "myEvilNOT NULLColumn" Change-Id: I21f0755ba14c7267243d9999f044db4d16963387 Reviewed-on: https://gerrit.libreoffice.org/56462 Tested-by: Jenkins Reviewed-by: Tamás Bunth <btomi96@gmail.com>
Diffstat (limited to 'dbaccess/qa')
-rw-r--r--dbaccess/qa/extras/hsql_schema_import.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/dbaccess/qa/extras/hsql_schema_import.cxx b/dbaccess/qa/extras/hsql_schema_import.cxx
index 892be33d15e7..dd75eb2dc38c 100644
--- a/dbaccess/qa/extras/hsql_schema_import.cxx
+++ b/dbaccess/qa/extras/hsql_schema_import.cxx
@@ -42,6 +42,7 @@ public:
void testIntegerAutoincremental();
void testTimestampWithParam();
void testDefaultValueNow();
+ void testEvilNullColumnName();
// TODO testForeign, testDecomposer
CPPUNIT_TEST_SUITE(HsqlSchemaImportTest);
@@ -53,6 +54,7 @@ public:
CPPUNIT_TEST(testIntegerAutoincremental);
CPPUNIT_TEST(testTimestampWithParam);
CPPUNIT_TEST(testDefaultValueNow);
+ CPPUNIT_TEST(testEvilNullColumnName);
CPPUNIT_TEST_SUITE_END();
};
@@ -197,6 +199,22 @@ void HsqlSchemaImportTest::testDefaultValueNow()
CPPUNIT_ASSERT(fbSql.indexOf("\'NOW\'") > 0); // composed 'NOW'
}
+void HsqlSchemaImportTest::testEvilNullColumnName()
+{
+ OUString sql{ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY, "
+ "\"myEvilNOT NULLName\" "
+ "VARCHAR(20))" };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ CPPUNIT_ASSERT_EQUAL(2_z, columns.size());
+ const ColumnDefinition* colVarchar = lcl_findByType(columns, css::sdbc::DataType::VARCHAR);
+ CPPUNIT_ASSERT(colVarchar != nullptr);
+ CPPUNIT_ASSERT(colVarchar->isNullable());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(HsqlSchemaImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();