Skip to content

Commit

Permalink
[oracle] Fix handling of type null variants
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 11, 2025
1 parent 5fc13f9 commit b7223cf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/providers/oracle/qgsoracleprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,12 +1394,18 @@ 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() )
if ( ( QgsVariantUtils::isNull( value ) && mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() )
|| ( value.toString() == defaultValues[i] )
|| value.userType() == qMetaTypeId< QgsUnsetAttributeValue >() )
{
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 );
Expand Down

0 comments on commit b7223cf

Please sign in to comment.