Skip to content
Permalink
Browse files

refs #5536

Escape field names in refine rules functions
  • Loading branch information
Hugo Mercier
Hugo Mercier committed Jun 1, 2012
1 parent cd97d82 commit f2c4f53941f5c51f78444382a9198686455aeacc
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/core/symbology-ng/qgsrulebasedrendererv2.cpp
@@ -803,7 +803,9 @@ void QgsRuleBasedRendererV2::refineRuleCategories( QgsRuleBasedRendererV2::Rule*
{
foreach( const QgsRendererCategoryV2& cat, r->categories() )
{
QString filter = QString( "%1 = '%2'" ).arg( r->classAttribute() ).arg( cat.value().toString() );
// replace simple "double quotes" by double "double quotes" in field name
QString escapedId = r->classAttribute().replace(QString("\""), QString("\"\""));
QString filter = QString( "\"%1\" = '%2'" ).arg( escapedId ).arg( cat.value().toString() );
QString label = filter;
initialRule->appendChild( new Rule( cat.symbol()->clone(), 0, 0, filter, label ) );
}
@@ -813,7 +815,9 @@ void QgsRuleBasedRendererV2::refineRuleRanges( QgsRuleBasedRendererV2::Rule* ini
{
foreach( const QgsRendererRangeV2& rng, r->ranges() )
{
QString filter = QString( "%1 >= '%2' AND %1 <= '%3'" ).arg( r->classAttribute() ).arg( rng.lowerValue() ).arg( rng.upperValue() );
// replace simple "double quotes" by double "double quotes" in field name
QString escapedId = r->classAttribute().replace(QString("\""), QString("\"\""));
QString filter = QString( "\"%1\" >= '%2' AND \"%1\" <= '%3'" ).arg( escapedId ).arg( rng.lowerValue() ).arg( rng.upperValue() );
QString label = filter;
initialRule->appendChild( new Rule( rng.symbol()->clone(), 0, 0, filter, label ) );
}

0 comments on commit f2c4f53

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