mirror of
https://github.com/chartdb/chartdb.git
synced 2025-11-05 06:23:17 +00:00
fix(dbml-editor): dealing with dbml editor for non-generic db-type (#624)
* fix(dbml-editor): dealing with dbml editor for non-generic db-type * small change * Handle ENUM type when exporting as varchar --------- Co-authored-by: Guy Ben-Aharon <baguy3@gmail.com>
This commit is contained in:
@@ -6,14 +6,17 @@ import type { DataType } from '../data-types/data-types';
|
||||
import { generateCacheKey, getFromCache, setInCache } from './export-sql-cache';
|
||||
import { exportMSSQL } from './export-per-type/mssql';
|
||||
|
||||
export const exportBaseSQL = (diagram: Diagram): string => {
|
||||
export const exportBaseSQL = (
|
||||
diagram: Diagram,
|
||||
isDBMLFlow: boolean = false
|
||||
): string => {
|
||||
const { tables, relationships } = diagram;
|
||||
|
||||
if (!tables || tables.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (diagram.databaseType === DatabaseType.SQL_SERVER) {
|
||||
if (!isDBMLFlow && diagram.databaseType === DatabaseType.SQL_SERVER) {
|
||||
return exportMSSQL(diagram);
|
||||
}
|
||||
|
||||
@@ -72,6 +75,11 @@ export const exportBaseSQL = (diagram: Diagram): string => {
|
||||
table.fields.forEach((field, index) => {
|
||||
let typeName = field.type.name;
|
||||
|
||||
// Handle ENUM type
|
||||
if (typeName.toLowerCase() === 'enum') {
|
||||
typeName = 'varchar';
|
||||
}
|
||||
|
||||
// Temp fix for 'array' to be text[]
|
||||
if (typeName.toLowerCase() === 'array') {
|
||||
typeName = 'text[]';
|
||||
|
||||
Reference in New Issue
Block a user