mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-13 07:19:48 -05:00
@@ -2575,7 +2575,7 @@ void Sqlite3Parser::expr() {
|
||||
astFactory->addASTChild(currentAST, tmp119_AST);
|
||||
}
|
||||
match(LPAREN);
|
||||
subexpr();
|
||||
expr();
|
||||
if (inputState->guessing==0) {
|
||||
astFactory->addASTChild( currentAST, returnAST );
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ functionname
|
||||
expr
|
||||
:
|
||||
( LPAREN (((subexpr (COMMA subexpr)+ RPAREN binaryoperator LPAREN subexpr (COMMA subexpr)+) | (expr)) RPAREN) ((AND | OR) expr)* )
|
||||
| ( subexpr ((binaryoperator | AND | OR) (subexpr | LPAREN subexpr RPAREN) )* )
|
||||
| ( subexpr ((binaryoperator | AND | OR) (subexpr | LPAREN expr RPAREN) )* )
|
||||
;
|
||||
|
||||
subexpr
|
||||
|
||||
@@ -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)))");
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ private slots:
|
||||
void datetimeExpression();
|
||||
void extraParentheses();
|
||||
void moduloOperator();
|
||||
void complexExpression();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user