redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

added return_fields function, attempting to optionally limit fields r…

Open sav-norem opened this issue 1 year ago • 3 comments

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

sav-norem avatar Jul 05 '24 16:07 sav-norem

Please add also exclude keyword, it'll be convenient

DennyD17 avatar Sep 18 '24 19:09 DennyD17

Are u going to finish it guys?

DennyD17 avatar Nov 10 '24 18:11 DennyD17

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]

DennyD17 avatar Feb 16 '25 10:02 DennyD17

Refactored this feature to become a new only(*fields) and values(*fields) pair, following patterns from the Django ORM.

abrookins avatar Aug 15 '25 00:08 abrookins