grammar: Fix using unquoted keywords as DEFAULT values in constraints

This fixes tables like these where a keyword (in this case NO) is used
as an unquoted default value for a column:

CREATE TABLE test(a DEFAULT NO);

See issue #877.
This commit is contained in:
Martin Kleusberg
2017-01-14 14:23:40 +01:00
parent ec9e05ee7f
commit 09b679252e
4 changed files with 70 additions and 54 deletions

View File

@@ -429,6 +429,11 @@ QString identifier(antlr::RefAST ident)
QString concatTextAST(antlr::RefAST t, bool withspace = false)
{
// When this is called for a KEYWORDASTABLENAME token, we must take the child's content to get the actual value
// instead of 'KEYWORDASTABLENAME' as a string. The same applies for KEYWORDASCOLUMNNAME tokens.
if(t != antlr::nullAST && (t->getType() == sqlite3TokenTypes::KEYWORDASTABLENAME || t->getType() == sqlite3TokenTypes::KEYWORDASCOLUMNNAME))
return concatTextAST(t->getFirstChild());
QStringList stext;
while(t != antlr::nullAST)
{