tables.create / add_columns cannot set column constraints (MaxLength, MinValue/MaxValue, Format, RequiredLevel, DisplayName)
@vrathee-msft já está trabalhando nisso.
Desde 17/8/2026.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Summary
client.tables.create(...) and client.tables.add_columns(...) accept a column spec of {schema_name: type} where the value is only a type string (or an Enum subclass for optionsets). There is no way to set per-column constraints -- MaxLength, MinValue/MaxValue, Format/FormatName, Precision, RequiredLevel, or a custom DisplayName. Every constraint is hardcoded per type.
Evidence (main @ 5601657)
src/PowerPlatform/Dataverse/data/_odata_base.py::_attribute_payload:
- Rejects any non-
str/ non-Enumspec:raise ValueError("... expected str or Enum subclass"). - Hardcodes constraints per type:
string->MaxLength: 200;memo->MaxLength: 4000;int->MinValue: -2147483648, MaxValue: 2147483647;decimal/double-> fixed Min/Max +Precision;RequiredLevel: {"Value": "None"}on all branches;DisplayNamederived from the schema-name suffix.
No public create_attribute / raw-metadata / generic-request method exists in the tables API (only create, add_columns, remove_columns, create_alternate_key), so there is no managed escape hatch either.
Impact
To create, for example, a Rating column limited to 1-5 or a Comment column with MaxLength=2000, callers must drop to the raw Web API EntityDefinitions({id})/Attributes endpoint and hand-build the payload -- including the @odata.type derived-type discriminator and using PUT (not PATCH) for updates. On hosts where the Dataverse CLI cannot run (ChatGPT web / Codex sandbox -- no .NET runtime), the SDK is the primary path, so this gap forces error-prone hand-rolled metadata calls for a very common ask ("create a table with a bounded rating and a sized text field").
Proposed change (backward-compatible)
Extend the column-spec value to also accept a dict, keeping str / Enum working exactly as today:
client.tables.create("cfb_CustomerFeedback", {
"cfb_Name": "string", # unchanged
"cfb_Rating": {"type": "int", "min_value": 1, "max_value": 5},
"cfb_Comment": {"type": "memo", "max_length": 2000, "display_name": "Comment"},
})
_attribute_payload builds the base payload for type, then applies the provided overrides:
max_length->MaxLengthmin_value/max_value->MinValue/MaxValueprecision->Precisionformat->Format(int/date) orFormatName.Value(string/memo)required->RequiredLevel.Value(None/ApplicationRequired/Recommended)display_name->DisplayNamelabel
The @odata.type discriminator is already stamped correctly, so this needs no endpoint changes.
Touchpoints
data/_odata_base.py::_attribute_payload(core -- shared by the sync + async paths).- Docstrings / typing for
operations/tables.py+aio/operations/async_tables.py(create,add_columns) andoperations/batch.py. - Unit tests mirroring the existing
_attribute_payloadtype tests (add override cases). - README + CHANGELOG per the repo maintenance rules.
Acceptance
{"type": "memo", "max_length": 2000}produces a MemoAttributeMetadata payload withMaxLength: 2000.{"type": "int", "min_value": 1, "max_value": 5}produces an IntegerAttributeMetadata payload with those bounds.strandEnumspecs behave exactly as before (no breaking change).- Unit tests cover the overrides and the unchanged str/Enum paths.
- Linguagem predominante
- Python
- Estrelas
- 60
- Forks
- 23
- Merge médio
- 13h 53min
- PRs com merge (30d)
- 3
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/PowerPlatform-DataverseClient-Python
-
enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
-
enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 68/100
-
enhancement
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
-
microsoft/PowerPlatform-DataverseClient-Python#170 · 1 responsável ·
-
bug
microsoft/PowerPlatform-DataverseClient-Python#166 · 1 comentário · 1 responsável ·
Todas as issues de microsoft/PowerPlatform-DataverseClient-Python
Issues semelhantes
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
zostera/django-bootstrap4#894 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
use-agent-os/agent-os#3276 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
NousResearch/hermes-agent#117848 ·