pgsql backend: don't insert model if already exists (hash models)
Description
- Store a hash of
AuthorizationModels - If it is requested to store a new model, but the store already contains one with the same hash, it can return the already existing one
What problem is being solved?
Sending authorization model twice duplicates it
References
Closes #811
Review Checklist
- [x] I have clicked on "allow edits by maintainers".
- [ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
- [x] The correct base branch is being used, if not
main - [ ] I have added tests to validate that the change in functionality is working as expected
TODO:
- Make the tests pass (they don't seem to work on my machine)
- Write tests for this feature
I absolutely suck at Go, I'm not sure I can finish this PR.
[!IMPORTANT]
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
✨ Finishing touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
If the provided model is exactly the same, but one type's relations are defined in a slightly different order, will this produce a consistent hash? Looking over the implementation, it would not appear to.
will this produce a consistent hash?
#811 is about caching the exact same request, we don't care about semantic equality. IMO OpenFGA doesn't have to guarantee caching in all cases and for all storage backends, it just has to try.