feat(mysql): edit table auto-increment counter

Closes #7065
This commit is contained in:
t8y2 committed 2026-08-25 01:24:09 +00:00
1 parent 44dc2a88f8
commit 277386ec81
13 files changed
+513 -32

No files matched your search

+15 -12
View File
@@ -1761,19 +1761,22 @@ mod tests {
#[test]
fn builds_mysql_auto_increment_sql_and_rejects_invalid_values() {
let options = MysqlAutoIncrementSqlOptions {
database_type: Some(DatabaseType::Mysql),
driver_profile: Some("mysql".to_string()),
schema: Some("sales`archive".to_string()),
table_name: "order`items".to_string(),
value: "18446744073709551615".to_string(),
};
assert_eq!(
build_mysql_auto_increment_sql(options),
Ok("ALTER TABLE `sales``archive`.`order``items` AUTO_INCREMENT = 18446744073709551615;".to_string())
);
for value in ["1", "9007199254740993", "18446744073709551615"] {
assert_eq!(
build_mysql_auto_increment_sql(MysqlAutoIncrementSqlOptions {
database_type: Some(DatabaseType::Mysql),
driver_profile: Some("mysql".to_string()),
schema: Some("sales`archive".to_string()),
table_name: "order`items".to_string(),
value: value.to_string(),
}),
Ok(format!("ALTER TABLE `sales``archive`.`order``items` AUTO_INCREMENT = {value};"))
);
}
for value in ["", "0", "01", " 1", "1 ", "+1", "-1", "1; DROP TABLE users", "18446744073709551616"] {
for value in
["", "0", "01", " 1", "1 ", "+1", "-1", "1.0", "1e3", "1; DROP TABLE users", "18446744073709551616"]
{
assert!(
build_mysql_auto_increment_sql(MysqlAutoIncrementSqlOptions {
database_type: Some(DatabaseType::Mysql),