Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 105x 99x 99x 6x 6x 5x 1x | /**
* Database executors for different database engines
* Handles SQL execution with proper type coercion
*/
export { BaseDatabaseExecutor } from './base-executor'
export { PostgresExecutor, createPostgresExecutor } from './postgres-executor'
export { MySQLExecutor, createMySQLExecutor } from './mysql-executor'
export { SQLiteExecutor, createSQLiteExecutor } from './sqlite-executor'
export { SingleStoreExecutor, createSingleStoreExecutor } from './singlestore-executor'
// Re-export factory function for auto-detection
import type { DrizzleDatabase, DatabaseExecutor } from '../types'
import { createPostgresExecutor } from './postgres-executor'
import { createMySQLExecutor } from './mysql-executor'
import { createSQLiteExecutor } from './sqlite-executor'
import { createSingleStoreExecutor } from './singlestore-executor'
/**
* Auto-detect database type and create appropriate executor
* @param db - Drizzle database instance
* @param schema - Optional schema for type inference
* @param engineType - Optional explicit engine type override
* @returns Appropriate database executor
*/
export function createDatabaseExecutor(
db: DrizzleDatabase,
schema?: any,
engineType?: 'postgres' | 'mysql' | 'sqlite' | 'singlestore'
): DatabaseExecutor {
// If engine type is explicitly provided, use it
if (engineType) {
switch (engineType) {
case 'postgres':
return createPostgresExecutor(db, schema)
case 'mysql':
return createMySQLExecutor(db, schema)
case 'sqlite':
return createSQLiteExecutor(db, schema)
case 'singlestore':
return createSingleStoreExecutor(db, schema)
}
}
// Auto-detect based on available methods
Iif (db.all && db.run) {
// SQLite has synchronous methods
return createSQLiteExecutor(db, schema)
} else if (db.execute) {
// PostgreSQL and MySQL have async execute method
// We default to PostgreSQL since it's more common
return createPostgresExecutor(db, schema)
} else {
throw new Error('Unable to determine database engine type. Please specify engineType parameter.')
}
} |