Fix extra spaces in type definitions with parentheses

At the moment space is inserted between all tokens from which a type
consists. This adds extra spaces to types like VARCHAR(5) which become
"VARCHAR ( 5 )" which causes problems in some applications.

This patch modifies the way tokens are concatenated for a type. It makes
sure that the extra space isn't inserted before "(" and ")" and also
after "(".
This commit is contained in:
Jiří Techet
2017-09-20 19:22:47 +02:00
committed by Martin Kleusberg
parent c5e91976c8
commit 18bcbf138f
2 changed files with 23 additions and 2 deletions

View File

@@ -935,7 +935,28 @@ void CreateTableWalker::parsecolumn(Table* table, antlr::RefAST c)
c = c->getNextSibling(); //type?
if(c != antlr::nullAST && c->getType() == sqlite3TokenTypes::TYPE_NAME)
{
type = concatTextAST(c->getFirstChild(), true);
antlr::RefAST t = c->getFirstChild();
if(t != antlr::nullAST)
{
type.clear();
}
while(t != antlr::nullAST)
{
int thisType = t->getType();
type.append(textAST(t));
t = t->getNextSibling();
if(t != antlr::nullAST)
{
int nextType = t->getType();
if(nextType != sqlite3TokenTypes::LPAREN && nextType != sqlite3TokenTypes::RPAREN &&
thisType != sqlite3TokenTypes::LPAREN)
{
type.append(" ");
}
}
}
c = c->getNextSibling();
}