/** * SQL Server 数据库适配器 * 使用 mssql 驱动实现 DbAdapter 接口 * 支持 SQL Server 2012+ 和 Azure SQL Database * * 性能优化:使用批量查询获取 Schema 信息,避免 N+1 查询问题 */ import { BaseAdapter, ExecuteScriptOptions, TransactionContext } from './base.js'; import type { QueryResult, SchemaInfo } from '../types/adapter.js'; export declare class SQLServerAdapter extends BaseAdapter { private pool; private config; constructor(config: { host: string; port: number; user?: string; password?: string; database?: string; poolConfig?: { max?: number; min?: number; idleTimeoutMs?: number; }; }); /** * 连接到 SQL Server 数据库 */ connect(): Promise; /** * 断开数据库连接 */ disconnect(): Promise; /** * 执行 SQL 查询 */ executeQuery(query: string, params?: unknown[]): Promise; /** * 获取数据库结构信息(批量查询优化版本) */ getSchema(): Promise; private makeTableKey; /** * 组装 Schema 信息 */ private assembleSchema; /** * 格式化 SQL Server 数据类型 */ private formatSQLServerType; /** * P0-3: Override withTransaction to pin all statements to a single physical connection * via mssql's Transaction API. Without this, BEGIN/COMMIT and individual statements * could end up on different pooled connections, breaking "all-or-nothing" semantics. * * mssql's transaction API is callback-based but returns a promise when called * without a callback, so we can use await directly. */ withTransaction(fn: (tx: TransactionContext) => Promise): Promise; /** * P0-3: Override executeScript to use withTransaction. * All statements run on a single connection so BEGIN/COMMIT are atomic. * Non-transactional mode falls back to the BaseAdapter default. */ executeScript(query: string, options?: ExecuteScriptOptions): Promise; /** * 检查是否为写操作 */ isWriteOperation(query: string): boolean; protected getDialect(): import('../utils/adapter-factory.js').DbType; } //# sourceMappingURL=sqlserver.d.ts.map