Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8874 from rldhont/sld-read-like-escapeChar-34
SLD : Support escapeChar attribute of PropertyIsLike
  • Loading branch information
m-kuhn committed Jan 16, 2019
2 parents d316255 + 356bc38 commit 19f0e02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/qgsogcutils.cpp
Expand Up @@ -3206,6 +3206,10 @@ QgsExpressionNodeBinaryOperator *QgsOgcUtilsExpressionFromFilter::nodeBinaryOper
{
escape = element.attribute( QStringLiteral( "escape" ) );
}
if ( element.hasAttribute( QStringLiteral( "escapeChar" ) ) )
{
escape = element.attribute( QStringLiteral( "escapeChar" ) );
}
// replace
QString oprValue = static_cast<const QgsExpressionNodeLiteral *>( opRight.get() )->value().toString();
if ( !wildCard.isEmpty() && wildCard != QLatin1String( "%" ) )
Expand Down
9 changes: 8 additions & 1 deletion tests/src/core/testqgsogcutils.cpp
Expand Up @@ -396,14 +396,21 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter_data()
"<PropertyName>NAME</PropertyName><Literal>._QGIS.\\.</Literal></PropertyIsLike>"
"</Filter>" )
<< QStringLiteral( "NAME LIKE '_\\\\_QGIS_.'" );
// different single chars
// different escape chars
QTest::newRow( "like escape char" ) << QString(
"<Filter>"
"<PropertyIsLike wildCard=\"*\" singleChar=\".\" escape=\"!\">"
"<PropertyName>NAME</PropertyName><Literal>_QGIS.!.!!%QGIS*!*</Literal></PropertyIsLike>"
"</Filter>" )
<< QStringLiteral( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" );

QTest::newRow( "like escape char" ) << QString(
"<Filter>"
"<PropertyIsLike wildCard=\"*\" singleChar=\".\" escapeChar=\"!\">"
"<PropertyName>NAME</PropertyName><Literal>_QGIS.!.!!%QGIS*!*</Literal></PropertyIsLike>"
"</Filter>" )
<< QStringLiteral( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" );

QTest::newRow( "is null" ) << QString(
"<Filter>"
"<ogc:PropertyIsNull>"
Expand Down

0 comments on commit 19f0e02

Please sign in to comment.