Skip to content
Permalink
Browse files
Handle arrays in QgsExpression::quotedValue
  • Loading branch information
arnaud-morvan committed Mar 22, 2017
1 parent 25fe2b0 commit eeb1283018ab20bcb8cff98eaab9e6b06db018c1
Showing with 12 additions and 0 deletions.
  1. +10 −0 src/core/qgsexpression.cpp
  2. +2 −0 tests/src/core/testqgsexpression.cpp
@@ -4225,6 +4225,16 @@ QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type )
case QVariant::Bool:
return value.toBool() ? "TRUE" : "FALSE";

case QVariant::List:
{
QStringList quotedValues;
Q_FOREACH ( const QVariant &v, value.toList() )
{
quotedValues += quotedValue( v );
}
return QStringLiteral( "array( %1 )" ).arg( quotedValues.join( ", " ) );
}

default:
case QVariant::String:
return quotedString( value.toString() );
@@ -2539,6 +2539,8 @@ class TestQgsExpression: public QObject
QCOMPARE( QgsExpression::quotedValue( QVariant( true ), QVariant::String ), QString( "'true'" ) );
QCOMPARE( QgsExpression::quotedValue( QVariant() ), QString( "NULL" ) );
QCOMPARE( QgsExpression::quotedValue( QVariant(), QVariant::String ), QString( "NULL" ) );
QVariantList array = QVariantList() << QVariant( 1 ) << QVariant( "a" ) << QVariant();
QCOMPARE( QgsExpression::quotedValue( array ), QString( "array( 1, 'a', NULL )" ) );
}

void reentrant()

0 comments on commit eeb1283

Please sign in to comment.