Skip to content

Comments

test(findMany): add failing test for querying by null#187

Closed
kettanaito wants to merge 1 commit intomainfrom
fix/query-nullable-fields
Closed

test(findMany): add failing test for querying by null#187
kettanaito wants to merge 1 commit intomainfrom
fix/query-nullable-fields

Conversation

@kettanaito
Copy link
Member

@kettanaito kettanaito force-pushed the fix/query-nullable-fields branch from 92b43dd to 235c606 Compare January 26, 2022 15:10
const users = db.user.findMany({
where: {
organizationId: {
equals: null,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Querying nullable fields by null is a legal operation.

@kettanaito kettanaito force-pushed the fix/query-nullable-fields branch from 235c606 to bd133cf Compare February 5, 2022 11:42
@kettanaito
Copy link
Member Author

Insights

I suspect that the type produced by Value is not correct:

data/src/glossary.ts

Lines 211 to 212 in d32f154

Target[Key] extends NullableProperty<any>
? ReturnType<Target[Key]['getValue']>

First of all, it misses the | null union type. But even when added, it still remains just a plain model value type without the null union. I have no idea why this happens, neither I have the tools to debug this with the current types complexity of Data.

Eventually, a null check must be introduced to the queryTypes.ts to produce a proper query type:

export type GetQueryFor<ValueType extends any> = ValueType extends string
? StringQuery

@kettanaito
Copy link
Member Author

Update

1.0 most likely fixes this. The task is now to see if this test exists in the new test suites and if it doesn't, add it.

@kettanaito
Copy link
Member Author

Released: v1.0.1 🎉

This has been released in v1.0.1.

Get these changes by running the following command:

npm i @msw/data@latest

Predictable release automation by Release.

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

Successfully merging this pull request may close these issues.

1 participant