Skip to content
Permalink
Browse files

Merge pull request #8878 from rldhont/sld-read-like-escapeChar-master

[BUGFIX] SLD : Support escapeChar attribute of PropertyIsLike
  • Loading branch information
rldhont committed Jan 16, 2019
2 parents aaede28 + 1f9a14d commit 9419bfdc5f1ad6358d28e0bf6d50895bd32131f5
Showing with 12 additions and 1 deletion.
  1. +4 −0 src/core/qgsogcutils.cpp
  2. +8 −1 tests/src/core/testqgsogcutils.cpp
@@ -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( "%" ) )
@@ -391,14 +391,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>"

0 comments on commit 9419bfd

Please sign in to comment.
You can’t perform that action at this time.