Closed SteffenDE closed 2 years ago
Oh, I just saw that there already was a similar issue and PR. I'll check that and close this PR if necessary.
I think this PR is fine and actually implements the solution that was agreed on in #94.
For reference, I've tidied up the documentation to make it clearer how this works: https://github.com/tompave/fun_with_flags/commit/00cd00a6eeb746994649f2e828f93cbb7bd40470
I find the fact that prepare_query/3
only support the Query API a bit confusing, so I'd like to explain its gotchas.
This has been released on Hex with version 1.10.0
.
When having a setup similar to what's described in the official Ecto guides on setting up multi tenancy with foreign keys, the queries originating from FunWithFlags can fail, as the tenant key is not set. See https://hexdocs.pm/ecto/multi-tenancy-with-foreign-keys.html.
This PR adds a custom query option (
:fun_with_flags
) to allow an easy detection of these queries and to skip the tenant key check. The test repo was changed to check for this option and raise if it is not set.Closes #94.