Skip to content

added return_fields function, attempting to optionally limit fields r… #633

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sav-norem
Copy link

…eturned by find. Will solve #568 when completed.

@sav-norem sav-norem marked this pull request as ready for review August 14, 2024 14:39
@sav-norem sav-norem requested review from slorello89 and banker August 14, 2024 14:39
@DennyD17
Copy link

Please add also exclude keyword, it'll be convenient

@DennyD17
Copy link

Are u going to finish it guys?

@DennyD17
Copy link

I tried to do it, and I found two main problems here:

  1. All fields that will not be returned must be Optional or have a default value. If not there will be an Exception here --- https://github.com/redis/redis-om-python/blob/main/aredis_om/model/model.py#L1473. It will not be clear for user. This can be validated in FindQuery init, but I don't have an idea, how to check it.
  2. Here is a problem with dict fields and embedded model --- it will be returned as JSON, and we will have a validation issue again.
address
Input should be a valid dictionary or object to extract fields from [type=model_attributes_type, input_value='{"pk":"01JM7319T5SP7A6YR...e":"11111","note":null}', input_type=str]

bsbodden added a commit that referenced this pull request Aug 12, 2025
- Move RETURN clause from query string to args list (fixes RediSearch syntax)
- Rename internal parameter from return_fields to projected_fields to avoid conflict with method name
- Return dictionaries instead of model instances when using field projection
- Add proper parsing for projected results that returns flat key-value pairs
- Add tests for both HashModel and JsonModel field projection
- Update validation to use model_fields instead of deprecated __fields__

This addresses all review comments from PR #633 and implements field projection correctly.
@bsbodden bsbodden force-pushed the limit_return_fields branch from 3de85c9 to 8fc78fc Compare August 12, 2025 21:18
@bsbodden bsbodden self-requested a review August 12, 2025 21:18
bsbodden added a commit that referenced this pull request Aug 12, 2025
- Move RETURN clause from query string to args list (fixes RediSearch syntax)
- Rename internal parameter from return_fields to projected_fields to avoid conflict with method name
- Return dictionaries instead of model instances when using field projection
- Add proper parsing for projected results that returns flat key-value pairs
- Add tests for both HashModel and JsonModel field projection
- Update validation to use model_fields instead of deprecated __fields__

This addresses all review comments from PR #633 and implements field projection correctly.
@bsbodden bsbodden force-pushed the limit_return_fields branch from 8fc78fc to 5b91067 Compare August 12, 2025 21:31
- Move RETURN clause from query string to args list (fixes RediSearch syntax)
- Rename internal parameter from return_fields to projected_fields to avoid conflict with method name
- Return dictionaries instead of model instances when using field projection
- Add proper parsing for projected results that returns flat key-value pairs
- Add tests for both HashModel and JsonModel field projection
- Update validation to use model_fields instead of deprecated __fields__

This addresses all review comments from PR #633 and implements field projection correctly.
@bsbodden bsbodden force-pushed the limit_return_fields branch from 5b91067 to b997389 Compare August 12, 2025 21:35
@bsbodden bsbodden removed the request for review from banker August 12, 2025 21:50
@bsbodden bsbodden self-assigned this Aug 12, 2025
Copy link
Contributor

@bsbodden bsbodden left a comment

Choose a reason for hiding this comment

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

Looks good to me... now 😉

@bsbodden bsbodden requested a review from slorello89 August 12, 2025 21:53
@bsbodden bsbodden self-requested a review August 13, 2025 16:00
Copy link
Contributor

@bsbodden bsbodden left a comment

Choose a reason for hiding this comment

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

LGTM!

@bsbodden bsbodden requested a review from abrookins August 13, 2025 16:36
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.

5 participants