microsoft / microsoft/PowerPlatform-DataverseClient-Python

Typed column metadata reads via RetrieveMetadataChanges (one request, no @odata.type cast round-trip)

未关闭
#203 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
Python
星标
60
派生
23
平均合并
13 小时 53 分钟
30 天内合并 PR
3

描述

Summary

Reading type-specific column properties over /EntityDefinitions is a two-step dance: first read the generic attribute to get AttributeType/@odata.type, then re-issue a second GET with a derived-type URL cast (/Attributes/Microsoft.Dynamics.CRM.StringAttributeMetadata) to project the typed fields. The SDK does exactly this today (e.g. _bulk_fetch_picklists, extra_select="@odata.type,AttributeType").

Context: what the .NET modern client gives for free

ServiceClient gets fully-typed, polymorphic AttributeMetadata derived objects back in one RetrieveEntity/RetrieveAllEntities call and the caller just downcasts (attr is StringAttributeMetadata s). No second request, no discriminator juggling.

Proposed change

Add a typed read path backed by the Web API RetrieveMetadataChanges function -- the closest Web-API analog to the .NET single-request typed retrieve. It returns derived typed attributes in one call and supports property projection (via the query's AttributeQuery.Properties), so callers get small, typed payloads without the cast round-trip.

cols = client.tables.list_columns("account", typed=True)   # typed values, one request
col  = client.tables.get_column("account", "emailaddress1", typed=True)

Why this does not need a platform change

Payload size is controlled by the query's property projection, so the platform "omit null fields" ask is not a blocker -- we simply project only the properties we need. (Note: the .NET client itself uses plain Retrieve* + a client cache rather than RetrieveMetadataChanges; for a Web-API client wanting small typed payloads, RetrieveMetadataChanges with projection is the better fit. Design discussion welcome.)

Touchpoints

  • data/_odata.py -- new _retrieve_metadata_changes(...) issuing GET RetrieveMetadataChanges(Query=@p1)?@p1={...} with an EntityQueryExpression + AttributeQuery.Properties projection.
  • operations/tables.py + async twin -- typed=True on list_columns / get_column (keep the existing cast path as fallback).
  • Unit tests: request shape (projection, criteria) + typed mapping.
  • README + CHANGELOG.

Acceptance

  • list_columns(typed=True) returns typed values (e.g. MaxLength on string/memo, MinValue/MaxValue on int) in a single request, no @odata.type URL cast.
  • Property projection limits the payload to requested properties.

Related

  • #194 -- create-time column constraints (in progress).
  • microsoft/Dataverse-skills#119 -- documents the current two-step typed-read workaround.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 data/_odata.py 开始,检查现有的 metadata cast path,然后跟踪 operations/tables.py 中的 list_columns 和 get_column 及其 async twin。为 RetrieveMetadataChanges 的 request shape、projection、criteria 和 typed mapping 添加 unit coverage,并更新 README 和 CHANGELOG。完成的标准是:typed reads 能在一次 request 中返回 MaxLength 或 MinValue/MaxValue 等属性,同时保留现有的 cast path 作为 fallback。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, backend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。