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 3a3b0fe)
  • Loading branch information
nyalldawson committed May 3, 2018
1 parent b28b588 commit befed4deff29434242865e6e464ad3c108830719
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/providers/oracle/qgsoracleprovider.cpp
@@ -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
{

0 comments on commit befed4d

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