correctly extract check expression from AST

This commit is contained in:
Peinthor Rene
2014-06-11 22:48:43 +02:00
parent 55d8c9f9d8
commit f246ddde1e
2 changed files with 6 additions and 5 deletions

View File

@@ -243,15 +243,15 @@ QString identifier(antlr::RefAST ident)
return sident;
}
QString concatTextAST(antlr::RefAST t)
QString concatTextAST(antlr::RefAST t, bool withspace = false)
{
QString stext;
QStringList stext;
while(t != antlr::nullAST)
{
stext.append(t->getText().c_str());
t = t->getNextSibling();
}
return stext;
return stext.join(withspace ? " " : "");
}
}
@@ -388,10 +388,11 @@ void CreateTableWalker::parsecolumn(FieldPtr& f, antlr::RefAST c)
case sqlite3TokenTypes::CHECK:
{
con = con->getNextSibling(); //LPAREN
check = concatTextAST(con);
check = concatTextAST(con, true);
// remove parenthesis
check.remove(check.length()-1, 1);
check.remove(0,1);
check = check.trimmed();
}
break;
case sqlite3TokenTypes::DEFAULT:

View File

@@ -218,7 +218,7 @@ void TestTable::createTableWithIn()
Table tab = Table::parseSQL(sSQL);
QVERIFY(tab.name() == "not_working");
QVERIFY(tab.fields().at(1)->check() == "value IN ('a', 'b', 'c')");
QVERIFY(tab.fields().at(1)->check() == "value IN ( 'a' , 'b' , 'c' )");
}
QTEST_MAIN(TestTable)