microsoft / microsoft/PowerPlatform-DataverseClient-Python

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

Ouverte
#203 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

enhancement
Langage dominant
Python
Étoiles
60
Forks
23
Merge moyen
13 h 53 min
PR mergées (30 j)
3

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez dans data/_odata.py et inspectez le chemin existant de conversion des metadata, puis suivez list_columns et get_column dans operations/tables.py ainsi que leur équivalent asynchrone. Ajoutez une couverture de tests unitaires pour la forme de la requête RetrieveMetadataChanges, la projection, les critères et le mapping typé, puis mettez également à jour README et CHANGELOG. Le travail est terminé lorsque les lectures typées renvoient des propriétés telles que MaxLength ou MinValue/MaxValue en une seule requête, tout en conservant le chemin de conversion existant comme fallback.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
api, backend
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
55/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.