I'm having an issue when I try to set an attribute value to null in the process of adding a new feature to a feature table.
I'm using C++ Qt Runtime sdk 100.3.
I have a feature layer that is enabled for editing. The feature table has string and int attributes that are defined as Editable = yes and Allows Null Values = yes.
What I'm doing is this:
- Create a new feature using ServiceFeatureTable::createFeature().
- Create a QMap<QString, QVariant> of feature attributes.
- Create a null QVariant value: QVariant qv = QVariant();
- I verified that qv.IsNull() is true;
- Add to the attributes list: featureAttributes.insert("MyAttrName", qv);
- I used this for both string and int attributes.
- Create a new feature: featureTable->createFeature(featureAttributes, geom, this);
- If I go ahead and add that feature to the table and apply edits, then I see that the resulting attribute is not null but has a non-null empty string for string attributes and 0 for int attributes.
- What I also found was that if right after creating the feature, I get the attributes back via the AttributeListModel, the attributes are no longer null.
- AttributeListModel* alm = feature->attributes();
- QVariant qv2 = alm->attributeValue(QString("MyAttrName"));
- qDebug() << "qv2 is null =" << qv2.isNull();
- This returns false. I expected it to return true.
If I leave out the attributes from the attribute list altogether, then I do get null values in the resulting feature in the table. However, that approach will not work if the attributes include default values that will set them to non-null values and that approach will not work for ServiceFeatureTable::updateFeature();
I need a way to set values to null explicitly.
Does anyone have suggestions as to what to try? I am probably missed something.
Regards.