Skip to content

Commit

Permalink
vector join: fix quoting in subset string
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 16, 2013
1 parent a132bc9 commit af8479e
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/core/qgsvectorlayerfeatureiterator.cpp
Expand Up @@ -407,7 +407,31 @@ void QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect( Qg
else
joinFieldName = joinInfo->joinFieldName;

subsetString.append( "\"" + joinFieldName + "\"" + " = " + "\"" + joinValue.toString() + "\"" );
subsetString.append( QString( "\"%1\"" ).arg( joinFieldName ) );

if ( joinValue.isNull() )
{
subsetString += " IS NULL";
}
else
{
QString v = joinValue.toString();
switch ( joinValue.type() )
{
case QVariant::Int:
case QVariant::LongLong:
case QVariant::Double:
break;

default:
case QVariant::String:
v.replace( "'", "''" );
v.prepend( "'" ).append( "'" );
break;
}
subsetString += "=" + v;
}

joinLayer->dataProvider()->setSubsetString( subsetString, false );

// select (no geometry)
Expand Down

0 comments on commit af8479e

Please sign in to comment.