Skip to content

Commit

Permalink
Merge pull request #3919 from drizzle-team/vercel-count-fix
Browse files Browse the repository at this point in the history
Fixed vercel session's lack of `count` override (fixes #3710)
  • Loading branch information
AndriiSherman authored Jan 23, 2025
2 parents e4cb269 + 6b06a03 commit 79df8c1
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 79df8c1

Please sign in to comment.