Skip to content

Commit

Permalink
Maybe fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 10, 2025
1 parent 3ed345a commit 1cf4ffd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/providers/oracle/qgsoracleprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,22 +1397,29 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag
{
QgsDebugError( "found unset value!!" );
}
if ( value.isNull() )
if ( QgsVariantUtils::isNull( value ) )
{
QgsDebugError( "found null value!!" );
}
QgsDebugError( QString( "attribute user type %1" ).arg( value.userType() ) );
QgsDebugError( QString( "default value is %1" ).arg( defaultValues.at( i ) ) );

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 >() )
{
QgsDebugError( QString( "evaluating default expression" ) );
value = evaluateDefaultExpression( defaultValues[i], fld.type() );
QgsDebugError( QString( "evaluated to %1" ).arg( value.toString() ) );
}
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
QgsDebugError( QString( "resetting to invalid variant" ) );
value = QVariant();
}
features->setAttribute( fieldId[i], value );

QgsDebugMsgLevel( QStringLiteral( "addBindValue: %1" ).arg( value.toString() ), 1 );
Expand Down

0 comments on commit 1cf4ffd

Please sign in to comment.