fix(schema-diff): correct Oracle/JDBC column, index and view diffs
This commit is contained in:
7 files changed
+1095
-95
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { ColumnInfo, IndexInfo, ForeignKeyInfo, TriggerInfo, FunctionInfo, SequenceInfo, RuleInfo, OwnerInfo, DatabaseType, TableInfo } from "@/types/database";
|
||||
import type { ColumnInfo, IndexInfo, ForeignKeyInfo, TriggerInfo, FunctionInfo, SequenceInfo, RuleInfo, OwnerInfo, DatabaseType, TableInfo, ConnectionConfig } from "@/types/database";
|
||||
import type { SchemaDiffTableMapping } from "@/types/schemaDiff";
|
||||
import { effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
|
||||
import { splitSqlStatementRanges } from "@/lib/sql/sqlStatementRanges";
|
||||
|
||||
const DIALECT_KIND_MAP: Record<string, string> = {
|
||||
@@ -44,6 +45,24 @@ export function databaseTypeToDialectKind(dbType: DatabaseType): string {
|
||||
return DIALECT_KIND_MAP[dbType] ?? "unsupported";
|
||||
}
|
||||
|
||||
/** The connection fields the JDBC product inference reads. */
|
||||
export type SchemaDiffDialectConnection = Partial<Pick<ConnectionConfig, "db_type" | "driver_profile" | "driver_label" | "connection_string" | "url_params" | "jdbc_driver_class" | "jdbc_driver_paths" | "database_info" | "external_config" | "username">>;
|
||||
|
||||
/**
|
||||
* Product type the schema-diff engine must treat a connection as.
|
||||
*
|
||||
* A JDBC connection stores the generic `jdbc` in `db_type`, but the engine keys its clause
|
||||
* shapes, index rules and view comparison off the product type — diffing a JDBC Oracle
|
||||
* connection as `jdbc` emits ANSI/MySQL clauses for it and never compares its view text.
|
||||
* The product is resolved from the driver profile/URL exactly like the metadata and query
|
||||
* paths already resolve it; every other connection keeps its own `db_type`.
|
||||
*/
|
||||
export function schemaDiffEngineDatabaseType(connection: SchemaDiffDialectConnection | undefined): DatabaseType | undefined {
|
||||
if (!connection?.db_type) return undefined;
|
||||
if (connection.db_type !== "jdbc") return connection.db_type as DatabaseType;
|
||||
return effectiveDatabaseTypeForConnection(connection) ?? (connection.db_type as DatabaseType);
|
||||
}
|
||||
|
||||
const DIALECT_ALIAS_MAP: Record<string, string> = {
|
||||
access: "sql_server",
|
||||
mssql: "sql_server",
|
||||
|
||||
Reference in new issue
Block a user