25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(firebird): order DEFAULT before NOT NULL in column DDL
t8y2b23a36b23cac
diff --git a/crates/dbx-sql-schema/src/table_structure_sql/column_format.rs b/crates/dbx-sql-schema/src/table_structure_sql/column_format.rsindex ce0501fb74..80e63c79ae 100644--- a/crates/dbx-sql-schema/src/table_structure_sql/column_format.rs+++ b/crates/dbx-sql-schema/src/table_structure_sql/column_format.rs@@ -43,6 +43,7 @@ pub(super) fn column_definition(database_type: Option<DatabaseType>,) -> String {let data_type = column_data_type(dialect, column, database_type);+ let firebird = database_type == Some(DatabaseType::Firebird);let mut parts = vec![quote_ident(dialect, &column.name), data_type];// QuestDB SQL Syntax: ```ALTER TABLE tableName ADD COLUMN [IF NOT EXISTS] columnName typeDef```if dialect == StructureDialect::Questdb {@@ -62,7 +63,7 @@ pub(super) fn column_definition(if let Some(generated_clause) = mysql_generated_clause.as_ref() {parts.push(generated_clause.clone());}- if !column.is_nullable && !is_oracle_like(dialect) && dialect != StructureDialect::ClickHouse {+ if !column.is_nullable && !is_oracle_like(dialect) && dialect != StructureDialect::ClickHouse && !firebird {parts.push("NOT NULL".to_string());} else if column.is_nullable&& dialect == StructureDialect::Mysql@@ -87,6 +88,11 @@ pub(super) fn column_definition(if dialect == StructureDialect::Oracle && !column.is_nullable && !column.is_primary_key {parts.push("NOT NULL".to_string());}+ // Firebird's column grammar is `col type [DEFAULT expr] [NOT NULL]`; emitting+ // NOT NULL first produced `NOT NULL DEFAULT ...` and failed to recreate the table.+ if firebird && !column.is_nullable {+ parts.push("NOT NULL".to_string());+ }if mysql_generated_clause.is_none() {if let Some(on_update) = column.extra.as_ref().and_then(|e| e.on_update_current_timestamp).filter(|v| *v) {if on_update && dialect == StructureDialect::Mysql {diff --git a/crates/dbx-sql-schema/src/table_structure_sql/tests.rs b/crates/dbx-sql-schema/src/table_structure_sql/tests.rsindex f1e5a8bc34..58b0e67b72 100644--- a/crates/dbx-sql-schema/src/table_structure_sql/tests.rs+++ b/crates/dbx-sql-schema/src/table_structure_sql/tests.rs@@ -1,5 +1,6 @@use super::*;use crate::models::connection::DatabaseType;+use crate::table_structure_sql::dialect::StructureDialect;use crate::types::PgPartitionKind;fn column(name: &str) -> EditableStructureColumn {@@ -10929,6 +10930,19 @@ fn pg_family_concurrent_flag_is_ignored() {}}+#[test]+fn firebird_column_default_precedes_not_null() {+ let mut col = column("raiz");+ col.data_type = "varchar(20)".to_string();+ col.is_nullable = false;+ col.default_value = "'ECF'".to_string();++ assert_eq!(+ super::column_format::column_definition(StructureDialect::Postgres, &col, Some(DatabaseType::Firebird)),+ "\"raiz\" varchar(20) DEFAULT 'ECF' NOT NULL"+ );+}+#[test]fn non_postgres_concurrent_flag_is_ignored() {for database_type in [DatabaseType::Mysql, DatabaseType::Sqlite, DatabaseType::SqlServer] {