Skip to content

Commit 644c71e

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 befed4d)
1 parent 15d2b36 commit 644c71e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/providers/oracle/qgsoracleprovider.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,11 +1370,14 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
13701370
QVariant value = attributevec[ fieldId[i] ];
13711371

13721372
QString v;
1373-
if ( !value.isValid() )
1373+
if ( !value.isValid() || value.isNull() )
13741374
{
1375-
const QgsField &fld = field( fieldId[i] );
1376-
v = paramValue( defaultValues[i], defaultValues[i] );
1377-
features->setAttribute( fieldId[i], convertValue( fld.type(), v ) );
1375+
if ( mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() )
1376+
{
1377+
const QgsField &fld = field( fieldId[i] );
1378+
v = paramValue( defaultValues[i], defaultValues[i] );
1379+
features->setAttribute( fieldId[i], convertValue( fld.type(), v ) );
1380+
}
13781381
}
13791382
else
13801383
{

0 commit comments

Comments
 (0)