Skip to content

Cannot get model with null condition #228

@Karibash

Description

@Karibash

Current behavior

It is not possible to get a model for which a specific property is null.

const db = factory({
  user: {
    id: primaryKey(Number),
    deletedAt: nullable(Number),
  },
});

db.user.create({
  id: 1,
  deletedAt: null
});

db.user.create({
  id: 2,
  deletedAt: new Date().getTime()
});

const deletedUsers = db.user.findMany({ where: { deletedAt: { equals: null } } });
console.log(deletedUsers);
// -> []

Minimum reproduction code

https://codesandbox.io/s/inspiring-fog-wesv28?file=/index.js

Expected behavior

It seems that the compileQuery function is returning false if the property value is null.
I think it needs to flow to subsequent processing even if the property value is null.

// If an entity doesn't have any value for the property
// is being queried for, treat it as non-matching.
if (actualValue == null) {
return false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions