mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Address PR comments: also check for literal EQ columnref
This commit is contained in:
parent
b4ca6bca6e
commit
dccbed2cc0
@ -716,7 +716,7 @@ bool QgsExpressionNodeBinaryOperator::prepareNode( QgsExpression *parent, const
|
||||
if ( op->op() == boEQ )
|
||||
{
|
||||
// If left is a column ref and right is a literal, collect
|
||||
if ( dynamic_cast<QgsExpressionNodeColumnRef *>( op->opLeft() ) && dynamic_cast<QgsExpressionNodeLiteral *>( op->opRight() ) )
|
||||
if ( ( dynamic_cast<QgsExpressionNodeColumnRef *>( op->opLeft() ) && dynamic_cast<QgsExpressionNodeLiteral *>( op->opRight() ) ) )
|
||||
{
|
||||
const QString fieldName = op->opLeft()->dump();
|
||||
if ( !orValuesMap.contains( fieldName ) )
|
||||
@ -727,6 +727,17 @@ bool QgsExpressionNodeBinaryOperator::prepareNode( QgsExpression *parent, const
|
||||
orValuesMap[fieldName].append( op->opRight()->clone() );
|
||||
return true;
|
||||
}
|
||||
else if ( ( dynamic_cast<QgsExpressionNodeColumnRef *>( op->opRight() ) && dynamic_cast<QgsExpressionNodeLiteral *>( op->opLeft() ) ) )
|
||||
{
|
||||
const QString fieldName = op->opRight()->dump();
|
||||
if ( !orValuesMap.contains( fieldName ) )
|
||||
{
|
||||
orFieldNames.append( fieldName );
|
||||
orValuesMap.insert( fieldName, QgsExpressionNode::NodeList() );
|
||||
}
|
||||
orValuesMap[fieldName].append( op->opLeft()->clone() );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5600,6 +5600,7 @@ class TestQgsExpression: public QObject
|
||||
QTest::newRow( "simple3 mixed" ) << QStringLiteral( "field = 'value' OR field = 'value2' OR field2 = 'value3'" ) << QStringLiteral( "field IN ('value', 'value2') OR field2 = 'value3'" );
|
||||
QTest::newRow( "simple3 mixed 2" ) << QStringLiteral( "field2 = 'value3' OR field = 'value1' OR field = 'value2'" ) << QStringLiteral( "field2 = 'value3' OR field IN ('value1', 'value2')" );
|
||||
QTest::newRow( "simple3 mixed 3" ) << QStringLiteral( "field = 'value1' OR field2 = 'value3' OR field = 'value2'" ) << QStringLiteral( "field IN ('value1', 'value2') OR field2 = 'value3'" );
|
||||
QTest::newRow( "simple mixed order" ) << QStringLiteral( "field = 'value' OR 'value2' = field OR field = 'value3'" ) << QStringLiteral( "field IN ('value', 'value2', 'value3')" );
|
||||
|
||||
// test with IN
|
||||
QTest::newRow( "simple IN" ) << QStringLiteral( "field IN ('value', 'value2') OR field = 'value3'" ) << QStringLiteral( "field IN ('value', 'value2', 'value3')" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user