microsoft / microsoft/PowerPlatform-DataverseClient-Python
tables.update_column / update_columns: update existing column constraints (retrieve -> PUT + @odata.type) -- no metadata-write path exists today
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 60
- 派生
- 23
- 平均合并
- 13 小时 53 分钟
- 30 天内合并 PR
- 3
描述
Summary
client.tables can create, add_columns, and remove_columns, but there is no way to update an existing column's definition -- MaxLength, MinValue/MaxValue, RequiredLevel, DisplayName, Format, etc. Today a caller who needs to widen a text column or change a required level must drop to the raw Web API PUT EntityDefinitions({id})/Attributes({id}) and hand-build the payload, including the derived @odata.type discriminator.
This is also the only place the counter-intuitive PUT-not-PATCH metadata-update contract is exposed to users. Metadata updates go over PUT with merge semantics (partial payloads are honored), which reads like PATCH behavior on the PUT verb. The right fix is not a platform verb change (that is a long pole) -- it is to hide the verb inside the SDK so users never choose it.
Context: parity with the .NET modern client
Microsoft.PowerPlatform.Dataverse.Client.ServiceClient never hits this, because it rides the Organization Service message contracts (Execute(new UpdateAttributeRequest { Attribute = new StringAttributeMetadata { MaxLength = 4000 } })) -- a typed message, no HTTP verb. The Python SDK is Web-API-bound and cannot borrow those contracts, so it should own the retrieve -> modify -> PUT (+ @odata.type) sequence internally to give the same UX (typed fields in, no verb visible).
Proposed change (backward-compatible)
Add update_column (+ update_columns) that accepts the same dict override schema proposed in #194, so create and update share one spec shape:
client.tables.update_column("cfb_CustomerFeedback", "cfb_Comment",
{"max_length": 4000, "display_name": "Customer Comment"})
Internally: GET the existing typed attribute -> apply overrides -> PUT back with the correct derived @odata.type. Never expose PUT/PATCH/@odata.type to the caller.
Touchpoints
data/_odata.py-- new_update_attribute(retrieve-then-PUTwith@odata.type); reuse_odata_base.py::_attribute_payloadoverride-building from #194.operations/tables.py+aio/operations/async_tables.py-- newupdate_column/update_columns.- Unit tests: override application + correct verb /
@odata.typeon the outbound request. - README + CHANGELOG per repo maintenance rules.
Acceptance
update_column(..., {"max_length": 4000})issues aPUTtoEntityDefinitions({id})/Attributes({id})withMaxLength: 4000and the correct derived@odata.type.- Caller never passes a verb or
@odata.type. - Depends on / shares the override-spec schema from #194.
Related
- #194 -- create-time column constraints (in progress).
- microsoft/Dataverse-skills#119 -- documents the raw Web API metadata contract this method replaces.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 data/_odata.py 和 _odata_base.py::_attribute_payload 开始,然后检查 operations/tables.py 和 aio/operations/async_tables.py 中的表操作。在单元测试中验证 override 的应用和发出的 PUT 请求,包括派生的 @odata.type;按需更新 README 和 CHANGELOG。确认实现复用了 #194 中的 override schema,并将 verb 和 discriminator 保持为内部实现。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api, backend
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 68/100