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

Circular Struct Fields goes into infinite loop #53

Open
atmnksd opened this issue May 4, 2024 · 0 comments
Open

Circular Struct Fields goes into infinite loop #53

atmnksd opened this issue May 4, 2024 · 0 comments

Comments

@atmnksd
Copy link

atmnksd commented May 4, 2024

If the struct model used refers to any field with same type as that of model directly or indirectly in downstream dependencies then parser creation goes into infinite loop and program never proceeds. Example of such model. ( here Manager is of type User )
type User struct { ID uint ```gorm:"primary_key" rql:"filter,sort"\``` ManagerId *uint Manager *User DirectReports []User ```gorm:"foreignKey:ManagerId"\``` Admin bool ```rql:"filter"``` Name string ```rql:"filter"``` Tags datatypes.JSONSlice[string] ```rql:"filter"``` AddressName string ```rql:"filter"``` CreatedAt time.Time ```rql:"filter,sort"``` }
I propose here two possible solutions

  1. We introduce a nested tag like filter and sort and if a field of type struct is marked nested then only process it. This breaks the convention yet i have already forked this repo and wrote a code which works with this.
  2. Generate all things parser does at run time ( on the fly while parsing queries and not while creating parser) and don't even preprocess model with parser and in doing so we can break loop till all fields refered in query are are parsed.

Would be happy to discuss both the approaches ( or if there could be any other ) and create necessary PR to fix this.

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