orchid-orm 1.56.4 → 1.57.0

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';
@@ -1781,14 +1781,7 @@ const collectCodeChecks = ({
1781
1781
  const baseName = `${codeTable.table}_${columnName}_check`;
1782
1782
  codeChecks.push(
1783
1783
  ...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
- }
1784
+ const name = check.name || getFreeSetAlias(names, baseName, 1);
1792
1785
  names.add(name);
1793
1786
  return {
1794
1787
  check,
@@ -1803,14 +1796,7 @@ const collectCodeChecks = ({
1803
1796
  const { check } = constraint;
1804
1797
  if (check) {
1805
1798
  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
- }
1799
+ const name = constraint.name || getFreeSetAlias(names, baseName, 1);
1814
1800
  names.add(name);
1815
1801
  codeChecks.push({
1816
1802
  check: { sql: check, name: constraint.name },