Skip to content

Commit befed4d

Browse files
committed
[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)
1 parent b28b588 commit befed4d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/providers/oracle/qgsoracleprovider.cpp‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,11 +1301,14 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag
13011301
QVariant value = attributevec[ fieldId[i] ];
13021302

13031303
QString v;
1304-
if ( !value.isValid() )
1304+
if ( !value.isValid() || value.isNull() )
13051305
{
1306-
QgsField fld = field( fieldId[i] );
1307-
v = paramValue( defaultValues[i], defaultValues[i] );
1308-
features->setAttribute( fieldId[i], convertValue( fld.type(), v ) );
1306+
if ( mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() )
1307+
{
1308+
QgsField fld = field( fieldId[i] );
1309+
v = paramValue( defaultValues[i], defaultValues[i] );
1310+
features->setAttribute( fieldId[i], convertValue( fld.type(), v ) );
1311+
}
13091312
}
13101313
else
13111314
{

0 commit comments

Comments
 (0)