import { entityKind } from 'drizzle-orm/entity'; import type { Logger } from 'drizzle-orm/logger'; import { PgTransaction } from 'drizzle-orm/pg-core'; import type { PgColumn } from 'drizzle-orm/pg-core'; import type { PgSelectBuilder, SelectedFields } from 'drizzle-orm/pg-core/query-builders'; import type { SelectedFieldsOrdered } from 'drizzle-orm/pg-core/query-builders/select.types'; import type { PgTransactionConfig, PreparedQueryConfig, PgQueryResultHKT } from 'drizzle-orm/pg-core/session'; import { PgPreparedQuery, PgSession } from 'drizzle-orm/pg-core/session'; import type { RelationalSchemaConfig, TablesRelationalConfig } from 'drizzle-orm/relations'; import { type Query, SQL, type SQLWrapper } from 'drizzle-orm/sql/sql'; import type { WithSubquery } from 'drizzle-orm/subquery'; import type { Assume } from 'drizzle-orm/utils'; import type { DuckDBDialect } from './dialect.ts'; import type { DuckDBClientLike, RowData } from './client.ts'; import { type ExecuteBatchesRawChunk, type ExecuteInBatchesOptions } from './client.ts'; import type { PreparedStatementCacheConfig } from './options.ts'; import { type DuckDBSelectBuilder } from './select-builder.ts'; export type { DuckDBClientLike, RowData } from './client.ts'; type QueryMetadata = { type: 'select' | 'update' | 'delete' | 'insert'; tables: string[]; }; type CacheConfig = { enable?: boolean; autoInvalidate?: boolean; tag?: string; config?: unknown; }; export declare class DuckDBPreparedQuery extends PgPreparedQuery { private client; private dialect; private queryString; private params; private logger; private fields; private _isResponseInArrayMode; private customResultMapper; private rejectStringArrayLiterals; private prepareCache; private warnOnStringArrayLiteral?; private scalarParamIndexes?; private onStatementError?; private decimalMode; static readonly [entityKind]: string; private resultMapper?; constructor(client: DuckDBClientLike, dialect: DuckDBDialect, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper: ((rows: unknown[][]) => T['execute']) | undefined, rejectStringArrayLiterals: boolean, prepareCache: PreparedStatementCacheConfig | undefined, queryMetadata?: QueryMetadata, cacheConfig?: CacheConfig, warnOnStringArrayLiteral?: ((sql: string) => void) | undefined, scalarParamIndexes?: ReadonlySet | undefined, onStatementError?: ((error: unknown) => void) | undefined, decimalMode?: 'number' | 'string'); execute(placeholderValues?: Record | undefined): Promise; private executeQuery; all(placeholderValues?: Record | undefined): Promise; isResponseInArrayMode(): boolean; } export interface DuckDBSessionOptions { decimalMode?: 'number' | 'string'; logger?: Logger; rejectStringArrayLiterals?: boolean; arrayLiteralWarning?: (query: string) => void; prepareCache?: PreparedStatementCacheConfig; } export declare class DuckDBSession = Record, TSchema extends TablesRelationalConfig = Record> extends PgSession { private client; private schema; private options; static readonly [entityKind]: string; protected dialect: DuckDBDialect; private logger; private rejectStringArrayLiterals; private prepareCache; private hasWarnedArrayLiteral; private rollbackOnly; private statementFailures; constructor(client: DuckDBClientLike, dialect: DuckDBDialect, schema: RelationalSchemaConfig | undefined, options?: DuckDBSessionOptions); prepareQuery(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute'], queryMetadata?: QueryMetadata, cacheConfig?: CacheConfig): PgPreparedQuery; transaction(transaction: (tx: DuckDBTransaction) => Promise, config?: PgTransactionConfig): Promise; private warnOnStringArrayLiteral; private recordStatementFailure; /** * DuckDB keeps parser and binder failures recoverable but aborts the * transaction on execution failures. COMMIT then succeeds without saving * anything, so probe the transaction before committing. */ private assertTransactionNotAborted; private rollbackQuietly; private prepareQueryExecution; private trackStreamFailures; executeBatches(query: SQL, options?: ExecuteInBatchesOptions): AsyncGenerator[], void, void>; executeBatchesRaw(query: SQL, options?: ExecuteInBatchesOptions): AsyncGenerator; executeArrow(query: SQL): Promise; markRollbackOnly(): void; isRollbackOnly(): boolean; } export declare class DuckDBTransaction, TSchema extends TablesRelationalConfig> extends PgTransaction { static readonly [entityKind]: string; constructor(dialect: DuckDBDialect, session: DuckDBSession, schema: RelationalSchemaConfig | undefined, nestedIndex?: number); private getInternals; private markRollbackOnly; private selectMethods; with(...queries: WithSubquery[]): ReturnType['with']>; select(): DuckDBSelectBuilder; select(fields: TSelection): DuckDBSelectBuilder; selectDistinct(): PgSelectBuilder; selectDistinct(fields: TSelection): PgSelectBuilder; selectDistinctOn(on: (PgColumn | SQLWrapper)[]): PgSelectBuilder; selectDistinctOn(on: (PgColumn | SQLWrapper)[], fields: TSelection): PgSelectBuilder; rollback(): never; /** * @deprecated DuckDB has no SET TRANSACTION statement, so transaction config * is ignored. This helper will be removed in the next major version. */ getTransactionConfigSQL(config: PgTransactionConfig): SQL; /** * @deprecated DuckDB has no SET TRANSACTION statement. This method is a * no-op that warns once, and passing config will throw in the next major * version. */ setTransaction(config: PgTransactionConfig): Promise; executeBatches(query: SQL, options?: ExecuteInBatchesOptions): AsyncGenerator[], void, void>; executeBatchesRaw(query: SQL, options?: ExecuteInBatchesOptions): AsyncGenerator; executeArrow(query: SQL): Promise; transaction(transaction: (tx: DuckDBTransaction) => Promise): Promise; private runNestedWithoutSavepoint; } export type GenericRowData = T; export type GenericTableData = T[]; export interface DuckDBQueryResultHKT extends PgQueryResultHKT { type: GenericTableData>; }