Skip to content

How to implement IsNull and IsNotNull in filter? #81

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

Closed
ixxvivxxi opened this issue Apr 6, 2024 · 5 comments · Fixed by #82
Closed

How to implement IsNull and IsNotNull in filter? #81

ixxvivxxi opened this issue Apr 6, 2024 · 5 comments · Fixed by #82
Labels
bug Something isn't working

Comments

@ixxvivxxi
Copy link

I would like to filter mainly columns something like this:

filter: {
  startDate: {
    isNull: true
  },
  endDate: {
    isNotNull: true
  }
}

Perhaps there is a way to add your own filters, but I haven’t figured out how

@klerick klerick added the help wanted Extra attention is needed label Apr 6, 2024
@klerick
Copy link
Owner

klerick commented Apr 6, 2024

@ixxvivxxi
try to use filter operator eq and ne
example:
http://localhost:3000/api/users?filter%5BfirstName%5D[eq]=null&filter%5Blogin%5D[ne]=null
is equal of sql query:

SELECT * FROM "users" "Users" WHERE "Users"."login" <> null AND "Users"."first_name" = null

so you filter should be:

 filter: {
  startDate: {
    eq: true
  },
  endDate: {
    no: true
  }
}

@ixxvivxxi
Copy link
Author

@klerick Thank you for your response! But your example doesn't work, there is a message - String should be as date
{code: "custom", message: "String should be as date", path: ["filter", "target", "startDate", "eq"]}
{code: "custom", message: "String should be as date", path: ["filter", "target", "endDate", "ne"]}

@klerick
Copy link
Owner

klerick commented Apr 6, 2024

@ixxvivxxi
Oooops)
this is bug of validation)
I will try fixed it ASAP

@klerick klerick added bug Something isn't working and removed help wanted Extra attention is needed labels Apr 6, 2024
klerick added a commit that referenced this issue Apr 6, 2024
Fix validation if try create conditional for date filed. If check field for null validation throw error: "String should be as date"

Closes: #81
@klerick
Copy link
Owner

klerick commented Apr 6, 2024

@ixxvivxxi
try to use version json-api-nestjs@7.0.1

@ixxvivxxi
Copy link
Author

Thank you! The issue was fixed

klerick added a commit that referenced this issue Apr 8, 2024
Fix validation if try create conditional for date filed. If check field for null validation throw error: "String should be as date"

Closes: #81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants