| 128 | const onConflictDoNothing = vi.fn(() => ({ returning }) as unknown as Promise<void>) |
| 129 | |
| 130 | const whereBuilder = () => { |
| 131 | // Some call sites (e.g. `db.select().from(t).where(eq(...))` with no |
| 132 | // limit/orderBy) await the where directly. Make the builder a thenable so |
| 133 | // those calls resolve to the default empty array. |
| 134 | const thenable: any = Promise.resolve([] as unknown[]) |
| 135 | thenable.limit = limit |
| 136 | thenable.orderBy = orderBy |
| 137 | thenable.returning = returning |
| 138 | thenable.groupBy = groupBy |
| 139 | thenable.for = forClause |
| 140 | return thenable |
| 141 | } |
| 142 | const where = vi.fn(whereBuilder) |
| 143 | |
| 144 | const joinBuilder = (): { where: typeof where; innerJoin: any; leftJoin: any } => ({ |