[oracle] Fix handling of type null variants

This commit is contained in:
Nyall Dawson 2025-02-11 11:27:58 +10:00
parent dd11d8acf1
commit 398fc2c30a
No known key found for this signature in database
GPG Key ID: 4C61673F0BF197FC

View File

@ -1394,10 +1394,16 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag
QVariant value = attributevec.value( fieldId[i], QVariant() );
QgsField fld = field( fieldId[i] );
if ( ( value.isNull() && mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() ) || ( value.toString() == defaultValues[i] ) )
if ( ( QgsVariantUtils::isNull( value ) && mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() ) || ( value.toString() == defaultValues[i] ) )
{
value = evaluateDefaultExpression( defaultValues[i], fld.type() );
}
else if ( QgsVariantUtils::isNull( value ) )
{
// don't use typed null variants, always use invalid variants. Otherwise the connection
// may incorrectly try to coerce a null value to the variant type
value = QVariant();
}
features->setAttribute( fieldId[i], value );
QgsDebugMsgLevel( QStringLiteral( "addBindValue: %1" ).arg( value.toString() ), 4 );