Add extended table metadata retrieval and models for columns and option sets#132
Open
maksii wants to merge 7 commits intomicrosoft:mainfrom
Open
Add extended table metadata retrieval and models for columns and option sets#132maksii wants to merge 7 commits intomicrosoft:mainfrom
maksii wants to merge 7 commits intomicrosoft:mainfrom
Conversation
…on sets - Implemented methods to fetch detailed metadata for tables, including columns and relationships. - Introduced `ColumnMetadata`, `OptionItem`, and `OptionSetInfo` models to represent column and option set data structures. - Updated `get` method in `TableOperations` to support optional parameters for including columns and relationships in the response. - Enhanced tests to cover new functionality and ensure backward compatibility. This update improves the SDK's ability to interact with Dataverse metadata, providing richer data for developers.
Co-authored-by: maksii <1761348+maksii@users.noreply.github.com>
Fix spurious `columns_created` in `get()` result and reduce cyclomatic complexity
- Introduced new test data fixtures in `tests/fixtures/test_data.py` for various metadata attributes, including columns, option sets, and relationships. - Updated `tests/unit/models/test_metadata.py` to utilize the new fixtures for testing `ColumnMetadata` and `OptionSetInfo` classes, improving test coverage for primary name columns, picklist columns, and status/state option sets. - Enhanced `tests/unit/test_tables_operations.py` to incorporate fixtures for table operations, ensuring accurate testing of column retrieval, relationship listing, and table metadata. - Refactored existing tests to replace hardcoded data with structured test data from the new fixtures, promoting maintainability and clarity in test cases.
- Updated the docstring to clarify the types of columns supported, including Picklist, MultiSelect, Boolean, Status, and State. - Improved descriptions of the return values for better understanding of the method's functionality.
Contributor
There was a problem hiding this comment.
Pull request overview
Extends the Dataverse SDK metadata surface area to support richer table metadata retrieval (columns, relationships, option sets) and introduces new strongly-typed metadata models, with accompanying docs and unit tests.
Changes:
- Added extended table metadata retrieval via
TableOperations.get(..., select/include_columns/include_relationships)plus new helpers (get_columns,get_column,get_column_options,list_relationships). - Introduced new metadata models:
ColumnMetadata,OptionItem,OptionSetInfo. - Expanded fixtures and added/updated unit tests and documentation examples for the new APIs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/PowerPlatform/Dataverse/operations/tables.py |
Adds extended table/column/relationship/option-set APIs on the public tables namespace. |
src/PowerPlatform/Dataverse/data/_odata.py |
Implements low-level Web API calls for rich entity metadata, columns, relationships, and option sets. |
src/PowerPlatform/Dataverse/models/metadata.py |
Adds new dataclass-based metadata models and API-response mapping helpers. |
src/PowerPlatform/Dataverse/common/constants.py |
Adds constants for attribute metadata cast types and attribute type codes. |
tests/unit/test_tables_operations.py |
Adds unit tests for extended get() behavior and new tables methods. |
tests/unit/models/test_metadata.py |
Adds unit tests for the new metadata model mappers. |
tests/fixtures/test_data.py |
Adds realistic column/option set/relationship fixture payloads and table list entries. |
tests/fixtures/__init__.py |
Initializes the fixtures package. |
README.md |
Documents new metadata retrieval capabilities with examples. |
.claude/skills/dataverse-sdk-use/SKILL.md |
Updates skill documentation with new metadata APIs and examples. |
Comments suppressed due to low confidence (2)
src/PowerPlatform/Dataverse/data/_odata.py:1525
- Using
set(select)andsetunion to build$selectmakes the projected field order non-deterministic. This can cause noisy diffs/logs and can interfere with any request caching keyed by URL. Prefer an order-preserving de-duplication strategy (e.g., base fields first, then user-provided fields in their original order).
if select:
base_fields = {"MetadataId", "LogicalName", "SchemaName", "EntitySetName"}
merged = list(base_fields | set(select))
params["$select"] = ",".join(merged)
src/PowerPlatform/Dataverse/data/_odata.py:1653
- The docstring for
_get_column_optionsetsays it only supports Picklist/MultiSelectPicklist/Boolean, but the implementation also attempts Status and State casts (and the public API advertises Status/State support). Update the docstring to reflect the actual supported attribute types and the expected 400/404 behavior for failed casts.
"""Get the option set definition for a Picklist, MultiSelectPicklist, or Boolean column.
:param table_schema_name: Schema name of the table.
:type table_schema_name: ``str``
:param column_logical_name: Logical name of the column.
:type column_logical_name: ``str``
:return: Raw option set metadata dict, or ``None`` if not found or not an option-set column.
:rtype: ``dict[str, Any]`` | ``None``
:raises HttpError: If the request fails (non-400/404).
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ty select list in TableOperations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR extends the Dataverse SDK’s table metadata APIs to support richer metadata retrieval (columns, relationships, and option sets) and adds new metadata models plus corresponding unit tests.
Add extended table metadata retrieval and models for columns and option sets
ColumnMetadata,OptionItem, andOptionSetInfomodels to represent column and option set data structures.getmethod inTableOperationsto support optional parameters for including columns and relationships in the response.This update improves the SDK's ability to interact with Dataverse metadata, providing richer data for developers.