@dbml/core
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -12,2 +12,3 @@ "use strict"; | ||
var _SqlServerExporter = _interopRequireDefault(require("./SqlServerExporter")); | ||
var _OracleExporter = _interopRequireDefault(require("./OracleExporter")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -28,3 +29,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var format = arguments.length > 1 ? arguments[1] : undefined; | ||
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var isNormalized = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; | ||
@@ -49,2 +50,5 @@ var res = ''; | ||
break; | ||
case 'oracle': | ||
res = _OracleExporter["default"]["export"](normalizedModel); | ||
break; | ||
default: | ||
@@ -51,0 +55,0 @@ break; |
@@ -9,2 +9,4 @@ "use strict"; | ||
exports.buildNewTableName = buildNewTableName; | ||
exports.buildUniqueTableName = buildUniqueTableName; | ||
exports.escapeObjectName = escapeObjectName; | ||
exports.hasWhiteSpace = hasWhiteSpace; | ||
@@ -28,3 +30,3 @@ exports.shouldPrintSchema = shouldPrintSchema; | ||
var fieldsMap = new Map(); | ||
fieldIds.map(function (fieldId) { | ||
fieldIds.forEach(function (fieldId) { | ||
var fieldName = "".concat(model.tables[model.fields[fieldId].tableId].name, "_").concat(model.fields[fieldId].name); | ||
@@ -49,2 +51,43 @@ var count = 1; | ||
return newTableName; | ||
} | ||
/** | ||
* | ||
* @param {string} schemaName | ||
* @param {string} firstTableName | ||
* @param {string} secondTableName | ||
* @param {Map<string, Set>} schemaToTableNameSetMap | ||
* @returns string | ||
* @description This function is a clone version of the buildNewTableName, but without side effect - update the original usedTableNames | ||
*/ | ||
function buildUniqueTableName(schemaName, firstTableName, secondTableName, schemaToTableNameSetMap) { | ||
var newTableName = "".concat(firstTableName, "_").concat(secondTableName); | ||
var count = 1; | ||
var tableNameSet = schemaToTableNameSetMap.get(schemaName); | ||
if (!tableNameSet) { | ||
return newTableName; | ||
} | ||
while (tableNameSet.has(newTableName)) { | ||
newTableName = "".concat(firstTableName, "_").concat(secondTableName, "(").concat(count, ")"); | ||
count += 1; | ||
} | ||
return newTableName; | ||
} | ||
function escapeObjectName(name, database) { | ||
if (!name) { | ||
return ''; | ||
} | ||
var escapeSignature = ''; | ||
switch (database) { | ||
case 'mysql': | ||
escapeSignature = '`'; | ||
break; | ||
case 'postgres': | ||
case 'oracle': | ||
escapeSignature = '"'; | ||
break; | ||
default: | ||
break; | ||
} | ||
return "".concat(escapeSignature).concat(name).concat(escapeSignature); | ||
} |
{ | ||
"name": "@dbml/core", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "> TODO: description", | ||
@@ -35,3 +35,3 @@ "author": "Holistics <dev@holistics.io>", | ||
"dependencies": { | ||
"@dbml/parse": "^3.3.0", | ||
"@dbml/parse": "^3.4.0", | ||
"antlr4": "^4.13.1", | ||
@@ -63,3 +63,3 @@ "lodash": "^4.17.15", | ||
}, | ||
"gitHead": "4594bf6ee08c4bc73498f919673b12a4ecf06359" | ||
"gitHead": "d46067f19bf80a245c77576106dac68bec5cbe5a" | ||
} |
@@ -1,2 +0,4 @@ | ||
declare function _export(str: string, format: 'dbml' | 'mysql' | 'postgres' | 'json' | 'mssql'): string; | ||
import { ExportFormatOption } from './ModelExporter'; | ||
declare function _export(str: string, format: ExportFormatOption): string; | ||
declare const _default: { | ||
@@ -3,0 +5,0 @@ export: typeof _export; |
import Database, { NormalizedDatabase } from '../model_structure/database'; | ||
export type ExportFormatOption = 'dbml' | 'mysql' | 'postgres' | 'json' | 'mssql' | 'oracle'; | ||
declare class ModelExporter { | ||
static export(model: Database | NormalizedDatabase, format: 'dbml' | 'mysql' | 'postgres' | 'json' | 'mssql', isNormalized?: boolean): string; | ||
static export(model: Database | NormalizedDatabase, format: ExportFormatOption, isNormalized?: boolean): string; | ||
} | ||
export default ModelExporter; |
9296563
135
41981
Updated@dbml/parse@^3.4.0