Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FEATURE]: remove limitation: notInArray requires at least one value #1652

Closed
sys13 opened this issue Dec 14, 2023 · 4 comments
Closed

[FEATURE]: remove limitation: notInArray requires at least one value #1652

sys13 opened this issue Dec 14, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@sys13
Copy link

sys13 commented Dec 14, 2023

Describe what you want

notInArray requires at least one value. Would like to allow for empty arrays

@sys13 sys13 added the enhancement New feature or request label Dec 14, 2023
@DenisBessa
Copy link

This would be nice. It leads to unnecessary runtime errors.

@Angelelz
Copy link
Collaborator

Can you share a code snippet? What is causing the error?

@DenisBessa
Copy link

The behavior of inArray and notInArray is the same.

When providing an empty array as argument, it leads to a runtime error.

  const someEmptyArray = []
  const thisWillGenerateAnRuntimeError = await db.select().from(customers).where(inArray(customers.id, someEmptyArray));

  const someNonEmptyArray = [1, 2, 3]
  const thisIsOk = await db.select().from(customers).where(inArray(customers.id, someNonEmptyArray));

@Angelelz
Copy link
Collaborator

How do you think drizzle should handle an empty array? just remove the filter altogether?
I think the team discussed this briefly but I don't remember a decision. I guess drizzle could just return false if inArray is passed an empty array. In any case, I'll close this issue in favor of #1295. That one already has a couple reactions. Let's continue the discussion over there.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants