Skip to content

Commit

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

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

QString v;
if ( !value.isValid() )
if ( !value.isValid() || value.isNull() )
{
const 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() )
{
const 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 644c71e

Please sign in to comment.