Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[oracle] Fix handling of NULL values when add features to provider
Fixes NULL attribute values are incorrectly converted to empty
strings or 0 numeric values instead of NULL.

(cherry-picked from 3a3b0fe)
  • Loading branch information
nyalldawson committed May 3, 2018
1 parent b28b588 commit befed4d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1301,11 +1301,14 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag
QVariant value = attributevec[ fieldId[i] ];

QString v;
if ( !value.isValid() )
if ( !value.isValid() || value.isNull() )
{
QgsField fld = field( fieldId[i] );
v = paramValue( defaultValues[i], defaultValues[i] );
features->setAttribute( fieldId[i], convertValue( fld.type(), v ) );
if ( mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() )
{
QgsField fld = field( fieldId[i] );
v = paramValue( defaultValues[i], defaultValues[i] );
features->setAttribute( fieldId[i], convertValue( fld.type(), v ) );
}
}
else
{
Expand Down

0 comments on commit befed4d

Please sign in to comment.