fix(dameng): emit modify syntax for column changes

Closes #8517
This commit is contained in:
t8y2 committed 2026-09-09 10:28:03 +08:00
1 parent 9690feee4f
commit 7835f4c309
2 files changed
+25 -2

No files matched your search

+10 -1
View File
@@ -5757,8 +5757,9 @@ fn generate_schema_sync_sql_inner(
}
} else if profile.alter_uses_modify_column {
if column.changes.iter().any(|change| !change.starts_with("order:")) {
let modify_keyword = profile.alter_modify_keyword();
parts.push(format!(
" MODIFY COLUMN {}",
" {modify_keyword} {}",
column_def(&mapped, db_type, source_dialect)
));
}
@@ -8145,6 +8146,14 @@ mod tests {
}
}
#[test]
fn dameng_modify_column_uses_modify_without_column_keyword() {
let diffs = make_col_diffs(&[("name", "varchar(64)")], &[("name", "varchar(32)")], false);
let sql = gen_sql(wrap_table_diff("tbxx", diffs), DatabaseType::Dameng, None);
assert!(sql.contains("MODIFY NAME varchar(64)"), "Dameng modify: {sql}");
assert!(!sql.contains("MODIFY COLUMN"), "Dameng must omit COLUMN: {sql}");
}
// -- 25. Rename with nullable change --
#[test]
fn rename_with_nullable_change() {
+15 -1
View File
@@ -209,6 +209,14 @@ impl DdlDialectProfile {
}
}
pub fn alter_modify_keyword(&self) -> &'static str {
if self.database_type == DatabaseType::Dameng {
"MODIFY"
} else {
"MODIFY COLUMN"
}
}
/// Replace `{key}` placeholders. Unknown keys are left unchanged.
pub fn render_template(template: &str, vars: &[(&str, &str)]) -> String {
let mut out = template.to_string();
@@ -759,6 +767,12 @@ pub fn profile_for(db_type: DatabaseType) -> DdlDialectProfile {
// MySQL family
Mysql | Doris | StarRocks | Goldendb | Sundb | Databend | Gbase | ManticoreSearch => mysql_family(db_type),
Dameng => {
let mut profile = oracle_family(db_type);
profile.alter_uses_modify_column = true;
profile
}
// PostgreSQL family
Postgres | Redshift | Gaussdb | Kingbase | Highgo | Vastbase | OpenGauss | Kwdb | Uxdb => {
postgres_family(db_type)
@@ -775,7 +789,7 @@ pub fn profile_for(db_type: DatabaseType) -> DdlDialectProfile {
}
// Oracle family
Oracle | Dameng | OceanbaseOracle | Yashandb | Xugu | Iris => oracle_family(db_type),
Oracle | OceanbaseOracle | Yashandb | Xugu | Iris => oracle_family(db_type),
// SQL Server (not Access)
SqlServer => sqlserver_family(db_type),