grammar: Fix parsing of more complex expressions

See issue #1950.
This commit is contained in:
Martin Kleusberg
2019-08-01 11:14:30 +02:00
parent 263c28e6f4
commit 05181df8b8
4 changed files with 17 additions and 2 deletions

View File

@@ -518,3 +518,17 @@ void TestTable::moduloOperator()
QCOMPARE(tab.fields.at(0).type(), "INTEGER");
QCOMPARE(tab.fields.at(0).defaultValue(), "(7%2)");
}
void TestTable::complexExpression()
{
std::string sql = "CREATE TABLE test(\n"
"uuid INTEGER DEFAULT (hex(randomblob(4))||'-'||hex(randomblob(2))||'-'||'4'||substr(hex(randomblob(2)),2)||'-'||substr('AB89',1+(abs(random())%4),1)||substr(hex(randomblob(2)),2)||'-'||hex(randomblob(6)))\n"
");";
Table tab = *(std::dynamic_pointer_cast<sqlb::Table>(Table::parseSQL(sql)));
QCOMPARE(tab.name(), "test");
QCOMPARE(tab.fields.at(0).name(), "uuid");
QCOMPARE(tab.fields.at(0).type(), "INTEGER");
QCOMPARE(tab.fields.at(0).defaultValue(), "(hex(randomblob(4))||'-'||hex(randomblob(2))||'-'||'4'||substr(hex(randomblob(2)),2)||'-'||substr('AB89',1+(abs(random())%4),1)||substr(hex(randomblob(2)),2)||'-'||hex(randomblob(6)))");
}

View File

@@ -38,6 +38,7 @@ private slots:
void datetimeExpression();
void extraParentheses();
void moduloOperator();
void complexExpression();
};
#endif