All files / server/executors base-executor.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 1/1
100% Lines 4/4

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                                  238x 238x       238x 238x          
/**
 * Base database executor implementation
 * Abstract class for database-specific executors
 */
 
import type { SQL } from 'drizzle-orm'
import type { DrizzleDatabase, DatabaseExecutor } from '../types'
import type { DatabaseAdapter } from '../adapters/base-adapter'
import { createDatabaseAdapter } from '../database-utils'
 
/**
 * Abstract base class for database executors
 */
export abstract class BaseDatabaseExecutor implements DatabaseExecutor {
  public databaseAdapter: DatabaseAdapter
  
  constructor(
    public db: DrizzleDatabase,
    public schema?: any,
    engineType?: 'postgres' | 'mysql' | 'sqlite' | 'singlestore'
  ) {
    // Create database adapter based on engine type or auto-detect
    const actualEngineType = engineType || this.getEngineType()
    this.databaseAdapter = createDatabaseAdapter(actualEngineType)
  }
 
  abstract execute<T = any[]>(query: SQL | any, numericFields?: string[]): Promise<T>
  abstract getEngineType(): 'postgres' | 'mysql' | 'sqlite' | 'singlestore'
}