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

Fails to fetch model instances when model is restricted to primary keys of a related model. #13

Open
matthewcove-code opened this issue Jan 4, 2023 · 2 comments

Comments

@matthewcove-code
Copy link

Models related by a Fk to another model are failing to fetch records on the first run. For example where a 'student' has a FK to a 'class', the class is being fetched first but then none of the 'student' records are fetched. Debugging shows that even when we have just fetched all 'class' records, when we process the strategy for the 'student' model and we run 'get_exported_pks_for_model' for the 'class' related model, no primary keys are returned and so the 'studend' queryset returned by get_queryset contains no records.

Removing the '@functools.lru_cache' decorator from 'get_exported_pks_for_model' and 'get_exported_objects_for_model 'fixes the issue.

@matthewcove-code
Copy link
Author

I was going to create a PR that fixes this issue but it looks like I dont have permissions to do this.

@danpalmer
Copy link
Owner

Sorry for the late reply, I have only just seen this! Could you possibly post the strategy setup you're using that I can try to reproduce with?

Removing the '@functools.lru_cache' decorator from 'get_exported_pks_for_model' and 'get_exported_objects_for_model 'fixes the issue.

Good find, but I seem to remember this was a fairly important optimisation so I'd rather not remove it if possible.

I was going to create a PR that fixes this issue but it looks like I dont have permissions to do this.

I'm sorry you're having trouble with this. I'm not sure why this would be, and I believe others have opened PRs without issue. Can you tell me what steps you've taken to try to open a PR? Where are you hitting the issue?

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

2 participants