drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.61k stars 649 forks source link

[FEATURE]: InArray does not support using multiple columns #3575

Open muhammetozendev opened 4 days ago

muhammetozendev commented 4 days ago

Feature hasn't been suggested before.

Describe the enhancement you want to request

I ran into a case where I need to use multiple columns with IN and drizzle does not seem to support it yet. Following would be an example usage:

db.select()
  .from(usersTable)
  .where(
    inArray(
      [usersTable.name, usersTable.age],
      [
        ['John', 20],
        ['Bob', 25]
      ]
    )
  );

And generated query would be as follows:

SELECT * FROM users WHERE (name, age) IN (('John', 20), ('Bob', 25));

In this case, it would be ideal to infer the type of the 2D array as [string, number][] if possible. Also it would be great to see this implemented with notInArray too. Thanks in advance