orchid-orm 1.56.5 → 1.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { promptSelect, getSchemaAndTableFromName, getDbTableColumnsChecks, dbColumnToAst, instantiateDbColumn, concatSchemaAndName, encodeColumnDefault, getIndexName, getExcludeName, getConstraintName, tableToAst, getDbStructureTableData, makeDomainsMap, astToMigration, createMigrationInterface, introspectDbSchema, makeStructureToAstCtx, makeFileVersion, writeMigrationFile, migrateAndClose, migrate, structureToAst, saveMigratedVersion, rakeDbCommands } from 'rake-db';
2
- import { colors, toSnakeCase, deepCompare, emptyArray, toArray, exhaustive, toCamelCase, addCode, pluralize, codeToString, toPascalCase, getImportPath, singleQuote, quoteObjectKey, pathToLog } from 'orchid-core';
2
+ import { colors, toSnakeCase, deepCompare, emptyArray, toArray, getFreeSetAlias, exhaustive, toCamelCase, addCode, pluralize, codeToString, toPascalCase, getImportPath, singleQuote, quoteObjectKey, pathToLog } from 'orchid-core';
3
3
  import { EnumColumn, ArrayColumn, getColumnBaseType, RawSQL, VirtualColumn, DomainColumn, UnknownColumn, defaultSchemaConfig, columnsShapeToCode, pushTableDataCode } from 'pqb';
4
4
  import path from 'node:path';
5
5
  import { pathToFileURL } from 'url';
@@ -1282,7 +1282,7 @@ const collectCodeComparableItemsType = (config, codeItems, key) => {
1282
1282
  ...codeItem.options,
1283
1283
  include: codeItem.options.include === void 0 ? void 0 : config.snakeCase ? toArray(codeItem.options.include).map(toSnakeCase) : toArray(codeItem.options.include),
1284
1284
  columns: codeItem.columns,
1285
- name: codeItem.name,
1285
+ name: codeItem.options.name,
1286
1286
  columnKeys: codeItem.columnKeys,
1287
1287
  includeKeys: codeItem.includeKeys
1288
1288
  });
@@ -1414,8 +1414,7 @@ const handleItemChange = ({
1414
1414
  const column = changingColumns[dbColumn.column];
1415
1415
  if (column) {
1416
1416
  ((_a = column.from.data)[key] ?? (_a[key] = [])).push({
1417
- options: dbItem,
1418
- name,
1417
+ options: { ...dbItem, name },
1419
1418
  with: key === "indexes" ? void 0 : dbColumn.with
1420
1419
  });
1421
1420
  return;
@@ -1423,8 +1422,7 @@ const handleItemChange = ({
1423
1422
  }
1424
1423
  ((_b = changeTableAst.drop)[key] ?? (_b[key] = [])).push({
1425
1424
  columns: dbColumns,
1426
- options: dbItem,
1427
- name
1425
+ options: { ...dbItem, name }
1428
1426
  });
1429
1427
  } else if (rename) {
1430
1428
  delayedAst.push({
@@ -1781,14 +1779,7 @@ const collectCodeChecks = ({
1781
1779
  const baseName = `${codeTable.table}_${columnName}_check`;
1782
1780
  codeChecks.push(
1783
1781
  ...column.data.checks.map((check) => {
1784
- let name = check.name;
1785
- if (!name) {
1786
- name = baseName;
1787
- let n = 0;
1788
- while (names.has(name)) {
1789
- name = baseName + ++n;
1790
- }
1791
- }
1782
+ const name = check.name || getFreeSetAlias(names, baseName, 1);
1792
1783
  names.add(name);
1793
1784
  return {
1794
1785
  check,
@@ -1803,14 +1794,7 @@ const collectCodeChecks = ({
1803
1794
  const { check } = constraint;
1804
1795
  if (check) {
1805
1796
  const baseName = `${codeTable.table}_check`;
1806
- let name = constraint.name;
1807
- if (!name) {
1808
- name = baseName;
1809
- let n = 0;
1810
- while (names.has(name)) {
1811
- name = baseName + ++n;
1812
- }
1813
- }
1797
+ const name = constraint.name || getFreeSetAlias(names, baseName, 1);
1814
1798
  names.add(name);
1815
1799
  codeChecks.push({
1816
1800
  check: { sql: check, name: constraint.name },