Describe the bug
In the prisma Client, when using null as the criteria in a where filter, corresponding records aren't fetched.
To Reproduce
datamodel.prisma
type User {
id: ID! @unique
name: String
}
In JavaScript code, I'm trying to retrieve all Users that have a null name:
const usersWithNoName = await prisma
.users({
where: {
name: null
}
})
This doesn't return any records even if there are some records that have a null name
If I directly use a GraphQL query to perform the same task, however, I am getting the expected records:
const query = `
query ($nullValue: String){
users(where:{
name: $nullValue
}) {
id
}
}
`
const variables = { nullValue: null }
const { users } = await prisma.$graphql(query, variables)
Expected behavior
The records with a null name should be returned
Versions (please complete the following information):
prisma CLI: prisma/1.23.2 (darwin-x64) node-v10.15.0prisma-client-lib: 1.23.2Hi @mobiware,
I am unable to reproduce this bug. I used the following piece of code to reproduce this:
const { prisma } = require('./generated/prisma-client')
async function whyNodeDoesntHaveTopLevelAwaitYet(){
const usersWithNoName = await prisma.users({where:{
name: null
}})
console.log(usersWithNoName);
}
whyNodeDoesntHaveTopLevelAwaitYet();
Here is the output of the code I used:

You are using an old version of prisma server so please try upgrading that.
@pantharshit00 I am running into a similar issue where with the generated typescript client.
The generated typescript code is
export interface TenantWhereInput {
address?: String;
address_not?: String;
address_in?: String[] | String;
address_not_in?: String[] | String;
address_lt?: String;
address_lte?: String;
address_gt?: String;
address_gte?: String;
address_contains?: String;
address_not_contains?: String;
address_starts_with?: String;
address_not_starts_with?: String;
address_ends_with?: String;
address_not_ends_with?: String;
}
Then when I try to do
let tenants = await prisma.tenants({
where: {
address: null
}
});
I get an error saying that type null is not assignable to type String
Looks related to https://github.com/prisma/prisma/issues/3774
prisma CLI: prisma/1.26.4 (darwin-x64) node-v11.9.0prisma: 1.26.4prisma-binding: 2.3.2This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.
@seawatts Sorry for a very late response. This issue does seem to be a duplicate of https://github.com/prisma/prisma/issues/3774. Closing.
Most helpful comment
@pantharshit00 I am running into a similar issue where with the generated typescript client.
The generated typescript code is
Then when I try to do
I get an error saying that type null is not assignable to type String
Looks related to https://github.com/prisma/prisma/issues/3774
prismaCLI: prisma/1.26.4 (darwin-x64) node-v11.9.0prisma: 1.26.4prisma-binding: 2.3.2