[#1431 , #1445 , #1594] feature: Add get_value method to MongoDB and Redis FSM storages#1669
[#1431 , #1445 , #1594] feature: Add get_value method to MongoDB and Redis FSM storages#1669Vadim-Khristenko wants to merge 4 commits intoaiogram:dev-3.xfrom
Conversation
Implement get_value method for MongoStorage that retrieves individual values from storage data using MongoDB projections. Add comprehensive test coverage for the new method.
✔️ Changelog found.Thank you for adding a description of the changes |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new feature method, get_value, to MongoDB and Redis FSM storages to enable efficient retrieval of individual user data values using projection queries for MongoDB.
- Added tests for the get_value method in the MongoDB test suite
- Introduced get_value overloads and its implementation in Redis storage
- Implemented get_value in MongoDB storage with projection support for optimized data retrieval
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_fsm/storage/test_mongo.py | Added comprehensive tests for get_value behavior |
| aiogram/fsm/storage/redis.py | Introduced overloaded get_value with implementation |
| aiogram/fsm/storage/mongo.py | Added get_value with projection support for MongoDB |
Files not reviewed (1)
- CHANGES/1669.feature.rst: Language not supported
JrooTJunior
left a comment
There was a problem hiding this comment.
I don't see any important changes that add or improve anything, so why should these changes be accepted?
| async def get_value(self, storage_key: StorageKey, dict_key: str, default: Any) -> Any: ... | ||
|
|
||
| async def get_value( | ||
| self, storage_key: StorageKey, dict_key: str, default: Optional[Any] = None |
There was a problem hiding this comment.
You don't need to override this method in the Redis Storage because the base implementation is the same as you have added.
| async def get_value(self, storage_key: StorageKey, dict_key: str, default: Any) -> Any: ... | ||
|
|
||
| async def get_value( | ||
| self, storage_key: StorageKey, dict_key: str, default: Optional[Any] = None |
There was a problem hiding this comment.
Actually what is the difference with the original implementation in the base method?
Is the same as get_data + get_value, so it is not needed to be overriden
|
I have decided to close this pull request due to its lack of necessity and relevance. I sincerely apologize for wasting your time, @JrooTJunior. |
Description
Added
get_valuemethod to MongoDB and Redis FSM storages to retrieve individual values from stored user data. This completes the implementation across all storage backends.For MongoDB, the implementation uses projection queries to optimize performance when retrieving single values from large data objects.
Fixes #1431
Supersedes inactive PR #1445 (no updates since June 18, 2024)
Complements PR #1594 (which added the method to MemoryStorage and Scenes)
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: