turbine-orm 0.38.0 → 0.38.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.
@@ -138,7 +138,13 @@ async function importOptionalPeer(specifier, allowEsmFallback = true) {
138
138
  */
139
139
  function peerPackageVersion(specifier) {
140
140
  try {
141
- const pkg = require(`${specifier}/package.json`);
141
+ // Resolve the path with `require.resolve`, then read + parse the file
142
+ // directly instead of `require`ing the JSON module: some loader hooks
143
+ // (tsx's CJS hook on Node 20) fail on requiring a .json file even though
144
+ // resolution succeeds, and a plain fs read is loader-independent.
145
+ const path = require.resolve(`${specifier}/package.json`);
146
+ const raw = require('node:fs').readFileSync(path, 'utf8');
147
+ const pkg = JSON.parse(raw);
142
148
  return typeof pkg.version === 'string' ? pkg.version : null;
143
149
  }
144
150
  catch {
@@ -1481,8 +1481,15 @@ function getColumnArrayType(qi, column) {
1481
1481
  const arrayType = qi.columnArrayTypeMap.get(column);
1482
1482
  if (arrayType)
1483
1483
  return arrayType;
1484
- // Fallback heuristic for unknown columns, routed through the active dialect
1485
- // so non-Postgres packages can supply their own bulk-insert cast shape.
1484
+ // The column's DECLARED type always beats any name-based guess: a text/uuid
1485
+ // "author_id" must never be cast bigint[] just because of its suffix (that
1486
+ // produced real 22P02 failures on createMany against uuid-keyed tables).
1487
+ const declared = Object.hasOwn(qi.tableMeta.pgTypes, column) ? qi.tableMeta.pgTypes[column] : undefined;
1488
+ if (declared)
1489
+ return qi.dialect.arrayType?.(declared) ?? 'text[]';
1490
+ // Last-resort heuristic for columns absent from the metadata entirely,
1491
+ // routed through the active dialect so non-Postgres packages can supply
1492
+ // their own bulk-insert cast shape.
1486
1493
  if (column === 'id' || column.endsWith('_id'))
1487
1494
  return qi.dialect.arrayType?.('int8') ?? 'text[]';
1488
1495
  if (column.endsWith('_at'))
@@ -105,7 +105,13 @@ async function importOptionalPeer(specifier, allowEsmFallback = true) {
105
105
  */
106
106
  function peerPackageVersion(specifier) {
107
107
  try {
108
- const pkg = require(`${specifier}/package.json`);
108
+ // Resolve the path with `require.resolve`, then read + parse the file
109
+ // directly instead of `require`ing the JSON module: some loader hooks
110
+ // (tsx's CJS hook on Node 20) fail on requiring a .json file even though
111
+ // resolution succeeds, and a plain fs read is loader-independent.
112
+ const path = require.resolve(`${specifier}/package.json`);
113
+ const raw = require('node:fs').readFileSync(path, 'utf8');
114
+ const pkg = JSON.parse(raw);
109
115
  return typeof pkg.version === 'string' ? pkg.version : null;
110
116
  }
111
117
  catch {
@@ -1421,8 +1421,15 @@ export function getColumnArrayType(qi, column) {
1421
1421
  const arrayType = qi.columnArrayTypeMap.get(column);
1422
1422
  if (arrayType)
1423
1423
  return arrayType;
1424
- // Fallback heuristic for unknown columns, routed through the active dialect
1425
- // so non-Postgres packages can supply their own bulk-insert cast shape.
1424
+ // The column's DECLARED type always beats any name-based guess: a text/uuid
1425
+ // "author_id" must never be cast bigint[] just because of its suffix (that
1426
+ // produced real 22P02 failures on createMany against uuid-keyed tables).
1427
+ const declared = Object.hasOwn(qi.tableMeta.pgTypes, column) ? qi.tableMeta.pgTypes[column] : undefined;
1428
+ if (declared)
1429
+ return qi.dialect.arrayType?.(declared) ?? 'text[]';
1430
+ // Last-resort heuristic for columns absent from the metadata entirely,
1431
+ // routed through the active dialect so non-Postgres packages can supply
1432
+ // their own bulk-insert cast shape.
1426
1433
  if (column === 'id' || column.endsWith('_id'))
1427
1434
  return qi.dialect.arrayType?.('int8') ?? 'text[]';
1428
1435
  if (column.endsWith('_at'))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbine-orm",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
4
4
  "description": "Postgres-native TypeScript ORM — runs on Neon, Vercel Postgres, Cloudflare, Supabase. Streaming cursors, typed errors, single-query nested relations. One dependency, no WASM engine",
5
5
  "type": "module",
6
6
  "exports": {