You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a query such as the one below the table is named agent_activity so when I reference it as schema.agentActivity in the subquery that gets generated as agent_activity, but the drizzle.query.agentActivity includes an alias for agentActivity, not the same as the name used in the subquery, so I have to put in a manual alias so that the names line up
// schema.ts (relevant excerpt)exportconstagentActivity=pgTable("agent_activity",{id: uuid("id").default(sql`uuid_generate_v4()`).primaryKey().notNull(),agentId: uuid("agent_id").notNull().references(()=>agents.id,{onDelete: "cascade",onUpdate: "cascade"}),});exportconstagentActivityResult=pgTable("agent_activity_result",{id: uuid("id").default(sql`uuid_generate_v4()`).primaryKey().notNull(),activityId: uuid("activity_id").notNull().references(()=>agentActivity.id,{onDelete: "cascade",onUpdate: "cascade"}),});// My query:constactivities=awaitdrizzle.query.agentActivity.findMany({where: and(eq(schema.agentActivity.agentId,"some-uuid"),notExists(drizzle.select().from(schema.agentActivityResult).where(// HACK: drizzle.query.agentActivity aliases the table as "agentActivity", but this subquery by default calls it "agent_activity" so we hack around...eq(schema.agentActivityResult.activityId,alias(schema.agentActivity,"agentActivity").id),),),),});
This example was copied out of my code (with some omissions), but an equivalent will be similar I'm sure. I can provide a minimal reproduction if necessary
Expected behavior
The default names of aliases should be the same in the drizzle.query API as in the regular query builder so that this query works by default without needing alias
Environment & setup
This issue is in the query builder level, I am querying on a PostgreSQL database.
The text was updated successfully, but these errors were encountered:
What version of
drizzle-orm
are you using?0.30.10
What version of
drizzle-kit
are you using?0.21.4
Describe the Bug
In a query such as the one below the table is named
agent_activity
so when I reference it asschema.agentActivity
in the subquery that gets generated asagent_activity
, but thedrizzle.query.agentActivity
includes an alias foragentActivity
, not the same as the name used in the subquery, so I have to put in a manual alias so that the names line upThis example was copied out of my code (with some omissions), but an equivalent will be similar I'm sure. I can provide a minimal reproduction if necessary
Expected behavior
The default names of aliases should be the same in the
drizzle.query
API as in the regular query builder so that this query works by default without needingalias
Environment & setup
This issue is in the query builder level, I am querying on a PostgreSQL database.
The text was updated successfully, but these errors were encountered: