File tree Expand file tree Collapse file tree
packages/orm/src/client/executor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -817,7 +817,10 @@ export class QueryNameMapper extends OperationNodeTransformer {
817817
818818 private processEnumSelection ( selection : SelectionNodeChild , fieldName : string ) {
819819 const { alias, node } = stripAlias ( selection ) ;
820- const fieldScope = this . resolveFieldFromScopes ( fieldName ) ;
820+ const fieldScope = this . resolveFieldFromScopes (
821+ fieldName ,
822+ ReferenceNode . is ( node ) ? node . table ?. table ?. identifier . name : undefined ,
823+ ) ;
821824 if ( ! fieldScope || ! fieldScope . model ) {
822825 return selection ;
823826 }
Original file line number Diff line number Diff line change 1+ import { createTestClient } from '@zenstackhq/testtools' ;
2+ import { describe , it } from 'vitest' ;
3+
4+ // https://github.com/zenstackhq/zenstack/issues/2825
5+ describe ( 'Regression for issue #2825' , ( ) => {
6+ it ( 'handle same column name with enum type' , async ( ) => {
7+ const schema = `
8+ enum UserStatus {
9+ OK1 @map("ok1")
10+ NO1 @map("no1")
11+
12+ @@map("user_status")
13+ }
14+
15+ enum PostStatus {
16+ OK2 @map("ok2")
17+ NO2 @map("no2")
18+
19+ @@map("post_status")
20+ }
21+
22+ model User {
23+ id Int @id @default(autoincrement())
24+ status UserStatus?
25+ posts Post[]
26+ }
27+
28+ model Post {
29+ id Int @id @default(autoincrement())
30+ status PostStatus?
31+ author User? @relation(fields: [authorId], references: [id])
32+ authorId Int
33+ }
34+ ` ;
35+
36+ const db = await createTestClient ( schema , { usePrismaPush : true , provider : 'postgresql' } ) ;
37+
38+ await db . $qb . selectFrom ( 'User as u' ) . innerJoin ( 'Post as p' , 'p.authorId' , 'u.id' ) . select ( 'u.status' ) . execute ( ) ;
39+ } ) ;
40+ } ) ;
You can’t perform that action at this time.
0 commit comments