Skip to content

Commit

Permalink
grammar: Correctly parse double quotes as a means of escaping
Browse files Browse the repository at this point in the history
This should parse the table and column names correctly by removing any
double quote characters and replacing them by a single one.

See issue #387.
  • Loading branch information
MKleusberg committed Aug 18, 2015
1 parent 631979c commit dce47b3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/sqlitetypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,20 @@ QString identifier(antlr::RefAST ident)
ident->getType() == Sqlite3Lexer::QUOTEDLITERAL ||
ident->getType() == sqlite3TokenTypes::STRINGLITERAL)
{
// Remember the way the identifier is quoted
QChar quoteChar = sident.at(0);

// Remove first and final character, i.e. the quotes
sident.remove(0, 1);
sident.remove(sident.length() - 1, 1);
sident.chop(1);

// Replace all remaining occurences of two succeeding quote characters and replace them
// by a single instance. This is done because two quotes can be used as a means of escaping
// the quote character, thus only the visual representation has its two quotes, the actual
// name contains only one.
sident.replace(QString(quoteChar) + quoteChar, quoteChar);
}

return sident;
}

Expand Down

0 comments on commit dce47b3

Please sign in to comment.