Skip to content

Commit

Permalink
Fixed vercel session's lack of count override (fixes #3710)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukairo-02 committed Jan 9, 2025
1 parent 8e428d1 commit 6b06a03
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drizzle-orm/src/vercel-postgres/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.type
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';
import { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';
import type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';
import { fillPlaceholders, type Query, sql } from '~/sql/sql.ts';
import { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';
import { type Assume, mapResultRow } from '~/utils.ts';

export type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;
Expand Down Expand Up @@ -181,6 +181,12 @@ export class VercelPgSession<
return this.client.query<T>(query, params);
}

override async count(sql: SQL): Promise<number> {
const result = await this.execute(sql);

return Number((result as any)['rows'][0]['count']);
}

override async transaction<T>(
transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,
config?: PgTransactionConfig | undefined,
Expand Down

0 comments on commit 6b06a03

Please # to comment.