Unexpected behaviour using arcpy.da.InsertCursor on a column with an attribute domain

564
2
01-31-2022 04:10 AM
Sven_Harpering
Esri Contributor

Hi,

one of our customers created a feature class in ArcGIS Pro in the default GDB. He configured an attribute domain with 3 values and assigned it to a specific column in the feature class. 

When he is editing the feature class in ArcGIS Pro manually, the customer can only choose between the 3 given values (expected behaviour). On the other hand when the customer ist using the arcpy.da.InsertCursor(...) on this dataset and the specific column, he can write any value into the column. Isn't that against the idea of a domain?

Here are some screenshots:#

(1) manually:

manually.PNG

 

(2) cursor:

cursor.PNG

Best

Sven

Passionate about GIS and on the journey as an instructor for analytical insights.
Tags (3)
0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

It could be that domains through arcpy.da are readonly 

Domain—ArcGIS Pro | Documentation

but can be created and managed through arctoolbox

Add Coded Value To Domain (Data Management)—ArcGIS Pro | Documentation

and there doesn't appear to be any supported environments setting to limit control when used with cursors.

Maybe this is an advantage since you could technically add values without needing to recreate them  (haven't tested this... give it a try if you have a sample dataset)


... sort of retired...
0 Kudos
DonMorrison1
Occasional Contributor III

Good question - I had the same reaction when I first ran into this.  I'm not a database expert but I believe SQL server has the ability to constrain a column to a set of values so I'm curious why this isn't enforced.