Skip to content

Add extended table metadata retrieval and models for columns and option sets#2

Draft
maksii wants to merge 7 commits intomainfrom
feature/metadata
Draft

Add extended table metadata retrieval and models for columns and option sets#2
maksii wants to merge 7 commits intomainfrom
feature/metadata

Conversation

@maksii
Copy link
Owner

@maksii maksii commented Feb 28, 2026

Add extended table metadata retrieval and models for columns and option 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.

…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.
@maksii
Copy link
Owner Author

maksii commented Feb 28, 2026

@codex review
@copilot review

Copy link

Copilot AI commented Feb 28, 2026

@maksii I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI and others added 3 commits February 28, 2026 12:30
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.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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.

Changes:

  • Added extended table metadata retrieval to TableOperations.get() via select, include_columns, and include_relationships.
  • Introduced metadata models (ColumnMetadata, OptionItem, OptionSetInfo) and added extensive fixtures/tests for columns and option sets.
  • Implemented new OData metadata helpers for table metadata, columns, relationships, and column option sets.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/PowerPlatform/Dataverse/operations/tables.py Extends public table metadata APIs (get/columns/relationships/option sets).
src/PowerPlatform/Dataverse/data/_odata.py Adds OData helper methods for metadata retrieval (tables, columns, option sets, relationships).
src/PowerPlatform/Dataverse/models/metadata.py Adds dataclass models for column and option set metadata.
src/PowerPlatform/Dataverse/common/constants.py Adds OData type constants used for attribute-type casting in metadata calls.
tests/unit/test_tables_operations.py Expands table operations tests to cover new metadata functionality and backward compatibility.
tests/unit/models/test_metadata.py New unit tests validating metadata model parsing.
tests/fixtures/test_data.py Adds realistic fixtures for attributes, option sets, relationships, and table list entries.
tests/fixtures/__init__.py Initializes fixtures as a package.
README.md Documents new metadata retrieval APIs with examples.
.claude/skills/dataverse-sdk-use/SKILL.md Updates skill documentation with new metadata retrieval examples.
Comments suppressed due to low confidence (3)

src/PowerPlatform/Dataverse/data/_odata.py:1534

  • _get_table_metadata() expands Attributes / relationship collections without projecting fields (no nested $select). Expanding Attributes in particular can return very large payloads for common entities, which can make tables.get(..., include_columns=True) slow/heavy. Consider adding nested $select for expanded collections (or reusing the more selective _get_table_columns endpoint for columns) so the default extended-get remains practical on large schemas.
        expand_parts: List[str] = []
        if include_attributes:
            expand_parts.append("Attributes")
        if include_one_to_many:
            expand_parts.append("OneToManyRelationships")
        if include_many_to_one:
            expand_parts.append("ManyToOneRelationships")
        if include_many_to_many:
            expand_parts.append("ManyToManyRelationships")

src/PowerPlatform/Dataverse/operations/tables.py:368

  • The get_column_options() docstring says it only supports Picklist/MultiSelect/Boolean columns, but the implementation (_get_column_optionset) also supports Status and State attribute types (and unit tests exercise those). Please update the docstring to include Status/State so the public API docs match behavior.
        """Get option set values for a Picklist, MultiSelect, or Boolean column.

        This method retrieves the available choices for a column that uses an
        option set. For Picklist and MultiSelect columns, the options are the
        defined choice values. For Boolean columns, the result contains the
        True and False option labels.

src/PowerPlatform/Dataverse/data/_odata.py:1660

  • _get_column_optionset() uses $expand=OptionSet,GlobalOptionSet without a nested $select. This can significantly increase payload size and may omit fields you actually need (e.g., Options / TrueOption / FalseOption) depending on server defaults. Consider using a nested expand with an explicit select (similar to the existing picklist fetch logic earlier in this file that uses OptionSet($select=Options)) to keep responses smaller and more reliable.
        base = f"{self.api}/EntityDefinitions(LogicalName='{table_lower}')/Attributes(LogicalName='{column_lower}')"

        params = {"$select": "LogicalName", "$expand": "OptionSet,GlobalOptionSet"}

        for cast_type in [

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants