-
Notifications
You must be signed in to change notification settings - Fork 11
Preserve @odata keys when normalizing record keys #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this 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 fixes a bug where OData annotation keys were being incorrectly lowercased. The _lowercase_keys helper function now preserves case-sensitive OData keys (like @odata.bind) while still normalizing Dataverse attribute names to lowercase.
Changes:
- Modified
_lowercase_keysto detect and preserve OData annotation keys by checking for "@OData" substring - Updated docstrings and inline comments to reflect the new behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _lowercase_keys(record: Dict[str, Any]) -> Dict[str, Any]: | ||
| """Convert all dictionary keys to lowercase for case-insensitive column names. | ||
| """Normalize dictionary keys to lowercase for case-insensitive column names. | ||
|
|
||
| Dataverse LogicalNames for attributes are stored lowercase, but users may | ||
| provide PascalCase names (matching SchemaName). This normalizes the input. | ||
| This function lowercases all string keys except OData annotation keys, | ||
| which must remain case-sensitive. | ||
| """ | ||
| if not isinstance(record, dict): | ||
| return record | ||
| return {k.lower() if isinstance(k, str) else k: v for k, v in record.items()} | ||
|
|
||
| new_record = {} | ||
|
|
||
| # Preserve OData annotation keys as they are case sensitive | ||
| for k, v in record.items(): | ||
| if isinstance(k, str) and "@odata" in k: | ||
| new_record[k] = v | ||
| else: | ||
| new_record[k.lower() if isinstance(k, str) else k] = v | ||
| return new_record |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _lowercase_keys function lacks test coverage for the new behavior of preserving OData annotation keys. Consider adding tests that verify OData keys like "@odata.bind", "@odata.type", and "@odata.nextLink" are preserved with their original casing while regular attribute keys are lowercased.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The _lowercase_keys helper function previously lowercases all string keys which unintentionally breaks OData keys such as @odata.bind. These keys are case sensitive and must remain unchanged for Dataverse to interpret them correctly.