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

max recursion bug #1627

Open
olegkorshunov opened this issue May 24, 2024 · 0 comments
Open

max recursion bug #1627

olegkorshunov opened this issue May 24, 2024 · 0 comments

Comments

@olegkorshunov
Copy link

olegkorshunov commented May 24, 2024

I suppose this logic incorrect, simple example:

class DBBaseModel(Model):
    class PydanticMeta:
        backward_relations = True
        allow_cycles = False
        max_recursion = 3
        exclude_raw_fields = False
# A->B->C->D->E
class A(DBBaseModel):
   ...
   B: ReverseRelation["B"]

class B(DBBaseModel):
   C: ReverseRelation["C"]
   ...

class C(DBBaseModel):
  D: ReverseRelation["D"]
   ...

class D(DBBaseModel):
  E: ReverseRelation["E"]
   ...

class E(DBBaseModel):
   ...
   
class MetaOvveride(PydanticMeta):
    backward_relations = False
    allow_cycles = False
    max_recursion = 0
    exclude_raw_fields = False

pydantic_a = pydantic_model_creator(A, meta_override=MetaOvveride)

result = await pydantic_a.from_queryset(A.filter(...))

Here I get all data from all relationship, but max_recursion is 0, this part of code doesn't work, also if max_recursion = 1 this part returns all models from relationships, but when max_recursion = 1 we must get A and B, I think we must watch max_recursion only in A model not in others, and changing max_recursion by -1 when we do a recursive traversal

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

No branches or pull requests

1 participant