feat(db): implement SqlDialect with MySQL, SQL Server, PostgreSQL dialects
Add three SqlDialect implementations with a factory function: - MySqlDialect: positional ?, ON DUPLICATE KEY UPDATE, LIMIT/OFFSET - SqlServerDialect: @pN params, MERGE USING, OFFSET/FETCH - PostgreSqlDialect: $N (1-based), ON CONFLICT DO UPDATE, LIMIT/OFFSET TDD approach: 43 tests written first, all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
27
src/main/services/database/dialects/index.ts
Normal file
27
src/main/services/database/dialects/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* SQL Dialect Factory
|
||||
*
|
||||
* Creates the appropriate SqlDialect implementation based on database type.
|
||||
*/
|
||||
|
||||
import type { DatabaseType } from '@types/database.types'
|
||||
import type { SqlDialect } from '@types/sql-dialect.types'
|
||||
|
||||
import { MySqlDialect } from './mysql-dialect'
|
||||
import { PostgreSqlDialect } from './postgresql-dialect'
|
||||
import { SqlServerDialect } from './sqlserver-dialect'
|
||||
|
||||
export { MySqlDialect } from './mysql-dialect'
|
||||
export { PostgreSqlDialect } from './postgresql-dialect'
|
||||
export { SqlServerDialect } from './sqlserver-dialect'
|
||||
|
||||
export function createDialect(type: DatabaseType): SqlDialect {
|
||||
switch (type) {
|
||||
case 'sqlserver':
|
||||
return new SqlServerDialect()
|
||||
case 'postgresql':
|
||||
return new PostgreSqlDialect()
|
||||
default:
|
||||
return new MySqlDialect()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user