refactor: 接口 ISqlDialect 改名 SqlDialect(仓颉惯例,去掉 I 前缀,删除兼容别名,同步 README 与文件名 sql_dialect.cj)
This commit is contained in:
@@ -275,12 +275,12 @@ public open class Migration {
|
||||
}
|
||||
|
||||
/**
|
||||
* DDL SQL 工厂:MigrationOperation → SQL(类型映射与差异语法委托给 ISqlDialect)。
|
||||
* DDL SQL 工厂:MigrationOperation → SQL(类型映射与差异语法委托给 SqlDialect)。
|
||||
*/
|
||||
public class DdlFactory {
|
||||
public init() {}
|
||||
|
||||
public func toSql(op: MigrationOperation, dialect: ISqlDialect): String {
|
||||
public func toSql(op: MigrationOperation, dialect: SqlDialect): String {
|
||||
match (op.kind) {
|
||||
case MigrationOperationKind.CreateTable => createTableSql(op, dialect)
|
||||
case MigrationOperationKind.DropTable => "DROP TABLE IF EXISTS ${dialect.quoteName(op.tableName)}"
|
||||
@@ -303,7 +303,7 @@ public class DdlFactory {
|
||||
/// - 有同名列且类型一致 → AddColumn 幂等跳过(空列表);AlterColumn 保留原 SQL(处理非空/长度等变化)
|
||||
/// - 有同名列但类型不同 → 先 DROP COLUMN 再 ADD COLUMN(重建该字段)
|
||||
/// existingType 来自 information_schema.data_type;None 表示列不存在。
|
||||
public func resolveColumnSqls(op: MigrationOperation, dialect: ISqlDialect,
|
||||
public func resolveColumnSqls(op: MigrationOperation, dialect: SqlDialect,
|
||||
existingType: ?String): ArrayList<String> {
|
||||
let result = ArrayList<String>()
|
||||
let col = op.column.getOrThrow()
|
||||
@@ -369,7 +369,7 @@ public class DdlFactory {
|
||||
sb.toString()
|
||||
}
|
||||
|
||||
private func createTableSql(op: MigrationOperation, dialect: ISqlDialect): String {
|
||||
private func createTableSql(op: MigrationOperation, dialect: SqlDialect): String {
|
||||
let sb = StringBuilder()
|
||||
sb.append("CREATE TABLE IF NOT EXISTS ${dialect.quoteName(op.tableName)} (\n")
|
||||
var first = true
|
||||
@@ -384,7 +384,7 @@ public class DdlFactory {
|
||||
sb.toString()
|
||||
}
|
||||
|
||||
private func createIndexSql(op: MigrationOperation, dialect: ISqlDialect): String {
|
||||
private func createIndexSql(op: MigrationOperation, dialect: SqlDialect): String {
|
||||
let sb = StringBuilder()
|
||||
sb.append("CREATE ")
|
||||
if (op.unique) {
|
||||
@@ -406,7 +406,7 @@ public class DdlFactory {
|
||||
sb.toString()
|
||||
}
|
||||
|
||||
private func columnDefSql(col: ColumnDefinition, dialect: ISqlDialect): String {
|
||||
private func columnDefSql(col: ColumnDefinition, dialect: SqlDialect): String {
|
||||
let sb = StringBuilder()
|
||||
sb.append(dialect.quoteName(col.name))
|
||||
sb.append(" ${dialect.columnTypeSql(col.columnType, col.autoIncrement, col.maxLength)}")
|
||||
|
||||
@@ -18,10 +18,10 @@ import simcu::orm.sql.*
|
||||
*/
|
||||
public class Migrator {
|
||||
private let _datasource: Datasource
|
||||
private let _dialect: ISqlDialect
|
||||
private let _dialect: SqlDialect
|
||||
private let _historyTable = "simcu_orm_migrations"
|
||||
|
||||
public init(datasource: Datasource, dialect: ISqlDialect) {
|
||||
public init(datasource: Datasource, dialect: SqlDialect) {
|
||||
this._datasource = datasource
|
||||
this._dialect = dialect
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user