Skip to content

Commit af8479e

Browse files
committed
vector join: fix quoting in subset string
1 parent a132bc9 commit af8479e

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎src/core/qgsvectorlayerfeatureiterator.cpp‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,31 @@ void QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect( Qg
407407
else
408408
joinFieldName = joinInfo->joinFieldName;
409409

410-
subsetString.append( "\"" + joinFieldName + "\"" + " = " + "\"" + joinValue.toString() + "\"" );
410+
subsetString.append( QString( "\"%1\"" ).arg( joinFieldName ) );
411+
412+
if ( joinValue.isNull() )
413+
{
414+
subsetString += " IS NULL";
415+
}
416+
else
417+
{
418+
QString v = joinValue.toString();
419+
switch ( joinValue.type() )
420+
{
421+
case QVariant::Int:
422+
case QVariant::LongLong:
423+
case QVariant::Double:
424+
break;
425+
426+
default:
427+
case QVariant::String:
428+
v.replace( "'", "''" );
429+
v.prepend( "'" ).append( "'" );
430+
break;
431+
}
432+
subsetString += "=" + v;
433+
}
434+
411435
joinLayer->dataProvider()->setSubsetString( subsetString, false );
412436

413437
// select (no geometry)

0 commit comments

Comments
 (0)