cache empty result for picklist label retrieval in _ODataClient#83
cache empty result for picklist label retrieval in _ODataClient#83pkontek wants to merge 1 commit intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes the picklist label retrieval logic by caching empty results when no option sets are found, preventing redundant queries for non-existent data.
Key Changes:
- Modified
_optionset_mapto cache empty results instead of returningNone - Return empty dictionary
{}instead ofNonefor consistency
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # cache empty result | ||
| self._picklist_label_cache[cache_key] = {"map": {}, "ts": now} | ||
| return {} |
There was a problem hiding this comment.
Changing the return type from None to {} is a breaking change for consumers who check for None (e.g., if result is None). This could cause existing code to behave incorrectly. Consider deprecating the None return in a separate release or updating all callers to handle empty dict, or document this breaking change explicitly in release notes.
There was a problem hiding this comment.
It’s the same value returned when the Attribute is not a picklist. In my opinion, this approach is more consistent.
This pull request updates the
_optionset_mapmethod to cache empty results instead of returningNonewhen no items are found. This change ensures that empty lookups are cached, which can improve performance by avoiding repeated queries for missing option sets.Caching improvements:
_optionset_mapinsrc/PowerPlatform/Dataverse/data/_odata.pyto cache empty results in_picklist_label_cacheand return an empty dictionary instead ofNonewhen no items are found.