Skip to content

Commit b7223cf

Browse files
committed
[oracle] Fix handling of type null variants
1 parent 5fc13f9 commit b7223cf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/providers/oracle/qgsoracleprovider.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,12 +1394,18 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag
13941394
QVariant value = attributevec.value( fieldId[i], QVariant() );
13951395

13961396
QgsField fld = field( fieldId[i] );
1397-
if ( ( value.isNull() && mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() )
1397+
if ( ( QgsVariantUtils::isNull( value ) && mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() )
13981398
|| ( value.toString() == defaultValues[i] )
13991399
|| value.userType() == qMetaTypeId< QgsUnsetAttributeValue >() )
14001400
{
14011401
value = evaluateDefaultExpression( defaultValues[i], fld.type() );
14021402
}
1403+
else if ( QgsVariantUtils::isNull( value ) )
1404+
{
1405+
// don't use typed null variants, always use invalid variants. Otherwise the connection
1406+
// may incorrectly try to coerce a null value to the variant type
1407+
value = QVariant();
1408+
}
14031409
features->setAttribute( fieldId[i], value );
14041410

14051411
QgsDebugMsgLevel( QStringLiteral( "addBindValue: %1" ).arg( value.toString() ), 4 );

0 commit comments

Comments
 (0)