orchid-orm 1.50.4 → 1.50.5

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,6 +1,6 @@
1
1
  import { promptSelect, colors, getSchemaAndTableFromName, getDbTableColumnsChecks, dbColumnToAst, instantiateDbColumn, concatSchemaAndName, encodeColumnDefault, getIndexName, getExcludeName, getConstraintName, tableToAst, getDbStructureTableData, makeDomainsMap, astToMigration, createMigrationInterface, introspectDbSchema, exhaustive, pluralize, makeStructureToAstCtx, makeFileVersion, writeMigrationFile, migrate, structureToAst, saveMigratedVersion, rakeDbCommands } from 'rake-db';
2
2
  export * from 'rake-db';
3
- import { toSnakeCase, deepCompare, emptyArray, toArray, addCode, codeToString, toCamelCase, toPascalCase, getImportPath, singleQuote, quoteObjectKey, pathToLog } from 'orchid-core';
3
+ import { toSnakeCase, deepCompare, emptyArray, toArray, toCamelCase, addCode, codeToString, toPascalCase, getImportPath, singleQuote, quoteObjectKey, pathToLog } from 'orchid-core';
4
4
  import { EnumColumn, ArrayColumn, getColumnBaseType, RawSQL, VirtualColumn, DomainColumn, UnknownColumn, defaultSchemaConfig, columnsShapeToCode, pushTableDataCode, Adapter } from 'pqb';
5
5
  import path from 'node:path';
6
6
  import { pathToFileURL } from 'url';
@@ -2275,7 +2275,8 @@ const report = (ast, config, currentSchema) => {
2275
2275
  }).join(", ")}` : ""}${indexes?.length ? indexes.length === 1 ? ", has index" : `, has ${indexes.length} indexes` : ""}${excludes?.length ? excludes.length === 1 ? ", has exclude" : `, has ${excludes.length} excludes` : ""}${checks?.length ? `, checks ${checks.map((check) => check.sql.toSQL({ values: [] })).join(", ")}` : ""}`
2276
2276
  );
2277
2277
  } else if (change.type === "change") {
2278
- const name = change.from.column?.data.name ?? key;
2278
+ let name = change.from.column?.data.name ?? key;
2279
+ if (config.snakeCase) name = toCamelCase(name);
2279
2280
  const changes2 = [];
2280
2281
  inner.push(`${yellow("~ change column")} ${name}:`, changes2);
2281
2282
  changes2.push(`${yellow("from")}: `);
@@ -2290,7 +2291,7 @@ const report = (ast, config, currentSchema) => {
2290
2291
  }
2291
2292
  } else if (change.type === "rename") {
2292
2293
  inner.push(
2293
- `${yellow("~ rename column")} ${key} ${yellow("=>")} ${change.name}`
2294
+ `${yellow("~ rename column")} ${config.snakeCase ? toCamelCase(key) : key} ${yellow("=>")} ${change.name}`
2294
2295
  );
2295
2296
  } else {
2296
2297
  exhaustive(change.type);
@@ -2943,7 +2944,7 @@ const appCodeGenUpdateDbFile = async (dbPath, tables, extensions, domains, curre
2943
2944
  if (extensions.length) {
2944
2945
  code += `
2945
2946
  extensions: [${extensions.map(
2946
- (ext) => ext.version ? `{ ${quoteObjectKey(ext.name)}: '${ext.version}' }` : singleQuote(ext.name)
2947
+ (ext) => ext.version ? `{ ${quoteObjectKey(ext.name, false)}: '${ext.version}' }` : singleQuote(ext.name)
2947
2948
  ).join(", ")}],`;
2948
2949
  }
2949
2950
  if (domains.length) {
@@ -2951,7 +2952,8 @@ const appCodeGenUpdateDbFile = async (dbPath, tables, extensions, domains, curre
2951
2952
  domains: {
2952
2953
  ${domains.sort((a, b) => a.name > b.name ? 1 : -1).map(
2953
2954
  (ast) => `${quoteObjectKey(
2954
- ast.schema ? `${ast.schema}.${ast.name}` : ast.name
2955
+ ast.schema ? `${ast.schema}.${ast.name}` : ast.name,
2956
+ false
2955
2957
  )}: (t) => ${ast.baseType.toCode(
2956
2958
  { t: "t", table: ast.name, currentSchema },
2957
2959
  ast.baseType.data.name ?? ""