File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -948,6 +948,10 @@ void QgsOgrProvider::loadFields()
948
948
mAttributeFields .append (
949
949
fidField
950
950
);
951
+ // Set default value for fid, this is needed because
952
+ // the attribute form will not accept a NULL value, passing
953
+ // -1 will delegate to the back-end.
954
+ mDefaultValues .insert ( 0 , QStringLiteral ( " -1" ) );
951
955
}
952
956
953
957
for ( int i = 0 ; i < fdef.GetFieldCount (); ++i )
@@ -1201,6 +1205,18 @@ QVariant QgsOgrProvider::defaultValue( int fieldId ) const
1201
1205
return resultVar;
1202
1206
}
1203
1207
1208
+ QString QgsOgrProvider::defaultValueClause ( int fieldIndex ) const
1209
+ {
1210
+ QString defVal = mDefaultValues .value ( fieldIndex, QString () );
1211
+
1212
+ if ( !providerProperty ( EvaluateDefaultValues, false ).toBool () && !defVal.isEmpty () )
1213
+ {
1214
+ return defVal;
1215
+ }
1216
+
1217
+ return QString ();
1218
+ }
1219
+
1204
1220
void QgsOgrProvider::updateExtents ()
1205
1221
{
1206
1222
invalidateCachedExtent ( true );
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
109
109
virtual QgsFields fields () const override ;
110
110
virtual QgsRectangle extent () const override ;
111
111
QVariant defaultValue ( int fieldId ) const override ;
112
+ QString defaultValueClause ( int fieldIndex ) const override ;
112
113
virtual void updateExtents () override ;
113
114
virtual bool addFeatures ( QgsFeatureList &flist, QgsFeatureSink::Flags flags = 0 ) override ;
114
115
virtual bool deleteFeatures ( const QgsFeatureIds &id ) override ;
You can’t perform that action at this time.
0 commit comments