We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
drizzle-orm
0.25.4
drizzle-kit
0.17.6
After updating to the latest version of drizzle-orm, my left joins are not working anymore.
Every time I run a query that includes a join it just errors with:
Error: Your "users->id" field references a column "users"."id", but the table "users" is not part of the query! Did you forget to join it?
I have two tables for users and accounts like this:
users
accounts
const usersTable = mysqlTable( "users", { id: varchar("id", { length: 191 }).primaryKey().notNull(), createdAt: datetime("created_at", { fsp: 3 }).notNull(), name: varchar("name", { length: 191 }), email: varchar("email", { length: 191 }).notNull(), emailVerified: datetime("email_verified", { fsp: 3 }), image: text("image"), }, (table) => ({ emailIdx: uniqueIndex("email_idx").on(table.email), }) ); const accountsTable = mysqlTable( "accounts", { id: varchar("id", { length: 191 }).primaryKey().notNull(), userId: varchar("user_id", { length: 191 }).notNull(), type: varchar("type", { length: 191 }).notNull(), provider: varchar("provider", { length: 191 }).notNull(), providerAccountId: varchar("provider_account_id", { length: 191, }).notNull(), refreshToken: text("refresh_token"), accessToken: text("access_token"), expiresAt: int("expires_at"), tokenType: varchar("token_type", { length: 191 }), scope: varchar("scope", { length: 191 }), idToken: text("id_token"), sessionState: varchar("session_state", { length: 191 }), }, (table) => ({ providerProviderAccountIdIdx: uniqueIndex( "provider_provider_account_id_idx" ).on(table.provider, table.providerAccountId), }) );
And then a query trying to join them like this:
const [userAndAccount] = await db .select({ user: usersTable, account: accountsTable }) .from(accountsTable) .leftJoin(usersTable, eq(accountsTable.userId, usersTable.id)) .where( and( eq(accountsTable.provider, provider), eq(accountsTable.providerAccountId, providerAccountId) ) ) .limit(1);
This works fine on 0.23.13.
0.23.13
It shouldn't error since I'm clearly joining the tables.
I'm using Planetscale and set up the connection as follows:
import { drizzle } from "drizzle-orm/planetscale-serverless"; const connection = connect({ host: process.env.DATABASE_HOST, username: process.env.DATABASE_USERNAME, password: process.env.DATABASE_PASSWORD, }); const db = drizzle(connection);
The text was updated successfully, but these errors were encountered:
Thanks! Will check it asap
Sorry, something went wrong.
@thillmann could you test if it works with drizzle-orm@beta?
drizzle-orm@beta
@dankochetov
Sorry for the delayed response, I can confirm it works with drizzle-orm@beta!
AndriiSherman
No branches or pull requests
What version of
drizzle-orm
are you using?0.25.4
What version of
drizzle-kit
are you using?0.17.6
Describe the Bug
After updating to the latest version of
drizzle-orm
, my left joins are not working anymore.Every time I run a query that includes a join it just errors with:
I have two tables for
users
andaccounts
like this:And then a query trying to join them like this:
This works fine on
0.23.13
.Expected behavior
It shouldn't error since I'm clearly joining the tables.
Environment & setup
I'm using Planetscale and set up the connection as follows:
The text was updated successfully, but these errors were encountered: