Skip to content
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

JsonModel.schema_for_type() missing 2 required positional arguments: 'typ' and 'field_info' #619

Open
DennyD17 opened this issue May 12, 2024 · 2 comments · May be fixed by #622
Open

JsonModel.schema_for_type() missing 2 required positional arguments: 'typ' and 'field_info' #619

DennyD17 opened this issue May 12, 2024 · 2 comments · May be fixed by #622

Comments

@DennyD17
Copy link

redis-om = "^0.3.1"

Here we try to pass 3 args to schema_for_type
https://github.com/redis/redis-om-python/blob/main/aredis_om/model/model.py#L1985

But it seems like it takes 5
https://github.com/redis/redis-om-python/blob/main/aredis_om/model/model.py#L1994

So I get
JsonModel.schema_for_type() missing 2 required positional arguments: 'typ' and 'field_info'

@slorello89
Copy link
Member

Hi @DennyD17 - I really need a reproduction of this issue to make any progress.

@DennyD17
Copy link
Author

            if getattr(field_info, "primary_key", None):
                if issubclass(_type, str):
                    redisearch_field = f"$.{name} AS {name} TAG SEPARATOR {SINGLE_VALUE_TAG_FIELD_SEPARATOR}"
                else:
                    redisearch_field = cls.schema_for_type(name, _type, field_info)
                schema_parts.append(redisearch_field)
                continue

If we create JsonModel with non-str pk we will get this error

class MyModel(JsonModel):
    my_id: int = Field(index=True, primary_key=True)

Here you pass 3 positional arguments to method expecting 5

redisearch_field = cls.schema_for_type(name, _type, field_info)

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 a pull request may close this issue.

2 participants