Skip to content
Permalink
Browse files

[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 befed4d)
  • Loading branch information
nyalldawson committed Apr 25, 2018
1 parent 15d2b36 commit 644c71ef8483e708566ec29820ba1cb4ba3d6842
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/providers/oracle/qgsoracleprovider.cpp
@@ -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
{

0 comments on commit 644c71e

Please sign in to comment.
You can’t perform that action at this time.