orange-orm 5.3.0 → 5.3.2

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.
@@ -2,7 +2,6 @@ void !function() {
2
2
  typeof self === 'undefined' && typeof global === 'object'
3
3
  ? global.self = global : null;
4
4
  }();import * as fastJsonPatch from 'fast-json-patch';
5
- import * as uuid from 'uuid';
6
5
  import * as axios from 'axios';
7
6
  import * as _default from 'rfdc/default';
8
7
  import * as ajv from 'ajv';
@@ -973,7 +972,7 @@ function requireHostHono () {
973
972
  return hostHono_1;
974
973
  }
975
974
 
976
- var require$$0$3 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(fastJsonPatch);
975
+ var require$$0$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(fastJsonPatch);
977
976
 
978
977
  var dateToISOString_1;
979
978
  var hasRequiredDateToISOString;
@@ -1035,7 +1034,19 @@ function requireStringify () {
1035
1034
  return stringify_1;
1036
1035
  }
1037
1036
 
1038
- var require$$0$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(uuid);
1037
+ var newMemoryId;
1038
+ var hasRequiredNewMemoryId;
1039
+
1040
+ function requireNewMemoryId () {
1041
+ if (hasRequiredNewMemoryId) return newMemoryId;
1042
+ hasRequiredNewMemoryId = 1;
1043
+ let nextId = 1;
1044
+
1045
+ newMemoryId = function newMemoryId() {
1046
+ return `tmp${nextId++}`;
1047
+ };
1048
+ return newMemoryId;
1049
+ }
1039
1050
 
1040
1051
  var createPatch;
1041
1052
  var hasRequiredCreatePatch;
@@ -1043,10 +1054,10 @@ var hasRequiredCreatePatch;
1043
1054
  function requireCreatePatch () {
1044
1055
  if (hasRequiredCreatePatch) return createPatch;
1045
1056
  hasRequiredCreatePatch = 1;
1046
- const jsonpatch = require$$0$3;
1057
+ const jsonpatch = require$$0$2;
1047
1058
  let dateToIsoString = requireDateToISOString();
1048
1059
  let stringify = requireStringify();
1049
- let { v4: uuid } = require$$0$2;
1060
+ let newMemoryId = requireNewMemoryId();
1050
1061
 
1051
1062
  createPatch = function createPatch(original, dto, options) {
1052
1063
  let subject = toCompareObject({ d: original }, options, true);
@@ -1155,7 +1166,7 @@ function requireCreatePatch () {
1155
1166
 
1156
1167
  function negotiateTempKey(value) {
1157
1168
  if (value === undefined)
1158
- return `~${uuid()}`;
1169
+ return `~${newMemoryId()}`;
1159
1170
  else
1160
1171
  return value;
1161
1172
  }
@@ -2972,7 +2983,7 @@ function requireToKeyPositionMap () {
2972
2983
  if (hasRequiredToKeyPositionMap) return toKeyPositionMap_1;
2973
2984
  hasRequiredToKeyPositionMap = 1;
2974
2985
  const stringify = requireStringify();
2975
- const { v4: uuid } = require$$0$2;
2986
+ const newMemoryId = requireNewMemoryId();
2976
2987
 
2977
2988
  function toKeyPositionMap(rows, options) {
2978
2989
  return rows.reduce((map, element, i) => {
@@ -2995,7 +3006,7 @@ function requireToKeyPositionMap () {
2995
3006
 
2996
3007
  function negotiateTempKey(value) {
2997
3008
  if (value === undefined)
2998
- return `~${uuid()}`;
3009
+ return `~${newMemoryId()}`;
2999
3010
  else
3000
3011
  return value;
3001
3012
  }
@@ -4257,7 +4268,7 @@ function requireClient () {
4257
4268
  if (arguments[i][isColumnProxyKey])
4258
4269
  args[i] = { [columnRefKey]: arguments[i][columnPathKey] };
4259
4270
  else
4260
- args[i] = arguments[i](tableProxy(path.split('.').slice(0, -1).join('.')));
4271
+ args[i] = arguments[i](tableProxy());
4261
4272
  }
4262
4273
  else
4263
4274
  args[i] = arguments[i];
@@ -5599,7 +5610,7 @@ function requireNewEncode$5 () {
5599
5610
  value = purify(value);
5600
5611
  if (value == null) {
5601
5612
  if (column.dbNull === null)
5602
- ;
5613
+ return 'null';
5603
5614
  return '\'' + column.dbNull + '\'';
5604
5615
  }
5605
5616
  var encodeCore = getSessionSingleton(context, 'encodeDate') || encodeDate;
@@ -5734,12 +5745,12 @@ function requireNewEncode$4 () {
5734
5745
  return 'null';
5735
5746
  return '\'' + column.dbNull + '\'';
5736
5747
  }
5737
- var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5748
+ var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5738
5749
  return encodeCore(value);
5739
5750
  };
5740
5751
 
5741
5752
  encode.direct = function(context, value) {
5742
- var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5753
+ var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5743
5754
  return encodeCore(value);
5744
5755
  };
5745
5756
 
@@ -5943,7 +5954,7 @@ function requireNewEncode$2 () {
5943
5954
  value = purify(value);
5944
5955
  if (value == null) {
5945
5956
  if (column.dbNull === null)
5946
- ;
5957
+ return 'null';
5947
5958
  return '\'' + column.dbNull + '\'';
5948
5959
  }
5949
5960
  var encodeCore = getSessionSingleton(context, 'encodeBigint') || encodeBigint;
@@ -6292,18 +6303,13 @@ function requireColumn () {
6292
6303
  return c;
6293
6304
  };
6294
6305
 
6295
- c.date = function() {
6296
- requireDate()(column);
6297
- return c;
6298
- };
6299
-
6300
6306
  c.dateWithTimeZone = function() {
6301
6307
  requireDateWithTimeZone()(column);
6302
6308
  return c;
6303
6309
  };
6304
6310
 
6305
- c.numeric = function(optionalPrecision,optionalScale) {
6306
- requireNumeric()(column,optionalPrecision,optionalScale);
6311
+ c.numeric = function() {
6312
+ requireNumeric()(column);
6307
6313
  return c;
6308
6314
  };
6309
6315
 
@@ -8899,6 +8905,10 @@ function requireDbRowToRow () {
8899
8905
  function dbRowToRow(context, span, dbRow) {
8900
8906
  var table = span.table;
8901
8907
  var row = decodeDbRow(context, span, table, dbRow);
8908
+ if (!hasPrimaryKey(row, table)) {
8909
+ skipNestedLegs(span, dbRow);
8910
+ return null;
8911
+ }
8902
8912
  var cache = table._cache;
8903
8913
  if (!cache.tryGet(context, row)) {
8904
8914
  var queryContext = span.queryContext;
@@ -8915,13 +8925,15 @@ function requireDbRowToRow () {
8915
8925
  var c = {};
8916
8926
 
8917
8927
  c.visitOne = function(leg) {
8918
- dbRowToRow(context, leg.span, dbRow);
8919
- leg.expand(row);
8928
+ let child = dbRowToRow(context, leg.span, dbRow);
8929
+ if (child)
8930
+ leg.expand(row);
8920
8931
  };
8921
8932
 
8922
8933
  c.visitJoin = function(leg) {
8923
- dbRowToRow(context, leg.span, dbRow);
8924
- leg.expand(row);
8934
+ let child = dbRowToRow(context, leg.span, dbRow);
8935
+ if (child)
8936
+ leg.expand(row);
8925
8937
  };
8926
8938
 
8927
8939
  c.visitMany = function() {
@@ -8936,6 +8948,33 @@ function requireDbRowToRow () {
8936
8948
  return row;
8937
8949
  }
8938
8950
 
8951
+ function hasPrimaryKey(row, table) {
8952
+ return table._primaryColumns.every((column) => {
8953
+ let value = row[column.alias];
8954
+ return value !== null && value !== undefined;
8955
+ });
8956
+ }
8957
+
8958
+ function skipNestedLegs(span, dbRow) {
8959
+ span.legs.forEach((leg) => {
8960
+ leg.accept({
8961
+ visitOne() {
8962
+ skipSpan(leg.span, dbRow);
8963
+ },
8964
+ visitJoin() {
8965
+ skipSpan(leg.span, dbRow);
8966
+ },
8967
+ visitMany() {
8968
+ }
8969
+ });
8970
+ });
8971
+ }
8972
+
8973
+ function skipSpan(span, dbRow) {
8974
+ decodeDbRow(undefined, span, span.table, dbRow);
8975
+ skipNestedLegs(span, dbRow);
8976
+ }
8977
+
8939
8978
  dbRowToRow_1 = dbRowToRow;
8940
8979
  return dbRowToRow_1;
8941
8980
  }
@@ -10277,10 +10316,9 @@ function requireWhere$1 () {
10277
10316
  function newWhere(_relations, _depth) {
10278
10317
 
10279
10318
  function where(context, fn) {
10280
- const includeMany = false;
10281
- let { relations, alias } = extract(includeMany, _relations);
10319
+ let { relations, alias } = extract(_relations);
10282
10320
  const table = relations[relations.length - 1].childTable;
10283
- if (!relations[0].isMany || includeMany)
10321
+ if (!relations[0].isMany)
10284
10322
  table._rootAlias = alias;
10285
10323
 
10286
10324
  try {
@@ -10296,11 +10334,11 @@ function requireWhere$1 () {
10296
10334
  }
10297
10335
  return where;
10298
10336
 
10299
- function extract(includeMany, relations) {
10337
+ function extract(relations) {
10300
10338
  let alias = relations[0].toLeg().table._dbName;
10301
10339
  let result = [];
10302
10340
  for (let i = 0; i < relations.length; i++) {
10303
- if (relations[i].isMany && !includeMany) {
10341
+ if (relations[i].isMany) {
10304
10342
  result = [relations[i]];
10305
10343
  alias = relations[i].toLeg().table._dbName;
10306
10344
  }
@@ -10327,10 +10365,9 @@ function requireAggregate$1 () {
10327
10365
  function newAggregate(_relations) {
10328
10366
 
10329
10367
  function aggregate(context, fn) {
10330
- const includeMany = false;
10331
- let { relations, alias } = extract(includeMany, _relations);
10368
+ let { relations, alias } = extract(_relations);
10332
10369
  const table = relations[relations.length - 1].childTable;
10333
- if (!relations[0].isMany || includeMany)
10370
+ if (!relations[0].isMany)
10334
10371
  table._rootAlias = alias;
10335
10372
 
10336
10373
  try {
@@ -10345,11 +10382,11 @@ function requireAggregate$1 () {
10345
10382
  }
10346
10383
  return aggregate;
10347
10384
 
10348
- function extract(includeMany, relations) {
10385
+ function extract(relations) {
10349
10386
  let alias = relations[0].toLeg().table._dbName;
10350
10387
  let result = [];
10351
10388
  for (let i = 0; i < relations.length; i++) {
10352
- if (relations[i].isMany && !includeMany) {
10389
+ if (relations[i].isMany) {
10353
10390
  result = [relations[i]];
10354
10391
  alias = relations[i].toLeg().table._dbName;
10355
10392
  }
@@ -11010,7 +11047,7 @@ function requireNewManyCacheCore () {
11010
11047
  }
11011
11048
  var rows = newArray();
11012
11049
  rows.push(childRow);
11013
- existing = cache.tryAdd(key, rows);
11050
+ cache.tryAdd(key, rows);
11014
11051
  }
11015
11052
 
11016
11053
  function newArray() {
@@ -11047,8 +11084,7 @@ var hasRequiredNewId;
11047
11084
  function requireNewId () {
11048
11085
  if (hasRequiredNewId) return newId;
11049
11086
  hasRequiredNewId = 1;
11050
- const { v4 : uuid} = require$$0$2;
11051
- newId = uuid;
11087
+ newId = requireNewMemoryId();
11052
11088
  return newId;
11053
11089
  }
11054
11090
 
@@ -11736,16 +11772,18 @@ function requireGetManyDto$1 () {
11736
11772
  outRow[column.alias] = column.decode(context, row[keys[j]]);
11737
11773
  }
11738
11774
 
11739
- for (let j = 0; j < aggregateKeys.length; j++) {
11740
- const key = aggregateKeys[j];
11741
- const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
11742
- outRow[key] = parse(context, row[keys[j + columnsLength]]);
11775
+ if (outRow) {
11776
+ for (let j = 0; j < aggregateKeys.length; j++) {
11777
+ const key = aggregateKeys[j];
11778
+ const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
11779
+ outRow[key] = parse(context, row[keys[j + columnsLength]]);
11780
+ }
11743
11781
  }
11744
11782
 
11745
11783
  outRows[i] = outRow;
11746
11784
  if (updateParent)
11747
11785
  updateParent(outRow, i);
11748
- if (shouldCreateMap) {
11786
+ if (shouldCreateMap && outRow) {
11749
11787
  fkIds[i] = getIds(outRow);
11750
11788
  addToMap(rowsMap, fkIds[i], outRow);
11751
11789
  }
@@ -12432,7 +12470,7 @@ var hasRequiredApplyPatch;
12432
12470
  function requireApplyPatch () {
12433
12471
  if (hasRequiredApplyPatch) return applyPatch_1;
12434
12472
  hasRequiredApplyPatch = 1;
12435
- const fastjson = require$$0$3;
12473
+ const fastjson = require$$0$2;
12436
12474
  let fromCompareObject = requireFromCompareObject();
12437
12475
  let toCompareObject = requireToCompareObject();
12438
12476
  let getSessionSingleton = requireGetSessionSingleton();
@@ -12936,7 +12974,6 @@ function requirePatchTable () {
12936
12974
  let result;
12937
12975
  for (let i = 0; i < relation.columns.length; i++) {
12938
12976
  let p = relation.columns[i].alias;
12939
- row[p];
12940
12977
  result = await remove({ path: ['dummy', p], oldValue: (oldValue || {})[p], op, options: options }, table, row) || result;
12941
12978
  }
12942
12979
  return result || {};
@@ -12949,8 +12986,7 @@ function requirePatchTable () {
12949
12986
  let p = relation.columns[i].alias;
12950
12987
  let childKey = relation.childTable._primaryColumns[i].alias;
12951
12988
  if (path[1] === childKey) {
12952
- row[p];
12953
- result = await remove({ path: ['dummy', p], oldValue: (oldValue || {})[p], op, options: options }, table, row) || result;
12989
+ result = await remove({ path: ['dummy', p], oldValue: oldValue[p], op, options: options }, table, row) || result;
12954
12990
  break;
12955
12991
  }
12956
12992
  }
@@ -16955,7 +16991,7 @@ function requireNewPgPool () {
16955
16991
  if (!pg) {
16956
16992
  pg = await import('pg');
16957
16993
  pg = pg.default || pg;
16958
- let types = pg.types || pg.types;
16994
+ let types = pg.types;
16959
16995
  types.setTypeParser(1700, function(val) {
16960
16996
  return parseFloat(val);
16961
16997
  });
package/dist/index.mjs CHANGED
@@ -2,7 +2,6 @@ void !function() {
2
2
  typeof self === 'undefined' && typeof global === 'object'
3
3
  ? global.self = global : null;
4
4
  }();import * as fastJsonPatch from 'fast-json-patch';
5
- import * as uuid from 'uuid';
6
5
  import * as axios from 'axios';
7
6
  import * as _default from 'rfdc/default';
8
7
  import * as ajv from 'ajv';
@@ -974,7 +973,7 @@ function requireHostHono () {
974
973
  return hostHono_1;
975
974
  }
976
975
 
977
- var require$$0$4 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(fastJsonPatch);
976
+ var require$$0$3 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(fastJsonPatch);
978
977
 
979
978
  var dateToISOString_1;
980
979
  var hasRequiredDateToISOString;
@@ -1036,7 +1035,19 @@ function requireStringify () {
1036
1035
  return stringify_1;
1037
1036
  }
1038
1037
 
1039
- var require$$0$3 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(uuid);
1038
+ var newMemoryId;
1039
+ var hasRequiredNewMemoryId;
1040
+
1041
+ function requireNewMemoryId () {
1042
+ if (hasRequiredNewMemoryId) return newMemoryId;
1043
+ hasRequiredNewMemoryId = 1;
1044
+ let nextId = 1;
1045
+
1046
+ newMemoryId = function newMemoryId() {
1047
+ return `tmp${nextId++}`;
1048
+ };
1049
+ return newMemoryId;
1050
+ }
1040
1051
 
1041
1052
  var createPatch;
1042
1053
  var hasRequiredCreatePatch;
@@ -1044,10 +1055,10 @@ var hasRequiredCreatePatch;
1044
1055
  function requireCreatePatch () {
1045
1056
  if (hasRequiredCreatePatch) return createPatch;
1046
1057
  hasRequiredCreatePatch = 1;
1047
- const jsonpatch = require$$0$4;
1058
+ const jsonpatch = require$$0$3;
1048
1059
  let dateToIsoString = requireDateToISOString();
1049
1060
  let stringify = requireStringify();
1050
- let { v4: uuid } = require$$0$3;
1061
+ let newMemoryId = requireNewMemoryId();
1051
1062
 
1052
1063
  createPatch = function createPatch(original, dto, options) {
1053
1064
  let subject = toCompareObject({ d: original }, options, true);
@@ -1156,7 +1167,7 @@ function requireCreatePatch () {
1156
1167
 
1157
1168
  function negotiateTempKey(value) {
1158
1169
  if (value === undefined)
1159
- return `~${uuid()}`;
1170
+ return `~${newMemoryId()}`;
1160
1171
  else
1161
1172
  return value;
1162
1173
  }
@@ -2973,7 +2984,7 @@ function requireToKeyPositionMap () {
2973
2984
  if (hasRequiredToKeyPositionMap) return toKeyPositionMap_1;
2974
2985
  hasRequiredToKeyPositionMap = 1;
2975
2986
  const stringify = requireStringify();
2976
- const { v4: uuid } = require$$0$3;
2987
+ const newMemoryId = requireNewMemoryId();
2977
2988
 
2978
2989
  function toKeyPositionMap(rows, options) {
2979
2990
  return rows.reduce((map, element, i) => {
@@ -2996,7 +3007,7 @@ function requireToKeyPositionMap () {
2996
3007
 
2997
3008
  function negotiateTempKey(value) {
2998
3009
  if (value === undefined)
2999
- return `~${uuid()}`;
3010
+ return `~${newMemoryId()}`;
3000
3011
  else
3001
3012
  return value;
3002
3013
  }
@@ -4258,7 +4269,7 @@ function requireClient () {
4258
4269
  if (arguments[i][isColumnProxyKey])
4259
4270
  args[i] = { [columnRefKey]: arguments[i][columnPathKey] };
4260
4271
  else
4261
- args[i] = arguments[i](tableProxy(path.split('.').slice(0, -1).join('.')));
4272
+ args[i] = arguments[i](tableProxy());
4262
4273
  }
4263
4274
  else
4264
4275
  args[i] = arguments[i];
@@ -5600,7 +5611,7 @@ function requireNewEncode$5 () {
5600
5611
  value = purify(value);
5601
5612
  if (value == null) {
5602
5613
  if (column.dbNull === null)
5603
- ;
5614
+ return 'null';
5604
5615
  return '\'' + column.dbNull + '\'';
5605
5616
  }
5606
5617
  var encodeCore = getSessionSingleton(context, 'encodeDate') || encodeDate;
@@ -5735,12 +5746,12 @@ function requireNewEncode$4 () {
5735
5746
  return 'null';
5736
5747
  return '\'' + column.dbNull + '\'';
5737
5748
  }
5738
- var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5749
+ var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5739
5750
  return encodeCore(value);
5740
5751
  };
5741
5752
 
5742
5753
  encode.direct = function(context, value) {
5743
- var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5754
+ var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
5744
5755
  return encodeCore(value);
5745
5756
  };
5746
5757
 
@@ -5944,7 +5955,7 @@ function requireNewEncode$2 () {
5944
5955
  value = purify(value);
5945
5956
  if (value == null) {
5946
5957
  if (column.dbNull === null)
5947
- ;
5958
+ return 'null';
5948
5959
  return '\'' + column.dbNull + '\'';
5949
5960
  }
5950
5961
  var encodeCore = getSessionSingleton(context, 'encodeBigint') || encodeBigint;
@@ -6293,18 +6304,13 @@ function requireColumn () {
6293
6304
  return c;
6294
6305
  };
6295
6306
 
6296
- c.date = function() {
6297
- requireDate()(column);
6298
- return c;
6299
- };
6300
-
6301
6307
  c.dateWithTimeZone = function() {
6302
6308
  requireDateWithTimeZone()(column);
6303
6309
  return c;
6304
6310
  };
6305
6311
 
6306
- c.numeric = function(optionalPrecision,optionalScale) {
6307
- requireNumeric()(column,optionalPrecision,optionalScale);
6312
+ c.numeric = function() {
6313
+ requireNumeric()(column);
6308
6314
  return c;
6309
6315
  };
6310
6316
 
@@ -8900,6 +8906,10 @@ function requireDbRowToRow () {
8900
8906
  function dbRowToRow(context, span, dbRow) {
8901
8907
  var table = span.table;
8902
8908
  var row = decodeDbRow(context, span, table, dbRow);
8909
+ if (!hasPrimaryKey(row, table)) {
8910
+ skipNestedLegs(span, dbRow);
8911
+ return null;
8912
+ }
8903
8913
  var cache = table._cache;
8904
8914
  if (!cache.tryGet(context, row)) {
8905
8915
  var queryContext = span.queryContext;
@@ -8916,13 +8926,15 @@ function requireDbRowToRow () {
8916
8926
  var c = {};
8917
8927
 
8918
8928
  c.visitOne = function(leg) {
8919
- dbRowToRow(context, leg.span, dbRow);
8920
- leg.expand(row);
8929
+ let child = dbRowToRow(context, leg.span, dbRow);
8930
+ if (child)
8931
+ leg.expand(row);
8921
8932
  };
8922
8933
 
8923
8934
  c.visitJoin = function(leg) {
8924
- dbRowToRow(context, leg.span, dbRow);
8925
- leg.expand(row);
8935
+ let child = dbRowToRow(context, leg.span, dbRow);
8936
+ if (child)
8937
+ leg.expand(row);
8926
8938
  };
8927
8939
 
8928
8940
  c.visitMany = function() {
@@ -8937,6 +8949,33 @@ function requireDbRowToRow () {
8937
8949
  return row;
8938
8950
  }
8939
8951
 
8952
+ function hasPrimaryKey(row, table) {
8953
+ return table._primaryColumns.every((column) => {
8954
+ let value = row[column.alias];
8955
+ return value !== null && value !== undefined;
8956
+ });
8957
+ }
8958
+
8959
+ function skipNestedLegs(span, dbRow) {
8960
+ span.legs.forEach((leg) => {
8961
+ leg.accept({
8962
+ visitOne() {
8963
+ skipSpan(leg.span, dbRow);
8964
+ },
8965
+ visitJoin() {
8966
+ skipSpan(leg.span, dbRow);
8967
+ },
8968
+ visitMany() {
8969
+ }
8970
+ });
8971
+ });
8972
+ }
8973
+
8974
+ function skipSpan(span, dbRow) {
8975
+ decodeDbRow(undefined, span, span.table, dbRow);
8976
+ skipNestedLegs(span, dbRow);
8977
+ }
8978
+
8940
8979
  dbRowToRow_1 = dbRowToRow;
8941
8980
  return dbRowToRow_1;
8942
8981
  }
@@ -10278,10 +10317,9 @@ function requireWhere$1 () {
10278
10317
  function newWhere(_relations, _depth) {
10279
10318
 
10280
10319
  function where(context, fn) {
10281
- const includeMany = false;
10282
- let { relations, alias } = extract(includeMany, _relations);
10320
+ let { relations, alias } = extract(_relations);
10283
10321
  const table = relations[relations.length - 1].childTable;
10284
- if (!relations[0].isMany || includeMany)
10322
+ if (!relations[0].isMany)
10285
10323
  table._rootAlias = alias;
10286
10324
 
10287
10325
  try {
@@ -10297,11 +10335,11 @@ function requireWhere$1 () {
10297
10335
  }
10298
10336
  return where;
10299
10337
 
10300
- function extract(includeMany, relations) {
10338
+ function extract(relations) {
10301
10339
  let alias = relations[0].toLeg().table._dbName;
10302
10340
  let result = [];
10303
10341
  for (let i = 0; i < relations.length; i++) {
10304
- if (relations[i].isMany && !includeMany) {
10342
+ if (relations[i].isMany) {
10305
10343
  result = [relations[i]];
10306
10344
  alias = relations[i].toLeg().table._dbName;
10307
10345
  }
@@ -10328,10 +10366,9 @@ function requireAggregate$1 () {
10328
10366
  function newAggregate(_relations) {
10329
10367
 
10330
10368
  function aggregate(context, fn) {
10331
- const includeMany = false;
10332
- let { relations, alias } = extract(includeMany, _relations);
10369
+ let { relations, alias } = extract(_relations);
10333
10370
  const table = relations[relations.length - 1].childTable;
10334
- if (!relations[0].isMany || includeMany)
10371
+ if (!relations[0].isMany)
10335
10372
  table._rootAlias = alias;
10336
10373
 
10337
10374
  try {
@@ -10346,11 +10383,11 @@ function requireAggregate$1 () {
10346
10383
  }
10347
10384
  return aggregate;
10348
10385
 
10349
- function extract(includeMany, relations) {
10386
+ function extract(relations) {
10350
10387
  let alias = relations[0].toLeg().table._dbName;
10351
10388
  let result = [];
10352
10389
  for (let i = 0; i < relations.length; i++) {
10353
- if (relations[i].isMany && !includeMany) {
10390
+ if (relations[i].isMany) {
10354
10391
  result = [relations[i]];
10355
10392
  alias = relations[i].toLeg().table._dbName;
10356
10393
  }
@@ -11011,7 +11048,7 @@ function requireNewManyCacheCore () {
11011
11048
  }
11012
11049
  var rows = newArray();
11013
11050
  rows.push(childRow);
11014
- existing = cache.tryAdd(key, rows);
11051
+ cache.tryAdd(key, rows);
11015
11052
  }
11016
11053
 
11017
11054
  function newArray() {
@@ -11048,8 +11085,7 @@ var hasRequiredNewId;
11048
11085
  function requireNewId () {
11049
11086
  if (hasRequiredNewId) return newId;
11050
11087
  hasRequiredNewId = 1;
11051
- const { v4 : uuid} = require$$0$3;
11052
- newId = uuid;
11088
+ newId = requireNewMemoryId();
11053
11089
  return newId;
11054
11090
  }
11055
11091
 
@@ -11737,16 +11773,18 @@ function requireGetManyDto$1 () {
11737
11773
  outRow[column.alias] = column.decode(context, row[keys[j]]);
11738
11774
  }
11739
11775
 
11740
- for (let j = 0; j < aggregateKeys.length; j++) {
11741
- const key = aggregateKeys[j];
11742
- const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
11743
- outRow[key] = parse(context, row[keys[j + columnsLength]]);
11776
+ if (outRow) {
11777
+ for (let j = 0; j < aggregateKeys.length; j++) {
11778
+ const key = aggregateKeys[j];
11779
+ const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
11780
+ outRow[key] = parse(context, row[keys[j + columnsLength]]);
11781
+ }
11744
11782
  }
11745
11783
 
11746
11784
  outRows[i] = outRow;
11747
11785
  if (updateParent)
11748
11786
  updateParent(outRow, i);
11749
- if (shouldCreateMap) {
11787
+ if (shouldCreateMap && outRow) {
11750
11788
  fkIds[i] = getIds(outRow);
11751
11789
  addToMap(rowsMap, fkIds[i], outRow);
11752
11790
  }
@@ -12433,7 +12471,7 @@ var hasRequiredApplyPatch;
12433
12471
  function requireApplyPatch () {
12434
12472
  if (hasRequiredApplyPatch) return applyPatch_1;
12435
12473
  hasRequiredApplyPatch = 1;
12436
- const fastjson = require$$0$4;
12474
+ const fastjson = require$$0$3;
12437
12475
  let fromCompareObject = requireFromCompareObject();
12438
12476
  let toCompareObject = requireToCompareObject();
12439
12477
  let getSessionSingleton = requireGetSessionSingleton();
@@ -12937,7 +12975,6 @@ function requirePatchTable () {
12937
12975
  let result;
12938
12976
  for (let i = 0; i < relation.columns.length; i++) {
12939
12977
  let p = relation.columns[i].alias;
12940
- row[p];
12941
12978
  result = await remove({ path: ['dummy', p], oldValue: (oldValue || {})[p], op, options: options }, table, row) || result;
12942
12979
  }
12943
12980
  return result || {};
@@ -12950,8 +12987,7 @@ function requirePatchTable () {
12950
12987
  let p = relation.columns[i].alias;
12951
12988
  let childKey = relation.childTable._primaryColumns[i].alias;
12952
12989
  if (path[1] === childKey) {
12953
- row[p];
12954
- result = await remove({ path: ['dummy', p], oldValue: (oldValue || {})[p], op, options: options }, table, row) || result;
12990
+ result = await remove({ path: ['dummy', p], oldValue: oldValue[p], op, options: options }, table, row) || result;
12955
12991
  break;
12956
12992
  }
12957
12993
  }
@@ -18002,7 +18038,7 @@ function requireNewPgPool () {
18002
18038
  if (!pg) {
18003
18039
  pg = await import('pg');
18004
18040
  pg = pg.default || pg;
18005
- let types = pg.types || pg.types;
18041
+ let types = pg.types;
18006
18042
  types.setTypeParser(1700, function(val) {
18007
18043
  return parseFloat(val);
18008
18044
  });
@@ -18589,6 +18625,7 @@ function requireNewTransaction$7 () {
18589
18625
  rdb.pool = pool;
18590
18626
  }
18591
18627
  rdb.engine = 'sqlite';
18628
+ rdb.maxParameters = 32766;
18592
18629
  rdb.encodeBoolean = encodeBoolean;
18593
18630
  rdb.encodeBinary = encodeBinary;
18594
18631
  rdb.decodeBinary = decodeBinary;
@@ -19022,6 +19059,7 @@ function requireNewTransaction$6 () {
19022
19059
  rdb.pool = pool;
19023
19060
  }
19024
19061
  rdb.engine = 'sqlite';
19062
+ rdb.maxParameters = 32766;
19025
19063
  rdb.encodeBoolean = encodeBoolean;
19026
19064
  rdb.encodeBinary = encodeBinary;
19027
19065
  rdb.decodeBinary = decodeBinary;
@@ -19458,6 +19496,7 @@ function requireNewTransaction$5 () {
19458
19496
  rdb.pool = pool;
19459
19497
  }
19460
19498
  rdb.engine = 'sqlite';
19499
+ rdb.maxParameters = 32766;
19461
19500
  rdb.encodeBoolean = encodeBoolean;
19462
19501
  rdb.decodeJSON = decodeJSON;
19463
19502
  rdb.encodeJSON = JSON.stringify;
@@ -20876,6 +20915,7 @@ function requireNewTransaction$3 () {
20876
20915
  rdb.pool = pool;
20877
20916
  }
20878
20917
  rdb.engine = 'mssqlNative';
20918
+ rdb.maxParameters = 2100;
20879
20919
  rdb.encodeBoolean = encodeBoolean;
20880
20920
  rdb.decodeJSON = decodeJSON;
20881
20921
  rdb.encodeJSON = JSON.stringify;
@@ -21638,6 +21678,7 @@ function requireNewTransaction$2 () {
21638
21678
  rdb.pool = pool;
21639
21679
  }
21640
21680
  rdb.engine = 'mssql';
21681
+ rdb.maxParameters = 2100;
21641
21682
  rdb.encodeBoolean = encodeBoolean;
21642
21683
  rdb.decodeJSON = decodeJSON;
21643
21684
  rdb.encodeJSON = JSON.stringify;
@@ -23206,6 +23247,7 @@ function requireNewTransaction () {
23206
23247
 
23207
23248
  rdb.begin = 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED';
23208
23249
  rdb.engine = 'oracle';
23250
+ rdb.maxParameters = 32768;
23209
23251
  rdb.encodeBoolean = encodeBoolean;
23210
23252
  rdb.decodeJSON = decodeJSON;
23211
23253
  rdb.encodeJSON = JSON.stringify;
package/docs/changelog.md CHANGED
@@ -1,4 +1,10 @@
1
1
  ## Changelog
2
+ __5.3.2__
3
+ Removed uuid dependency.
4
+ Upgraded to tedious@19.2.1 to reduce transitive audit vulnerabilities in the MSSQL driver chain.
5
+ __5.3.1__
6
+ Fixes crashes in getById/getMany when a missing relation has nested hasMany/hasOne/references in the strategy. [#177](https://github.com/alfateam/orange-orm/issues/177)
7
+ Added max parameter chunking for getManyDto hasMany subqueries on MSSQL, SQLite and Oracle.
2
8
  __5.3.0__
3
9
  Support for MariaDB [#169](https://github.com/alfateam/orange-orm/issues/169)
4
10
  __5.2.4__
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orange-orm",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,6 +37,7 @@
37
37
  "sap",
38
38
  "sapase",
39
39
  "Oracle",
40
+ "MariaDB",
40
41
  "rdb",
41
42
  "Orange ORM",
42
43
  "active record"
@@ -80,8 +81,7 @@
80
81
  "ajv": "^8.17.1",
81
82
  "axios": "^1.6.2",
82
83
  "fast-json-patch": "^3.1.1",
83
- "rfdc": "^1.2.0",
84
- "uuid": "^8.3.2 || ^9.0.0 || ^10.0.0 || ^11.1.0"
84
+ "rfdc": "^1.2.0"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@electric-sql/pglite": "^0.3.0",
@@ -91,7 +91,7 @@
91
91
  "oracledb": "^6.3.0",
92
92
  "pg": "^8.5.1",
93
93
  "pg-query-stream": "^3.3.2",
94
- "tedious": "^15.1.2 || ^16.0.0 || ^18.1.0 || || ^19.0.0"
94
+ "tedious": "^15.1.2 || ^16.0.0 || ^18.1.0 || ^19.0.0"
95
95
  },
96
96
  "peerDependenciesMeta": {
97
97
  "pg": {
@@ -144,7 +144,7 @@
144
144
  "pg": "^8.5.1",
145
145
  "pg-query-stream": "^3.3.2",
146
146
  "rollup": "^2.52.7",
147
- "tedious": "^19.0.0",
147
+ "tedious": "^19.2.1",
148
148
  "typescript": "^5.4.5",
149
149
  "vitest": "^3.2.4"
150
150
  },
@@ -19,6 +19,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
19
19
  rdb.pool = pool;
20
20
  }
21
21
  rdb.engine = 'sqlite';
22
+ rdb.maxParameters = 32766;
22
23
  rdb.encodeBoolean = encodeBoolean;
23
24
  rdb.encodeBinary = encodeBinary;
24
25
  rdb.decodeBinary = decodeBinary;
@@ -106,4 +107,4 @@ function decodeJSON(value) {
106
107
  return JSON.parse(value);
107
108
  }
108
109
 
109
- module.exports = newResolveTransaction;
110
+ module.exports = newResolveTransaction;
@@ -1,7 +1,7 @@
1
1
  const jsonpatch = require('fast-json-patch');
2
2
  let dateToIsoString = require('../dateToISOString');
3
3
  let stringify = require('./stringify');
4
- let { v4: uuid } = require('uuid');
4
+ let newMemoryId = require('../newMemoryId');
5
5
 
6
6
  module.exports = function createPatch(original, dto, options) {
7
7
  let subject = toCompareObject({ d: original }, options, true);
@@ -110,7 +110,7 @@ module.exports = function createPatch(original, dto, options) {
110
110
 
111
111
  function negotiateTempKey(value) {
112
112
  if (value === undefined)
113
- return `~${uuid()}`;
113
+ return `~${newMemoryId()}`;
114
114
  else
115
115
  return value;
116
116
  }
@@ -1086,7 +1086,7 @@ function column(path, ...previous) {
1086
1086
  if (arguments[i][isColumnProxyKey])
1087
1087
  args[i] = { [columnRefKey]: arguments[i][columnPathKey] };
1088
1088
  else
1089
- args[i] = arguments[i](tableProxy(path.split('.').slice(0, -1).join('.')));
1089
+ args[i] = arguments[i](tableProxy());
1090
1090
  }
1091
1091
  else
1092
1092
  args[i] = arguments[i];
@@ -1,5 +1,5 @@
1
1
  const stringify = require('./stringify');
2
- const { v4: uuid } = require('uuid');
2
+ const newMemoryId = require('../newMemoryId');
3
3
 
4
4
  function toKeyPositionMap(rows, options) {
5
5
  return rows.reduce((map, element, i) => {
@@ -22,9 +22,9 @@ function toKeyPositionMap(rows, options) {
22
22
 
23
23
  function negotiateTempKey(value) {
24
24
  if (value === undefined)
25
- return `~${uuid()}`;
25
+ return `~${newMemoryId()}`;
26
26
  else
27
27
  return value;
28
28
  }
29
29
 
30
- module.exports = toKeyPositionMap;
30
+ module.exports = toKeyPositionMap;
package/src/getManyDto.js CHANGED
@@ -126,16 +126,18 @@ async function decode(context, strategy, span, rows, keys = rows.length > 0 ? Ob
126
126
  outRow[column.alias] = column.decode(context, row[keys[j]]);
127
127
  }
128
128
 
129
- for (let j = 0; j < aggregateKeys.length; j++) {
130
- const key = aggregateKeys[j];
131
- const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
132
- outRow[key] = parse(context, row[keys[j + columnsLength]]);
129
+ if (outRow) {
130
+ for (let j = 0; j < aggregateKeys.length; j++) {
131
+ const key = aggregateKeys[j];
132
+ const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
133
+ outRow[key] = parse(context, row[keys[j + columnsLength]]);
134
+ }
133
135
  }
134
136
 
135
137
  outRows[i] = outRow;
136
138
  if (updateParent)
137
139
  updateParent(outRow, i);
138
- if (shouldCreateMap) {
140
+ if (shouldCreateMap && outRow) {
139
141
  fkIds[i] = getIds(outRow);
140
142
  addToMap(rowsMap, fkIds[i], outRow);
141
143
  }
@@ -19,6 +19,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
19
19
  rdb.pool = pool;
20
20
  }
21
21
  rdb.engine = 'mssqlNative';
22
+ rdb.maxParameters = 2100;
22
23
  rdb.encodeBoolean = encodeBoolean;
23
24
  rdb.decodeJSON = decodeJSON;
24
25
  rdb.encodeJSON = JSON.stringify;
@@ -117,4 +118,4 @@ function decodeJSON(value){
117
118
  return JSON.parse(value);
118
119
  }
119
120
 
120
- module.exports = newResolveTransaction;
121
+ module.exports = newResolveTransaction;
package/src/newId.js CHANGED
@@ -1,2 +1 @@
1
- const { v4 : uuid} = require('uuid');
2
- module.exports = uuid;
1
+ module.exports = require('./newMemoryId');
@@ -0,0 +1,5 @@
1
+ let nextId = 1;
2
+
3
+ module.exports = function newMemoryId() {
4
+ return `tmp${nextId++}`;
5
+ };
@@ -19,6 +19,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
19
19
  rdb.pool = pool;
20
20
  }
21
21
  rdb.engine = 'sqlite';
22
+ rdb.maxParameters = 32766;
22
23
  rdb.encodeBoolean = encodeBoolean;
23
24
  rdb.encodeBinary = encodeBinary;
24
25
  rdb.decodeBinary = decodeBinary;
@@ -106,4 +107,4 @@ function decodeJSON(value) {
106
107
  return JSON.parse(value);
107
108
  }
108
109
 
109
- module.exports = newResolveTransaction;
110
+ module.exports = newResolveTransaction;
@@ -21,6 +21,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
21
21
 
22
22
  rdb.begin = 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED';
23
23
  rdb.engine = 'oracle';
24
+ rdb.maxParameters = 32768;
24
25
  rdb.encodeBoolean = encodeBoolean;
25
26
  rdb.decodeJSON = decodeJSON;
26
27
  rdb.encodeJSON = JSON.stringify;
@@ -110,4 +111,4 @@ function decodeJSON(value) {
110
111
  return JSON.parse(value);
111
112
  }
112
113
 
113
- module.exports = newResolveTransaction;
114
+ module.exports = newResolveTransaction;
package/src/patchTable.js CHANGED
@@ -267,8 +267,6 @@ async function patchTableCore(context, table, patches, { strategy = undefined, d
267
267
  let result;
268
268
  for (let i = 0; i < relation.columns.length; i++) {
269
269
  let p = relation.columns[i].alias;
270
- let dto = {};
271
- dto[p] = row[p];
272
270
  result = await remove({ path: ['dummy', p], oldValue: (oldValue || {})[p], op, options: options }, table, row) || result;
273
271
  }
274
272
  return result || {};
@@ -281,9 +279,7 @@ async function patchTableCore(context, table, patches, { strategy = undefined, d
281
279
  let p = relation.columns[i].alias;
282
280
  let childKey = relation.childTable._primaryColumns[i].alias;
283
281
  if (path[1] === childKey) {
284
- let dto = {};
285
- dto[p] = row[p];
286
- result = await remove({ path: ['dummy', p], oldValue: (oldValue || {})[p], op, options: options }, table, row) || result;
282
+ result = await remove({ path: ['dummy', p], oldValue: oldValue[p], op, options: options }, table, row) || result;
287
283
  break;
288
284
  }
289
285
  }
@@ -22,7 +22,7 @@ function newPgPool(connectionString, poolOptions) {
22
22
  if (!pg) {
23
23
  pg = await import('pg');
24
24
  pg = pg.default || pg;
25
- let types = pg.types || pg.types;
25
+ let types = pg.types;
26
26
  types.setTypeParser(1700, function(val) {
27
27
  return parseFloat(val);
28
28
  });
@@ -17,6 +17,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
17
17
  rdb.pool = pool;
18
18
  }
19
19
  rdb.engine = 'sqlite';
20
+ rdb.maxParameters = 32766;
20
21
  rdb.encodeBoolean = encodeBoolean;
21
22
  rdb.decodeJSON = decodeJSON;
22
23
  rdb.encodeJSON = JSON.stringify;
@@ -102,4 +103,4 @@ function decodeJSON(value) {
102
103
  return JSON.parse(value);
103
104
  }
104
105
 
105
- module.exports = newResolveTransaction;
106
+ module.exports = newResolveTransaction;
@@ -21,7 +21,7 @@ function _new(column) {
21
21
  value = purify(value);
22
22
  if (value == null) {
23
23
  if (column.dbNull === null)
24
- 'null';
24
+ return 'null';
25
25
  return '\'' + column.dbNull + '\'';
26
26
  }
27
27
  var encodeCore = getSessionSingleton(context, 'encodeBigint') || encodeBigint;
@@ -21,7 +21,7 @@ function _new(column) {
21
21
  value = purify(value);
22
22
  if (value == null) {
23
23
  if (column.dbNull === null)
24
- 'null';
24
+ return 'null';
25
25
  return '\'' + column.dbNull + '\'';
26
26
  }
27
27
  var encodeCore = getSessionSingleton(context, 'encodeDate') || encodeDate;
@@ -23,12 +23,12 @@ function _new(column) {
23
23
  return 'null';
24
24
  return '\'' + column.dbNull + '\'';
25
25
  }
26
- var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
26
+ var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
27
27
  return encodeCore(value);
28
28
  };
29
29
 
30
30
  encode.direct = function(context, value) {
31
- var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
31
+ var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
32
32
  return encodeCore(value);
33
33
  };
34
34
 
@@ -28,18 +28,13 @@ function defineColumn(column, table) {
28
28
  return c;
29
29
  };
30
30
 
31
- c.date = function() {
32
- require('./column/date')(column);
33
- return c;
34
- };
35
-
36
31
  c.dateWithTimeZone = function() {
37
32
  require('./column/dateWithTimeZone')(column);
38
33
  return c;
39
34
  };
40
35
 
41
- c.numeric = function(optionalPrecision,optionalScale) {
42
- require('./column/numeric')(column,optionalPrecision,optionalScale);
36
+ c.numeric = function() {
37
+ require('./column/numeric')(column);
43
38
  return c;
44
39
  };
45
40
 
@@ -3,8 +3,8 @@ var newImmutable = require('../../newImmutable');
3
3
  var createPatch = require('../../client/createPatch');
4
4
  var createDto = require('../resultToRows/toDto/createDto');
5
5
 
6
- function newInsertCommand(table, row, options) {
7
- return new InsertCommand(table, row, options);
6
+ function newInsertCommand(table, row) {
7
+ return new InsertCommand(table, row);
8
8
  }
9
9
 
10
10
  function InsertCommand(table, row) {
@@ -1,10 +1,9 @@
1
1
  function newAggregate(_relations) {
2
2
 
3
3
  function aggregate(context, fn) {
4
- const includeMany = false;
5
- let { relations, alias } = extract(includeMany, _relations);
4
+ let { relations, alias } = extract(_relations);
6
5
  const table = relations[relations.length - 1].childTable;
7
- if (!relations[0].isMany || includeMany)
6
+ if (!relations[0].isMany)
8
7
  table._rootAlias = alias;
9
8
 
10
9
  try {
@@ -19,11 +18,11 @@ function newAggregate(_relations) {
19
18
  }
20
19
  return aggregate;
21
20
 
22
- function extract(includeMany, relations) {
21
+ function extract(relations) {
23
22
  let alias = relations[0].toLeg().table._dbName;
24
23
  let result = [];
25
24
  for (let i = 0; i < relations.length; i++) {
26
- if (relations[i].isMany && !includeMany) {
25
+ if (relations[i].isMany) {
27
26
  result = [relations[i]];
28
27
  alias = relations[i].toLeg().table._dbName;
29
28
  }
@@ -3,10 +3,9 @@ const negotiateRawSqlFilter = require('../column/negotiateRawSqlFilter');
3
3
  function newWhere(_relations, _depth) {
4
4
 
5
5
  function where(context, fn) {
6
- const includeMany = false;
7
- let { relations, alias } = extract(includeMany, _relations);
6
+ let { relations, alias } = extract(_relations);
8
7
  const table = relations[relations.length - 1].childTable;
9
- if (!relations[0].isMany || includeMany)
8
+ if (!relations[0].isMany)
10
9
  table._rootAlias = alias;
11
10
 
12
11
  try {
@@ -22,11 +21,11 @@ function newWhere(_relations, _depth) {
22
21
  }
23
22
  return where;
24
23
 
25
- function extract(includeMany, relations) {
24
+ function extract(relations) {
26
25
  let alias = relations[0].toLeg().table._dbName;
27
26
  let result = [];
28
27
  for (let i = 0; i < relations.length; i++) {
29
- if (relations[i].isMany && !includeMany) {
28
+ if (relations[i].isMany) {
30
29
  result = [relations[i]];
31
30
  alias = relations[i].toLeg().table._dbName;
32
31
  }
@@ -23,7 +23,7 @@ function newManyCache(joinRelation) {
23
23
  }
24
24
  var rows = newArray();
25
25
  rows.push(childRow);
26
- existing = cache.tryAdd(key, rows);
26
+ cache.tryAdd(key, rows);
27
27
  }
28
28
 
29
29
  function newArray() {
@@ -4,6 +4,10 @@ var decodeDbRow = require('./decodeDbRow');
4
4
  function dbRowToRow(context, span, dbRow) {
5
5
  var table = span.table;
6
6
  var row = decodeDbRow(context, span, table, dbRow);
7
+ if (!hasPrimaryKey(row, table)) {
8
+ skipNestedLegs(span, dbRow);
9
+ return null;
10
+ }
7
11
  var cache = table._cache;
8
12
  if (!cache.tryGet(context, row)) {
9
13
  var queryContext = span.queryContext;
@@ -20,13 +24,15 @@ function dbRowToRow(context, span, dbRow) {
20
24
  var c = {};
21
25
 
22
26
  c.visitOne = function(leg) {
23
- dbRowToRow(context, leg.span, dbRow);
24
- leg.expand(row);
27
+ let child = dbRowToRow(context, leg.span, dbRow);
28
+ if (child)
29
+ leg.expand(row);
25
30
  };
26
31
 
27
32
  c.visitJoin = function(leg) {
28
- dbRowToRow(context, leg.span, dbRow);
29
- leg.expand(row);
33
+ let child = dbRowToRow(context, leg.span, dbRow);
34
+ if (child)
35
+ leg.expand(row);
30
36
  };
31
37
 
32
38
  c.visitMany = function() {
@@ -41,4 +47,31 @@ function dbRowToRow(context, span, dbRow) {
41
47
  return row;
42
48
  }
43
49
 
44
- module.exports = dbRowToRow;
50
+ function hasPrimaryKey(row, table) {
51
+ return table._primaryColumns.every((column) => {
52
+ let value = row[column.alias];
53
+ return value !== null && value !== undefined;
54
+ });
55
+ }
56
+
57
+ function skipNestedLegs(span, dbRow) {
58
+ span.legs.forEach((leg) => {
59
+ leg.accept({
60
+ visitOne() {
61
+ skipSpan(leg.span, dbRow);
62
+ },
63
+ visitJoin() {
64
+ skipSpan(leg.span, dbRow);
65
+ },
66
+ visitMany() {
67
+ }
68
+ });
69
+ });
70
+ }
71
+
72
+ function skipSpan(span, dbRow) {
73
+ decodeDbRow(undefined, span, span.table, dbRow);
74
+ skipNestedLegs(span, dbRow);
75
+ }
76
+
77
+ module.exports = dbRowToRow;
@@ -19,6 +19,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
19
19
  rdb.pool = pool;
20
20
  }
21
21
  rdb.engine = 'mssql';
22
+ rdb.maxParameters = 2100;
22
23
  rdb.encodeBoolean = encodeBoolean;
23
24
  rdb.decodeJSON = decodeJSON;
24
25
  rdb.encodeJSON = JSON.stringify;
@@ -114,4 +115,4 @@ function decodeJSON(value){
114
115
  return JSON.parse(value);
115
116
  }
116
117
 
117
- module.exports = newResolveTransaction;
118
+ module.exports = newResolveTransaction;
package/deno.lock DELETED
@@ -1,75 +0,0 @@
1
- {
2
- "version": "5",
3
- "specifiers": {
4
- "jsr:@std/assert@*": "1.0.19",
5
- "jsr:@std/assert@^1.0.17": "1.0.19",
6
- "jsr:@std/internal@^1.0.12": "1.0.12",
7
- "jsr:@std/path@*": "1.1.4",
8
- "jsr:@std/testing@*": "1.0.17"
9
- },
10
- "jsr": {
11
- "@std/assert@1.0.19": {
12
- "integrity": "eaada96ee120cb980bc47e040f82814d786fe8162ecc53c91d8df60b8755991e",
13
- "dependencies": [
14
- "jsr:@std/internal"
15
- ]
16
- },
17
- "@std/internal@1.0.12": {
18
- "integrity": "972a634fd5bc34b242024402972cd5143eac68d8dffaca5eaa4dba30ce17b027"
19
- },
20
- "@std/path@1.1.4": {
21
- "integrity": "1d2d43f39efb1b42f0b1882a25486647cb851481862dc7313390b2bb044314b5",
22
- "dependencies": [
23
- "jsr:@std/internal"
24
- ]
25
- },
26
- "@std/testing@1.0.17": {
27
- "integrity": "87bdc2700fa98249d48a17cd72413352d3d3680dcfbdb64947fd0982d6bbf681",
28
- "dependencies": [
29
- "jsr:@std/assert@^1.0.17",
30
- "jsr:@std/internal"
31
- ]
32
- }
33
- },
34
- "workspace": {
35
- "packageJson": {
36
- "dependencies": [
37
- "npm:@cloudflare/workers-types@^4.20241106.0",
38
- "npm:@electric-sql/pglite@0.3",
39
- "npm:@hono/node-server@^1.14.4",
40
- "npm:@lroal/on-change@^4.0.2",
41
- "npm:@rollup/plugin-commonjs@^28.0.2",
42
- "npm:@rollup/plugin-json@^6.1.0",
43
- "npm:@rollup/plugin-node-resolve@13",
44
- "npm:@tediousjs/connection-string@~0.4.1",
45
- "npm:@types/express@^4.17.13",
46
- "npm:@types/oracledb@^6.0.4",
47
- "npm:@types/tedious@^4.0.14",
48
- "npm:@typescript-eslint/eslint-plugin@^8.56.1",
49
- "npm:@typescript-eslint/parser@^8.56.1",
50
- "npm:@vitest/coverage-v8@^3.2.4",
51
- "npm:ajv@^8.17.1",
52
- "npm:axios@^1.6.2",
53
- "npm:better-sqlite3@^12.6.2",
54
- "npm:cors@^2.8.5",
55
- "npm:eslint-plugin-jest@^29.15.0",
56
- "npm:eslint@^8.57.0",
57
- "npm:express@^4.18.2",
58
- "npm:fast-json-patch@^3.1.1",
59
- "npm:hono@^4.8.2",
60
- "npm:msnodesqlv8@^4.1.0",
61
- "npm:mysql2@^3.9.4",
62
- "npm:oracledb@^6.3.0",
63
- "npm:owasp-dependency-check@^0.0.21",
64
- "npm:pg-query-stream@^3.3.2",
65
- "npm:pg@^8.5.1",
66
- "npm:rfdc@^1.2.0",
67
- "npm:rollup@^2.52.7",
68
- "npm:tedious@19",
69
- "npm:typescript@^5.4.5",
70
- "npm:uuid@^8.3.2 || 9 || 10 || ^11.1.0",
71
- "npm:vitest@^3.2.4"
72
- ]
73
- }
74
- }
75
- }
package/other.db DELETED
Binary file
@@ -1,23 +0,0 @@
1
- var newWhereSql = require('./singleQuery/newWhereSql');
2
- var negotiateLimit = require('./singleQuery/negotiateLimit');
3
- var newParameterized = require('./newParameterized');
4
- var getSessionContext = require('../getSessionContext');
5
-
6
- function _new(table, filter, span, alias, orderBy, limit) {
7
- //unused ?
8
-
9
- if (!limit)
10
- return;
11
- var whereSql = newWhereSql(table, filter, alias);
12
- var safeLimit = negotiateLimit(limit);
13
- var sql;
14
- if (getSessionContext().limit === 'TOP') {
15
- safeLimit = safeLimit.replace('limit', 'top');
16
- sql = 'select ' + safeLimit + ' * from ' + table._dbName + ' ' + alias + whereSql + orderBy;
17
- }
18
- sql = 'select * from ' + table._dbName + ' ' + alias + whereSql + orderBy + safeLimit;
19
-
20
- return newParameterized(sql, filter.parameters);
21
- }
22
-
23
- module.exports = _new;