fix(export-sql): move from AI sql-export for sqlite to deterministic script (#627)

This commit is contained in:
Jonathan Fishner
2025-03-20 11:17:30 +02:00
committed by GitHub
parent 18f228ca1d
commit 897ac60a82
2 changed files with 374 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import type { DataType } from '../data-types/data-types';
import { generateCacheKey, getFromCache, setInCache } from './export-sql-cache';
import { exportMSSQL } from './export-per-type/mssql';
import { exportPostgreSQL } from './export-per-type/postgresql';
import { exportSQLite } from './export-per-type/sqlite';
export const exportBaseSQL = ({
diagram,
@@ -38,6 +39,14 @@ export const exportBaseSQL = ({
return exportPostgreSQL(diagram);
}
if (
!isDBMLFlow &&
diagram.databaseType === DatabaseType.SQLITE &&
targetDatabaseType === DatabaseType.SQLITE
) {
return exportSQLite(diagram);
}
// Filter out the tables that are views
const nonViewTables = tables.filter((table) => !table.isView);
@@ -288,6 +297,13 @@ export const exportSQL = async (
return sqlScript;
}
if (
databaseType === DatabaseType.SQLITE &&
diagram.databaseType === DatabaseType.SQLITE
) {
return sqlScript;
}
const cacheKey = await generateCacheKey(databaseType, sqlScript);
const cachedResult = getFromCache(cacheKey);