-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
[Pg-kit] Allow where
in with
when relation is 1-1
#4011
base: main
Are you sure you want to change the base?
[Pg-kit] Allow where
in with
when relation is 1-1
#4011
Conversation
When a relation is 1-many, `with` allows for use of `where` for filtering. The typing did not expose this option in a 1-1 relation, even though it is valid.
When a relation is 1-many, `with` allows for use of `where` for filtering. The typing did not expose this option in a 1-1 relation, even though it is valid.
7ae1e25
to
e2b789e
Compare
…ramipellumbi/drizzle-orm into rp/where-on-with-in-one-to-one-relation
e2b789e
to
71406af
Compare
Is there anything blocking this PR? I feel like Drizzle Team is not looking into Github issues / PRs at all |
This certainly feels like what happens. Releases seem to not focus on functionality fixes. I still use Prisma for anything that matters. |
See #3974. They seem to be focusing on their roadmap right now. |
The quick fix that seems to work for me is by using Install it by using Modify Add these two scripts in package.json. {
"scripts": {
"patch-packages": "patch-package drizzle-orm",
"postinstall": "patch-package"
}
} now run Now the where clause should work for one on one relation. I'm not sure whether there's a bad side effect caused by this, but everything seems to work fine so far. |
Just be careful with this. In the event the filter does not match, the relation is included with value |
Closes #3911. Namely, when a relation is 1-many,
with
allows for use ofwhere
for filtering. The typing did not expose this option in a 1-1 relation. A caveat I want feedback on is how to ensure the typing of thewith
column becomesnullable
, which is the behavior of the query when the filter does not match (I believe this is related to #824). Though, realistically, the record should be omitted in the case it does not match as this is very confusing behavior.Consider the following simple example (hoisting it from the issue which has had 0 interactions):
And suppose I do the following query:
But the expected behavior does not happen. Instead, I retrieve
bedAssignments
that have theirbed
property asnull
(but are not typed as such), which is very confusing behavior. A maintainer should take it from here.