import { DatabaseClient, PooledConnection, QueryResult, QueryExecutionOptions } from './database-client.interface'; import type { BunSqlOptions } from './types'; type BunSql = any; /** * DatabaseClient implementation for Bun's built-in SQL client * @see https://bun.sh/docs/api/sql * * NOTE: This requires Bun runtime. The SQL client is built into Bun. * Supports PostgreSQL, MySQL, and SQLite. */ export declare class BunClient extends DatabaseClient { private sql; private ownsConnection; /** * True when the client was constructed with `prepare: false` — Bun then uses * unnamed statements with TEXT-format results, whose array decoding is * correct (the binary decoder panics / mis-shapes arrays, see * supportsBinaryArrayResults). Conservatively false for pre-built instances * and connection strings, where the prepare mode is unknown. */ private usesTextResults; /** See BunSqlOptions.datesAsStrings — linkgress-level Date→PG-text conversion. */ private datesAsStrings; /** * Create a BunClient * @param config - Either a connection string, BunSqlOptions config object, or an existing Bun SQL instance * * @example * ```typescript * // Connection string * const client = new BunClient("postgres://user:pass@localhost:5432/mydb"); * * // Options object * const client = new BunClient({ * hostname: "localhost", * port: 5432, * database: "mydb", * username: "user", * password: "pass", * }); * * // Existing SQL instance * import { SQL } from "bun"; * const sql = new SQL("postgres://..."); * const client = new BunClient(sql); * ``` */ constructor(config: string | BunSqlOptions | BunSql); query(sql: string, params?: any[], _options?: QueryExecutionOptions): Promise>; connect(): Promise; end(): Promise; getDriverName(): string; /** * Execute a callback within a transaction. * Uses Bun SQL's built-in sql.begin() for proper transaction handling. */ transaction(callback: (query: (sql: string, params?: any[]) => Promise) => Promise): Promise; /** * Bun SQL supports multiple SQL statements using .simple() mode * This allows true single round-trip optimization */ supportsMultiStatementQueries(): boolean; /** * Normalize a Bun `.simple()` result into an array of result sets. * * For a SINGLE statement, `.simple()` returns the result set itself (an * array of row objects); for MULTIPLE statements it returns an array with * one result set per statement. Distinguish by element shape — a result * set's elements are row objects, never arrays. */ private static normalizeSimpleResultSets; /** * Execute a multi-statement query using the simple protocol * This bypasses prepared statements and allows multiple statements * WARNING: Only use with safe, validated inputs! */ querySimple(sql: string): Promise>; /** * Execute a multi-statement query and return ALL result sets * Used for fully optimized single-query execution */ querySimpleMulti(sql: string): Promise; /** * Bun SQL automatically uses binary protocol where appropriate * No explicit toggle needed */ supportsBinaryProtocol(): boolean; /** * Bun ≤ 1.3.14 cannot decode BINARY array result columns (alignment panic / * object-shaped arrays — see debug/bun-sql-binary-array-repro.ts), so by * default query builders aggregate via json_agg instead of array_agg. * * With `prepare: false`, Bun uses unnamed statements with TEXT-format * results whose array decoding is correct — native arrays work and the * panic surface disappears entirely (raw SQL included), at ~0.05ms/query * re-parse cost. In that mode this returns true and strategies keep * array_agg. */ supportsBinaryArrayResults(): boolean; /** * Get access to the underlying Bun SQL instance for advanced use cases */ getSql(): BunSql; } export {}; //# sourceMappingURL=bun-client.d.ts.map