fix: add PostgreSQL tests and fix parsing SQL (#760)

* feat: add PostgreSQL tests and fix parsing SQL

* fix: disable format on paste for SQL DDL import

* some ui fixes + add tests to the ci

* fix

* fix validator and importer

* fix for maria-db

* fix

* remove improved

* fix

* fix

* fix

* fix for test

---------

Co-authored-by: Guy Ben-Aharon <baguy3@gmail.com>
This commit is contained in:
Jonathan Fishner
2025-07-14 19:25:44 +03:00
committed by GitHub
parent 67f5ac303e
commit 5d337409d6
63 changed files with 9804 additions and 1094 deletions

View File

@@ -146,13 +146,42 @@ function processForeignKeyConstraint(
// Look up table IDs
const sourceTableKey = `${sourceSchema ? sourceSchema + '.' : ''}${sourceTable}`;
const sourceTableId = tableMap[sourceTableKey];
let sourceTableId = tableMap[sourceTableKey];
const targetTableKey = `${targetSchema ? targetSchema + '.' : ''}${targetTable}`;
const targetTableId = tableMap[targetTableKey];
let targetTableId = tableMap[targetTableKey];
if (!sourceTableId || !targetTableId) {
return;
// Try without schema if not found
if (!sourceTableId && sourceSchema) {
sourceTableId = tableMap[sourceTable];
}
if (!targetTableId && targetSchema) {
targetTableId = tableMap[targetTable];
}
// If still not found, try with 'public' schema
if (!sourceTableId && !sourceSchema) {
sourceTableId = tableMap[`public.${sourceTable}`];
}
if (!targetTableId && !targetSchema) {
targetTableId = tableMap[`public.${targetTable}`];
}
// If we still can't find them, log and return
if (!sourceTableId || !targetTableId) {
if (!sourceTableId) {
console.warn(
`No table ID found for source table: ${sourceTable} (tried: ${sourceTableKey}, ${sourceTable}, public.${sourceTable})`
);
}
if (!targetTableId) {
console.warn(
`No table ID found for target table: ${targetTable} (tried: ${targetTableKey}, ${targetTable}, public.${targetTable})`
);
}
return;
}
}
// Create relationships for each column pair