Skip to content
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

[BUG]: Drizzle Relational Query not filtering well #4080

Open
1 task done
ManuLpz4 opened this issue Feb 6, 2025 · 0 comments
Open
1 task done

[BUG]: Drizzle Relational Query not filtering well #4080

ManuLpz4 opened this issue Feb 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ManuLpz4
Copy link

ManuLpz4 commented Feb 6, 2025

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.39.2

What version of drizzle-kit are you using?

0.30.2

Other packages

No response

Describe the Bug

I'm trying to query the teams in which a specific user is teamMember but drizzle is retrieving the whole table of teams.

Am I missing something? (I tried changing the name of the teams variable in the where function)

  const teams = await db.query.teams.findMany({
    where: (teams, { exists, eq, and }) =>
      exists(
        db
          .select()
          .from(teamMembers)
          .where(
            and(
              eq(teamMembers.teamId, teams.id),
              eq(teamMembers.userId, userId)
            )
          )
      ),
    with: {
      teamMembers: true
    }
  })
@ManuLpz4 ManuLpz4 added the bug Something isn't working label Feb 6, 2025
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

No branches or pull requests

1 participant