orange-orm 4.7.13 → 4.7.14

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.
@@ -4963,12 +4963,12 @@ function requireNewDecode$4 () {
4963
4963
  return newDecode$4;
4964
4964
  }
4965
4965
 
4966
- var formatOut_1;
4967
- var hasRequiredFormatOut;
4966
+ var formatOut_1$1;
4967
+ var hasRequiredFormatOut$1;
4968
4968
 
4969
- function requireFormatOut () {
4970
- if (hasRequiredFormatOut) return formatOut_1;
4971
- hasRequiredFormatOut = 1;
4969
+ function requireFormatOut$1 () {
4970
+ if (hasRequiredFormatOut$1) return formatOut_1$1;
4971
+ hasRequiredFormatOut$1 = 1;
4972
4972
  var getSessionSingleton = requireGetSessionSingleton();
4973
4973
  const quote = requireQuote$2();
4974
4974
 
@@ -4982,8 +4982,8 @@ function requireFormatOut () {
4982
4982
  return `${quote(context, column._dbName)}`;
4983
4983
  }
4984
4984
 
4985
- formatOut_1 = formatOut;
4986
- return formatOut_1;
4985
+ formatOut_1$1 = formatOut;
4986
+ return formatOut_1$1;
4987
4987
  }
4988
4988
 
4989
4989
  var date;
@@ -4994,7 +4994,7 @@ function requireDate () {
4994
4994
  hasRequiredDate = 1;
4995
4995
  var newEncode = requireNewEncode$5();
4996
4996
  var newDecode = requireNewDecode$4();
4997
- var formatOut = requireFormatOut();
4997
+ var formatOut = requireFormatOut$1();
4998
4998
  var purify = requirePurify$3();
4999
4999
 
5000
5000
  function _new(column) {
@@ -5062,6 +5062,29 @@ function requireNewEncode$4 () {
5062
5062
  return newEncode$4;
5063
5063
  }
5064
5064
 
5065
+ var formatOut_1;
5066
+ var hasRequiredFormatOut;
5067
+
5068
+ function requireFormatOut () {
5069
+ if (hasRequiredFormatOut) return formatOut_1;
5070
+ hasRequiredFormatOut = 1;
5071
+ var getSessionSingleton = requireGetSessionSingleton();
5072
+ const quote = requireQuote$2();
5073
+
5074
+ function formatOut(context, column, alias) {
5075
+ var formatColumn = getSessionSingleton(context, 'formatDateTzOut') || getSessionSingleton(context, 'formatDateOut');
5076
+ if (formatColumn)
5077
+ return formatColumn(column, alias);
5078
+ else if (alias)
5079
+ return `${alias}.${quote(context, column._dbName)}`;
5080
+ else
5081
+ return `${quote(context, column._dbName)}`;
5082
+ }
5083
+
5084
+ formatOut_1 = formatOut;
5085
+ return formatOut_1;
5086
+ }
5087
+
5065
5088
  var dateWithTimeZone;
5066
5089
  var hasRequiredDateWithTimeZone;
5067
5090
 
@@ -9669,12 +9692,11 @@ function requireWhere$1 () {
9669
9692
  if (hasRequiredWhere$1) return where$1;
9670
9693
  hasRequiredWhere$1 = 1;
9671
9694
  const negotiateRawSqlFilter = requireNegotiateRawSqlFilter();
9672
- let tryGetSessionContext = requireTryGetSessionContext();
9673
9695
 
9674
9696
  function newWhere(_relations, _depth) {
9675
9697
 
9676
9698
  function where(context, fn) {
9677
- const includeMany = tryGetSessionContext(context)?.engine === 'mssql';
9699
+ const includeMany = false;
9678
9700
  let { relations, alias } = extract(includeMany, _relations);
9679
9701
  const table = relations[relations.length - 1].childTable;
9680
9702
  if (!relations[0].isMany || includeMany)
@@ -9721,12 +9743,10 @@ var hasRequiredAggregate$1;
9721
9743
  function requireAggregate$1 () {
9722
9744
  if (hasRequiredAggregate$1) return aggregate$1;
9723
9745
  hasRequiredAggregate$1 = 1;
9724
- let tryGetSessionContext = requireTryGetSessionContext();
9725
-
9726
9746
  function newAggregate(_relations) {
9727
9747
 
9728
9748
  function aggregate(context, fn) {
9729
- const includeMany = tryGetSessionContext(context)?.engine === 'mssql';
9749
+ const includeMany = false;
9730
9750
  let { relations, alias } = extract(includeMany, _relations);
9731
9751
  const table = relations[relations.length - 1].childTable;
9732
9752
  if (!relations[0].isMany || includeMany)
package/dist/index.mjs CHANGED
@@ -4964,12 +4964,12 @@ function requireNewDecode$4 () {
4964
4964
  return newDecode$4;
4965
4965
  }
4966
4966
 
4967
- var formatOut_1;
4968
- var hasRequiredFormatOut;
4967
+ var formatOut_1$1;
4968
+ var hasRequiredFormatOut$1;
4969
4969
 
4970
- function requireFormatOut () {
4971
- if (hasRequiredFormatOut) return formatOut_1;
4972
- hasRequiredFormatOut = 1;
4970
+ function requireFormatOut$1 () {
4971
+ if (hasRequiredFormatOut$1) return formatOut_1$1;
4972
+ hasRequiredFormatOut$1 = 1;
4973
4973
  var getSessionSingleton = requireGetSessionSingleton();
4974
4974
  const quote = requireQuote$6();
4975
4975
 
@@ -4983,8 +4983,8 @@ function requireFormatOut () {
4983
4983
  return `${quote(context, column._dbName)}`;
4984
4984
  }
4985
4985
 
4986
- formatOut_1 = formatOut;
4987
- return formatOut_1;
4986
+ formatOut_1$1 = formatOut;
4987
+ return formatOut_1$1;
4988
4988
  }
4989
4989
 
4990
4990
  var date;
@@ -4995,7 +4995,7 @@ function requireDate () {
4995
4995
  hasRequiredDate = 1;
4996
4996
  var newEncode = requireNewEncode$5();
4997
4997
  var newDecode = requireNewDecode$4();
4998
- var formatOut = requireFormatOut();
4998
+ var formatOut = requireFormatOut$1();
4999
4999
  var purify = requirePurify$3();
5000
5000
 
5001
5001
  function _new(column) {
@@ -5063,6 +5063,29 @@ function requireNewEncode$4 () {
5063
5063
  return newEncode$4;
5064
5064
  }
5065
5065
 
5066
+ var formatOut_1;
5067
+ var hasRequiredFormatOut;
5068
+
5069
+ function requireFormatOut () {
5070
+ if (hasRequiredFormatOut) return formatOut_1;
5071
+ hasRequiredFormatOut = 1;
5072
+ var getSessionSingleton = requireGetSessionSingleton();
5073
+ const quote = requireQuote$6();
5074
+
5075
+ function formatOut(context, column, alias) {
5076
+ var formatColumn = getSessionSingleton(context, 'formatDateTzOut') || getSessionSingleton(context, 'formatDateOut');
5077
+ if (formatColumn)
5078
+ return formatColumn(column, alias);
5079
+ else if (alias)
5080
+ return `${alias}.${quote(context, column._dbName)}`;
5081
+ else
5082
+ return `${quote(context, column._dbName)}`;
5083
+ }
5084
+
5085
+ formatOut_1 = formatOut;
5086
+ return formatOut_1;
5087
+ }
5088
+
5066
5089
  var dateWithTimeZone;
5067
5090
  var hasRequiredDateWithTimeZone;
5068
5091
 
@@ -5876,12 +5899,12 @@ function requireNewPrimaryKeyFilter () {
5876
5899
  return newPrimaryKeyFilter;
5877
5900
  }
5878
5901
 
5879
- var newShallowColumnSql$1;
5880
- var hasRequiredNewShallowColumnSql$1;
5902
+ var newShallowColumnSql;
5903
+ var hasRequiredNewShallowColumnSql;
5881
5904
 
5882
- function requireNewShallowColumnSql$1 () {
5883
- if (hasRequiredNewShallowColumnSql$1) return newShallowColumnSql$1;
5884
- hasRequiredNewShallowColumnSql$1 = 1;
5905
+ function requireNewShallowColumnSql () {
5906
+ if (hasRequiredNewShallowColumnSql) return newShallowColumnSql;
5907
+ hasRequiredNewShallowColumnSql = 1;
5885
5908
  const getSessionSingleton = requireGetSessionSingleton();
5886
5909
 
5887
5910
  function _new(context, table, alias, span, ignoreNulls) {
@@ -5922,8 +5945,8 @@ function requireNewShallowColumnSql$1 () {
5922
5945
  }
5923
5946
  }
5924
5947
 
5925
- newShallowColumnSql$1 = _new;
5926
- return newShallowColumnSql$1;
5948
+ newShallowColumnSql = _new;
5949
+ return newShallowColumnSql;
5927
5950
  }
5928
5951
 
5929
5952
  var sharedJoinUtils;
@@ -5932,7 +5955,7 @@ var hasRequiredSharedJoinUtils;
5932
5955
  function requireSharedJoinUtils () {
5933
5956
  if (hasRequiredSharedJoinUtils) return sharedJoinUtils;
5934
5957
  hasRequiredSharedJoinUtils = 1;
5935
- var newShallowColumnSql = requireNewShallowColumnSql$1();
5958
+ var newShallowColumnSql = requireNewShallowColumnSql();
5936
5959
 
5937
5960
  function joinLegToColumnSql(context, leg, alias, ignoreNull) {
5938
5961
  var span = leg.span;
@@ -5991,7 +6014,7 @@ var hasRequiredNewColumnSql;
5991
6014
  function requireNewColumnSql () {
5992
6015
  if (hasRequiredNewColumnSql) return newColumnSql;
5993
6016
  hasRequiredNewColumnSql = 1;
5994
- var newShallowColumnSql = requireNewShallowColumnSql$1();
6017
+ var newShallowColumnSql = requireNewShallowColumnSql();
5995
6018
  var newJoinedColumnSql = requireNewJoinedColumnSql();
5996
6019
 
5997
6020
  newColumnSql = function(context,table,span,alias,ignoreNull) {
@@ -6209,12 +6232,12 @@ function requireNegotiateExclusive () {
6209
6232
  return negotiateExclusive_1;
6210
6233
  }
6211
6234
 
6212
- var newSingleQuery$2;
6213
- var hasRequiredNewSingleQuery$2;
6235
+ var newSingleQuery$1;
6236
+ var hasRequiredNewSingleQuery$1;
6214
6237
 
6215
- function requireNewSingleQuery$2 () {
6216
- if (hasRequiredNewSingleQuery$2) return newSingleQuery$2;
6217
- hasRequiredNewSingleQuery$2 = 1;
6238
+ function requireNewSingleQuery$1 () {
6239
+ if (hasRequiredNewSingleQuery$1) return newSingleQuery$1;
6240
+ hasRequiredNewSingleQuery$1 = 1;
6218
6241
  var newColumnSql = requireNewColumnSql();
6219
6242
  var newJoinSql = requireNewJoinSql();
6220
6243
  var newWhereSql = requireNewWhereSql();
@@ -6238,8 +6261,8 @@ function requireNewSingleQuery$2 () {
6238
6261
  .append(orderBy + offset + exclusiveClause);
6239
6262
  }
6240
6263
 
6241
- newSingleQuery$2 = _new;
6242
- return newSingleQuery$2;
6264
+ newSingleQuery$1 = _new;
6265
+ return newSingleQuery$1;
6243
6266
  }
6244
6267
 
6245
6268
  var extractFilter;
@@ -6370,13 +6393,13 @@ function requireExtractOffset () {
6370
6393
  return extractOffset_1;
6371
6394
  }
6372
6395
 
6373
- var newQuery_1$3;
6374
- var hasRequiredNewQuery$3;
6396
+ var newQuery_1$2;
6397
+ var hasRequiredNewQuery$2;
6375
6398
 
6376
- function requireNewQuery$3 () {
6377
- if (hasRequiredNewQuery$3) return newQuery_1$3;
6378
- hasRequiredNewQuery$3 = 1;
6379
- var newSingleQuery = requireNewSingleQuery$2();
6399
+ function requireNewQuery$2 () {
6400
+ if (hasRequiredNewQuery$2) return newQuery_1$2;
6401
+ hasRequiredNewQuery$2 = 1;
6402
+ var newSingleQuery = requireNewSingleQuery$1();
6380
6403
  var extractFilter = requireExtractFilter();
6381
6404
  var extractOrderBy = requireExtractOrderBy();
6382
6405
  var extractLimit = requireExtractLimit();
@@ -6393,8 +6416,8 @@ function requireNewQuery$3 () {
6393
6416
  return queries;
6394
6417
  }
6395
6418
 
6396
- newQuery_1$3 = newQuery;
6397
- return newQuery_1$3;
6419
+ newQuery_1$2 = newQuery;
6420
+ return newQuery_1$2;
6398
6421
  }
6399
6422
 
6400
6423
  var negotiateQueryContext_1;
@@ -8673,7 +8696,7 @@ var hasRequiredGetMany;
8673
8696
  function requireGetMany () {
8674
8697
  if (hasRequiredGetMany) return getMany_1;
8675
8698
  hasRequiredGetMany = 1;
8676
- let newQuery = requireNewQuery$3();
8699
+ let newQuery = requireNewQuery$2();
8677
8700
  let executeQueries = requireExecuteQueries();
8678
8701
  let resultToRows = requireResultToRows();
8679
8702
  let strategyToSpan = requireStrategyToSpan();
@@ -9670,12 +9693,11 @@ function requireWhere$1 () {
9670
9693
  if (hasRequiredWhere$1) return where$1;
9671
9694
  hasRequiredWhere$1 = 1;
9672
9695
  const negotiateRawSqlFilter = requireNegotiateRawSqlFilter();
9673
- let tryGetSessionContext = requireTryGetSessionContext();
9674
9696
 
9675
9697
  function newWhere(_relations, _depth) {
9676
9698
 
9677
9699
  function where(context, fn) {
9678
- const includeMany = tryGetSessionContext(context)?.engine === 'mssql';
9700
+ const includeMany = false;
9679
9701
  let { relations, alias } = extract(includeMany, _relations);
9680
9702
  const table = relations[relations.length - 1].childTable;
9681
9703
  if (!relations[0].isMany || includeMany)
@@ -9722,12 +9744,10 @@ var hasRequiredAggregate$1;
9722
9744
  function requireAggregate$1 () {
9723
9745
  if (hasRequiredAggregate$1) return aggregate$1;
9724
9746
  hasRequiredAggregate$1 = 1;
9725
- let tryGetSessionContext = requireTryGetSessionContext();
9726
-
9727
9747
  function newAggregate(_relations) {
9728
9748
 
9729
9749
  function aggregate(context, fn) {
9730
- const includeMany = tryGetSessionContext(context)?.engine === 'mssql';
9750
+ const includeMany = false;
9731
9751
  let { relations, alias } = extract(includeMany, _relations);
9732
9752
  const table = relations[relations.length - 1].childTable;
9733
9753
  if (!relations[0].isMany || includeMany)
@@ -10793,12 +10813,12 @@ function requireCount () {
10793
10813
  return count_1;
10794
10814
  }
10795
10815
 
10796
- var newSingleQuery$1;
10797
- var hasRequiredNewSingleQuery$1;
10816
+ var newSingleQuery;
10817
+ var hasRequiredNewSingleQuery;
10798
10818
 
10799
- function requireNewSingleQuery$1 () {
10800
- if (hasRequiredNewSingleQuery$1) return newSingleQuery$1;
10801
- hasRequiredNewSingleQuery$1 = 1;
10819
+ function requireNewSingleQuery () {
10820
+ if (hasRequiredNewSingleQuery) return newSingleQuery;
10821
+ hasRequiredNewSingleQuery = 1;
10802
10822
  var newColumnSql = requireNewColumnSql();
10803
10823
  var newWhereSql = requireNewWhereSql();
10804
10824
  var newJoinSql = requireNewJoinSql();
@@ -10818,17 +10838,17 @@ function requireNewSingleQuery$1 () {
10818
10838
 
10819
10839
  }
10820
10840
 
10821
- newSingleQuery$1 = _new;
10822
- return newSingleQuery$1;
10841
+ newSingleQuery = _new;
10842
+ return newSingleQuery;
10823
10843
  }
10824
10844
 
10825
- var newQuery_1$2;
10826
- var hasRequiredNewQuery$2;
10845
+ var newQuery_1$1;
10846
+ var hasRequiredNewQuery$1;
10827
10847
 
10828
- function requireNewQuery$2 () {
10829
- if (hasRequiredNewQuery$2) return newQuery_1$2;
10830
- hasRequiredNewQuery$2 = 1;
10831
- var newSingleQuery = requireNewSingleQuery$1();
10848
+ function requireNewQuery$1 () {
10849
+ if (hasRequiredNewQuery$1) return newQuery_1$1;
10850
+ hasRequiredNewQuery$1 = 1;
10851
+ var newSingleQuery = requireNewSingleQuery();
10832
10852
  var extractFilter = requireExtractFilter();
10833
10853
  var extractOrderBy = requireExtractOrderBy();
10834
10854
  var extractLimit = requireExtractLimit();
@@ -10845,18 +10865,18 @@ function requireNewQuery$2 () {
10845
10865
  return newParameterized(query.sql(), query.parameters);
10846
10866
  }
10847
10867
 
10848
- newQuery_1$2 = newQuery;
10849
- return newQuery_1$2;
10868
+ newQuery_1$1 = newQuery;
10869
+ return newQuery_1$1;
10850
10870
  }
10851
10871
 
10852
- var getManyDto_1$2;
10853
- var hasRequiredGetManyDto$2;
10872
+ var getManyDto_1$1;
10873
+ var hasRequiredGetManyDto$1;
10854
10874
 
10855
- function requireGetManyDto$2 () {
10856
- if (hasRequiredGetManyDto$2) return getManyDto_1$2;
10857
- hasRequiredGetManyDto$2 = 1;
10875
+ function requireGetManyDto$1 () {
10876
+ if (hasRequiredGetManyDto$1) return getManyDto_1$1;
10877
+ hasRequiredGetManyDto$1 = 1;
10858
10878
  const emptyFilter = requireEmptyFilter();
10859
- const newQuery = requireNewQuery$2();
10879
+ const newQuery = requireNewQuery$1();
10860
10880
  const negotiateRawSqlFilter = requireNegotiateRawSqlFilter();
10861
10881
  const strategyToSpan = requireStrategyToSpan();
10862
10882
  const executeQueries = requireExecuteQueries();
@@ -11221,26 +11241,26 @@ function requireGetManyDto$2 () {
11221
11241
  return map.get(values);
11222
11242
  }
11223
11243
 
11224
- getManyDto_1$2 = getManyDto;
11225
- return getManyDto_1$2;
11244
+ getManyDto_1$1 = getManyDto;
11245
+ return getManyDto_1$1;
11226
11246
  }
11227
11247
 
11228
- var getManyDto_1$1;
11229
- var hasRequiredGetManyDto$1;
11248
+ var getManyDto_1;
11249
+ var hasRequiredGetManyDto;
11230
11250
 
11231
- function requireGetManyDto$1 () {
11232
- if (hasRequiredGetManyDto$1) return getManyDto_1$1;
11233
- hasRequiredGetManyDto$1 = 1;
11251
+ function requireGetManyDto () {
11252
+ if (hasRequiredGetManyDto) return getManyDto_1;
11253
+ hasRequiredGetManyDto = 1;
11234
11254
  const getSessionSingleton = requireGetSessionSingleton();
11235
- const getManyDtoCore = requireGetManyDto$2();
11255
+ const getManyDtoCore = requireGetManyDto$1();
11236
11256
 
11237
11257
  function getManyDto(context, _table, _filter, _strategy) {
11238
11258
  const _getManyDto = getSessionSingleton(context, 'getManyDto') || getManyDtoCore;
11239
11259
  return _getManyDto.apply(null, arguments);
11240
11260
  }
11241
11261
 
11242
- getManyDto_1$1 = getManyDto;
11243
- return getManyDto_1$1;
11262
+ getManyDto_1 = getManyDto;
11263
+ return getManyDto_1;
11244
11264
  }
11245
11265
 
11246
11266
  var tryGetById;
@@ -11625,13 +11645,13 @@ function requireAggregate () {
11625
11645
  return aggregate;
11626
11646
  }
11627
11647
 
11628
- var newQuery_1$1;
11629
- var hasRequiredNewQuery$1;
11648
+ var newQuery_1;
11649
+ var hasRequiredNewQuery;
11630
11650
 
11631
- function requireNewQuery$1 () {
11632
- if (hasRequiredNewQuery$1) return newQuery_1$1;
11633
- hasRequiredNewQuery$1 = 1;
11634
- var newSingleQuery = requireNewSingleQuery$1();
11651
+ function requireNewQuery () {
11652
+ if (hasRequiredNewQuery) return newQuery_1;
11653
+ hasRequiredNewQuery = 1;
11654
+ var newSingleQuery = requireNewSingleQuery();
11635
11655
  var extractFilter = requireExtractFilter();
11636
11656
  var extractLimit = requireExtractLimit();
11637
11657
  var newParameterized = requireNewParameterized();
@@ -11655,8 +11675,8 @@ function requireNewQuery$1 () {
11655
11675
  return ' GROUP BY ' + keys.map(key => span.aggregates[key].groupBy).join(',');
11656
11676
  }
11657
11677
 
11658
- newQuery_1$1 = newQuery;
11659
- return newQuery_1$1;
11678
+ newQuery_1 = newQuery;
11679
+ return newQuery_1;
11660
11680
  }
11661
11681
 
11662
11682
  var groupBy_1;
@@ -11665,7 +11685,7 @@ var hasRequiredGroupBy;
11665
11685
  function requireGroupBy () {
11666
11686
  if (hasRequiredGroupBy) return groupBy_1;
11667
11687
  hasRequiredGroupBy = 1;
11668
- const newQuery = requireNewQuery$1();
11688
+ const newQuery = requireNewQuery();
11669
11689
  const negotiateRawSqlFilter = requireNegotiateRawSqlFilter();
11670
11690
  const strategyToSpan = requireStrategyToSpan();
11671
11691
  const executeQueries = requireExecuteQueries();
@@ -11746,7 +11766,7 @@ function requireTable () {
11746
11766
  const hasOne = requireHasOne();
11747
11767
  const getMany = requireGetMany();
11748
11768
  const count = requireCount();
11749
- const getManyDto = requireGetManyDto$1();
11769
+ const getManyDto = requireGetManyDto();
11750
11770
  const getById = requireGetById();
11751
11771
  const tryGetById = requireTryGetById();
11752
11772
  const tryGetFirst = requireTryGetFirstFromDb();
@@ -17910,9 +17930,9 @@ function requireFormatDateOut$2 () {
17910
17930
 
17911
17931
  function formatDateOut(column, alias) {
17912
17932
  if (alias)
17913
- return `CONVERT(VARCHAR, ${alias}.${quote(column._dbName)}, 121)`;
17933
+ return `CONVERT(VARCHAR, ${alias}.${quote(column._dbName)}, 126)`;
17914
17934
  else
17915
- return `CONVERT(VARCHAR, ${quote(column._dbName)}, 121)`;
17935
+ return `CONVERT(VARCHAR, ${quote(column._dbName)}, 126)`;
17916
17936
  }
17917
17937
 
17918
17938
  formatDateOut_1$1 = formatDateOut;
@@ -18734,281 +18754,27 @@ function requireWrapQuery$1 () {
18734
18754
  return wrapQuery_1$1;
18735
18755
  }
18736
18756
 
18737
- var newShallowColumnSql;
18738
- var hasRequiredNewShallowColumnSql;
18757
+ var formatDateTzOut;
18758
+ var hasRequiredFormatDateTzOut;
18739
18759
 
18740
- function requireNewShallowColumnSql () {
18741
- if (hasRequiredNewShallowColumnSql) return newShallowColumnSql;
18742
- hasRequiredNewShallowColumnSql = 1;
18760
+ function requireFormatDateTzOut () {
18761
+ if (hasRequiredFormatDateTzOut) return formatDateTzOut;
18762
+ hasRequiredFormatDateTzOut = 1;
18743
18763
  const quote = requireQuote$2();
18744
18764
 
18745
- function _new(context, table, alias, span) {
18746
- alias = quote(alias);
18747
- let columnsMap = span.columns;
18748
- var columns = table._columns;
18749
- var sql = '';
18750
- var separator = '';
18751
-
18752
- for (var i = 0; i < columns.length; i++) {
18753
- var column = columns[i];
18754
- if (!columnsMap || (columnsMap.get(column))) {
18755
- sql = sql + separator + formatColumn(column) + ' as ' + quote(column.alias);
18756
- separator = ',';
18757
- }
18758
- }
18759
-
18760
- for (let name in span.aggregates || {}) {
18761
- sql = sql + separator + span.aggregates[name].expression(name);
18762
- }
18763
-
18764
- return sql;
18765
-
18766
- function formatColumn(column) {
18767
-
18768
- const formatted = column.formatOut && column.tsType !== 'DateColumn' ? column.formatOut(context, alias) : alias + '.' + quote(column._dbName);
18769
- if (column.dbNull === null)
18770
- return formatted;
18771
- else {
18772
- const encoded = column.encode.unsafe(context, column.dbNull);
18773
- return `CASE WHEN ${formatted}=${encoded} THEN null ELSE ${formatted} END`;
18774
- }
18775
-
18776
- }
18777
- }
18778
-
18779
- newShallowColumnSql = _new;
18780
- return newShallowColumnSql;
18781
- }
18782
-
18783
- var newSingleQuery;
18784
- var hasRequiredNewSingleQuery;
18785
-
18786
- function requireNewSingleQuery () {
18787
- if (hasRequiredNewSingleQuery) return newSingleQuery;
18788
- hasRequiredNewSingleQuery = 1;
18789
- var newColumnSql = requireNewShallowColumnSql();
18790
- var newWhereSql = requireNewWhereSql();
18791
- var newParameterized = requireNewParameterized();
18792
-
18793
- function _new(context, table, filter, span, alias, subQueries, orderBy, limit, offset) {
18794
- var columnSql = newColumnSql(context, table, alias, span);
18795
- var whereSql = newWhereSql(context, table, filter, alias);
18796
- if (limit)
18797
- limit = limit + ' ';
18798
-
18799
- let join = '';
18800
- const set = new Set();
18801
- for (let key in span.aggregates) {
18802
- const agg = span.aggregates[key];
18803
- for (let sql of agg.joins) {
18804
- if (!set.has(sql)) {
18805
- join = join + sql;
18806
- set.add(sql);
18807
- }
18808
- }
18809
- }
18810
-
18811
-
18812
- return newParameterized('select ' + limit + columnSql).append(subQueries).append(' from ' + `[${table._dbName}] [${alias}]` + join).append(whereSql).append(orderBy + offset);
18813
- }
18814
-
18815
- newSingleQuery = _new;
18816
- return newSingleQuery;
18817
- }
18818
-
18819
- var joinLegToQuery_1;
18820
- var hasRequiredJoinLegToQuery;
18821
-
18822
- function requireJoinLegToQuery () {
18823
- if (hasRequiredJoinLegToQuery) return joinLegToQuery_1;
18824
- hasRequiredJoinLegToQuery = 1;
18825
- const newShallowJoinSql = requireNewShallowJoinSqlCore();
18826
-
18827
- function joinLegToQuery(newQuery, context, parentAlias, leg, _legNo) {
18828
- var childAlias = parentAlias + leg.name;
18829
- var span = leg.span;
18830
- var parentTable = leg.table;
18831
- var childColumns = span.table._primaryColumns;
18832
- var parentColumns = leg.columns;
18833
-
18834
- var filter = newShallowJoinSql(context, parentTable, childColumns, parentColumns, childAlias, parentAlias, leg.span.where);
18835
- var query = newQuery(context, span.table, filter, span, childAlias);
18836
- return query.prepend('JSON_QUERY((').append(` FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER)) "${leg.name}"`);
18837
- }
18838
-
18839
- joinLegToQuery_1 = joinLegToQuery;
18840
- return joinLegToQuery_1;
18841
- }
18842
-
18843
- var oneLegToQuery_1;
18844
- var hasRequiredOneLegToQuery;
18845
-
18846
- function requireOneLegToQuery () {
18847
- if (hasRequiredOneLegToQuery) return oneLegToQuery_1;
18848
- hasRequiredOneLegToQuery = 1;
18849
- const newShallowJoinSql = requireNewShallowJoinSqlCore();
18850
- const newParameterized = requireNewParameterized();
18851
- const formatString = requireFormat();
18852
-
18853
- function oneLegToQuery(newQuery, context, rightAlias, leg, _legNo) {
18854
- let leftAlias = rightAlias + leg.name;
18855
- let span = leg.span;
18856
- let rightTable = leg.table;
18857
- let rightColumns = rightTable._primaryColumns;
18858
- let leftColumns = leg.columns;
18859
-
18860
- let filter = newShallowJoinSql(context, rightTable, leftColumns, rightColumns, leftAlias, rightAlias, leg.span.where);
18861
- let query = newQuery(context, span.table, filter, span, leftAlias);
18862
- let sql = 'SELECT TOP 1' + query.sql().substring(6);
18863
- return newParameterized(formatString('JSON_QUERY((%s FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER)) "%s"', sql, leg.name), query.parameters);
18864
- }
18865
-
18866
- oneLegToQuery_1 = oneLegToQuery;
18867
- return oneLegToQuery_1;
18868
- }
18869
-
18870
- var manyLegToQuery_1;
18871
- var hasRequiredManyLegToQuery;
18872
-
18873
- function requireManyLegToQuery () {
18874
- if (hasRequiredManyLegToQuery) return manyLegToQuery_1;
18875
- hasRequiredManyLegToQuery = 1;
18876
- const newShallowJoinSql = requireNewShallowJoinSqlCore();
18877
-
18878
- function manyLegToQuery(newQuery, context, rightAlias, leg, _legNo) {
18879
- var leftAlias = rightAlias + leg.name;
18880
- var span = leg.span;
18881
- var rightTable = leg.table;
18882
- var rightColumns = rightTable._primaryColumns;
18883
- var leftColumns = leg.columns;
18884
-
18885
- var filter = newShallowJoinSql(context, rightTable, leftColumns, rightColumns, leftAlias, rightAlias, leg.span.where);
18886
- var query = newQuery(context, span.table, filter, span, leftAlias);
18887
- return query.prepend('JSON_QUERY( coalesce((').append(` FOR JSON PATH, INCLUDE_NULL_VALUES),'[]')) "${leg.name}"`);
18888
- }
18889
-
18890
- manyLegToQuery_1 = manyLegToQuery;
18891
- return manyLegToQuery_1;
18892
- }
18893
-
18894
- var newSubQueries_1;
18895
- var hasRequiredNewSubQueries;
18896
-
18897
- function requireNewSubQueries () {
18898
- if (hasRequiredNewSubQueries) return newSubQueries_1;
18899
- hasRequiredNewSubQueries = 1;
18900
- const newParameterized = requireNewParameterized();
18901
- const joinLegToQuery = requireJoinLegToQuery();
18902
- const oneLegToQuery = requireOneLegToQuery();
18903
- const manyLegToQuery = requireManyLegToQuery();
18904
-
18905
- function newSubQueries(newQuery, context, _table, span, alias) {
18906
- var result = newParameterized('', []);
18907
- var c = {};
18908
- var _legNo;
18909
-
18910
- c.visitJoin = function(leg) {
18911
- result = result.append(',').append(joinLegToQuery(newQuery, context, alias, leg, _legNo));
18912
- };
18913
- c.visitOne = function(leg) {
18914
- result = result.append(',').append(oneLegToQuery(newQuery, context, alias, leg, _legNo));
18915
- };
18916
- c.visitMany = function(leg) {
18917
- result = result.append(',').append(manyLegToQuery(newQuery, context, alias, leg, _legNo));
18918
- };
18919
-
18920
- span.legs.forEach(onEachLeg);
18921
-
18922
- function onEachLeg(leg, legNo) {
18923
- _legNo = legNo;
18924
- leg.accept(c);
18925
- }
18926
-
18927
- return result;
18928
- }
18929
-
18930
- newSubQueries_1 = newSubQueries;
18931
- return newSubQueries_1;
18932
- }
18933
-
18934
- var newQueryCore;
18935
- var hasRequiredNewQueryCore;
18936
-
18937
- function requireNewQueryCore () {
18938
- if (hasRequiredNewQueryCore) return newQueryCore;
18939
- hasRequiredNewQueryCore = 1;
18940
- var newSingleQuery = requireNewSingleQuery();
18941
- var newSubQueries = requireNewSubQueries();
18942
- var extractFilter = requireExtractFilter();
18943
- var extractOrderBy = requireExtractOrderBy();
18944
- var extractLimit = requireExtractLimit();
18945
- var limitAndOffset = requireLimitAndOffset$2();
18946
-
18947
- function newQuery(context, table, filter, span, alias) {
18948
- filter = extractFilter(filter);
18949
- var orderBy = extractOrderBy(context, table, alias, span.orderBy);
18950
- var limit = extractLimit(context, span);
18951
- var offset = limitAndOffset(span);
18952
-
18953
- var subQueries = newSubQueries(newQuery, context, table, span, alias);
18954
- return newSingleQuery(context, table, filter, span, alias, subQueries, orderBy, limit, offset);
18955
- }
18956
-
18957
- newQueryCore = newQuery;
18958
- return newQueryCore;
18959
- }
18960
-
18961
- var newQuery_1;
18962
- var hasRequiredNewQuery;
18963
-
18964
- function requireNewQuery () {
18965
- if (hasRequiredNewQuery) return newQuery_1;
18966
- hasRequiredNewQuery = 1;
18967
- var newQueryCore = requireNewQueryCore();
18968
-
18969
- function newQuery() {
18970
- var query = newQueryCore.apply(null, arguments);
18971
- return query.append(' FOR JSON path, INCLUDE_NULL_VALUES');
18972
- }
18973
-
18974
- newQuery_1 = newQuery;
18975
- return newQuery_1;
18976
- }
18977
-
18978
- var getManyDto_1;
18979
- var hasRequiredGetManyDto;
18980
-
18981
- function requireGetManyDto () {
18982
- if (hasRequiredGetManyDto) return getManyDto_1;
18983
- hasRequiredGetManyDto = 1;
18984
- const newQuery = requireNewQuery();
18985
- const negotiateRawSqlFilter = requireNegotiateRawSqlFilter();
18986
- const strategyToSpan = requireStrategyToSpan();
18987
- const executeQueries = requireExecuteQueries();
18765
+ function formatDateOut(column, alias) {
18766
+ if (alias)
18767
+ return `FORMAT(${alias}.${quote(column._dbName)}, 'yyyy-MM-ddTHH:mm:sszzz')`;
18768
+ // return `LEFT(CONVERT(varchar(33), ${alias}.${quote(column._dbName)}, 127), 25)`;
18769
+ else
18770
+ return `FORMAT(${quote(column._dbName)}, 'yyyy-MM-ddTHH:mm:sszzz')`;
18771
+ // return `LEFT(CONVERT(varchar(33), ${quote(column._dbName)}, 127), 25)`;
18988
18772
 
18989
- async function getManyDto(context, table, filter, strategy) {
18990
- filter = negotiateRawSqlFilter(context, filter, table);
18991
- if (strategy && strategy.where) {
18992
- let arg = typeof strategy.where === 'function' ? strategy.where(table) : strategy.where;
18993
- filter = filter.and(context, arg);
18994
- }
18995
- let span = strategyToSpan(table, strategy);
18996
- let alias = table._dbName;
18997
18773
 
18998
- const query = newQuery(context, table, filter, span, alias);
18999
- const res = await executeQueries(context, [query]);
19000
- const rows = await res[0];
19001
- if (rows.length === 0)
19002
- return [];
19003
- let json = '';
19004
- for (let i = 0; i < rows.length; i++) {
19005
- json += rows[i]['JSON_F52E2B61-18A1-11d1-B105-00805F49916B'];
19006
- }
19007
- return JSON.parse(json);
19008
18774
  }
19009
18775
 
19010
- getManyDto_1 = getManyDto;
19011
- return getManyDto_1;
18776
+ formatDateTzOut = formatDateOut;
18777
+ return formatDateTzOut;
19012
18778
  }
19013
18779
 
19014
18780
  var newTransaction$2;
@@ -19023,8 +18789,8 @@ function requireNewTransaction$2 () {
19023
18789
  var selectForUpdateSql = requireSelectForUpdateSql$2();
19024
18790
  const limitAndOffset = requireLimitAndOffset$2();
19025
18791
  const insertSql = requireInsertSql$2();
19026
- const getManyDto = requireGetManyDto();
19027
18792
  const formatDateOut = requireFormatDateOut$2();
18793
+ const formatDateTzOut = requireFormatDateTzOut();
19028
18794
  const formatBigintOut = requireFormatBigintOut$2();
19029
18795
  const formatJSONOut = requireFormatJSONOut();
19030
18796
  const insert = requireInsert$2();
@@ -19037,7 +18803,6 @@ function requireNewTransaction$2 () {
19037
18803
  rdb.pool = pool;
19038
18804
  }
19039
18805
  rdb.engine = 'mssql';
19040
- rdb.getManyDto = getManyDto;
19041
18806
  rdb.encodeBoolean = encodeBoolean;
19042
18807
  rdb.decodeJSON = decodeJSON;
19043
18808
  rdb.encodeJSON = JSON.stringify;
@@ -19047,6 +18812,7 @@ function requireNewTransaction$2 () {
19047
18812
  rdb.insertSql = insertSql;
19048
18813
  rdb.insert = insert;
19049
18814
  rdb.formatDateOut = formatDateOut;
18815
+ rdb.formatDateTzOut = formatDateTzOut;
19050
18816
  rdb.formatBigintOut = formatBigintOut;
19051
18817
  rdb.formatJSONOut = formatJSONOut;
19052
18818
  rdb.multipleStatements = true;
package/docs/changelog.md CHANGED
@@ -1,4 +1,6 @@
1
1
  ## Changelog
2
+ __4.7.14__
3
+ Improved performance for SQL Server.
2
4
  __4.7.13__
3
5
  Change in *.d.ts: Allow count, delete and deleteCascade to have no arguments.
4
6
  __4.7.12__
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orange-orm",
3
- "version": "4.7.13",
3
+ "version": "4.7.14",
4
4
  "main": "./src/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "browser": "./dist/index.browser.mjs",
@@ -0,0 +1,14 @@
1
+ var getSessionSingleton = require('../../getSessionSingleton');
2
+ const quote = require('../../quote');
3
+
4
+ function formatOut(context, column, alias) {
5
+ var formatColumn = getSessionSingleton(context, 'formatDateTzOut') || getSessionSingleton(context, 'formatDateOut');
6
+ if (formatColumn)
7
+ return formatColumn(column, alias);
8
+ else if (alias)
9
+ return `${alias}.${quote(context, column._dbName)}`;
10
+ else
11
+ return `${quote(context, column._dbName)}`;
12
+ }
13
+
14
+ module.exports = formatOut;
@@ -1,6 +1,6 @@
1
1
  var newEncode = require('./dateWithTimeZone/newEncode');
2
2
  var newDecode = require('./date/newDecode');
3
- var formatOut = require('./date/formatOut');
3
+ var formatOut = require('./dateWithTimeZone/formatOut');
4
4
  var purify = require('./date/purify');
5
5
 
6
6
  function _new(column) {
@@ -1,9 +1,7 @@
1
- let tryGetSessionContext = require('../tryGetSessionContext');
2
-
3
1
  function newAggregate(_relations) {
4
2
 
5
3
  function aggregate(context, fn) {
6
- const includeMany = tryGetSessionContext(context)?.engine === 'mssql';
4
+ const includeMany = false;
7
5
  let { relations, alias } = extract(includeMany, _relations);
8
6
  const table = relations[relations.length - 1].childTable;
9
7
  if (!relations[0].isMany || includeMany)
@@ -1,10 +1,9 @@
1
1
  const negotiateRawSqlFilter = require('../column/negotiateRawSqlFilter');
2
- let tryGetSessionContext = require('../tryGetSessionContext');
3
2
 
4
3
  function newWhere(_relations, _depth) {
5
4
 
6
5
  function where(context, fn) {
7
- const includeMany = tryGetSessionContext(context)?.engine === 'mssql';
6
+ const includeMany = false;
8
7
  let { relations, alias } = extract(includeMany, _relations);
9
8
  const table = relations[relations.length - 1].childTable;
10
9
  if (!relations[0].isMany || includeMany)
@@ -2,9 +2,9 @@ const quote = require('./quote');
2
2
 
3
3
  function formatDateOut(column, alias) {
4
4
  if (alias)
5
- return `CONVERT(VARCHAR, ${alias}.${quote(column._dbName)}, 121)`;
5
+ return `CONVERT(VARCHAR, ${alias}.${quote(column._dbName)}, 126)`;
6
6
  else
7
- return `CONVERT(VARCHAR, ${quote(column._dbName)}, 121)`;
7
+ return `CONVERT(VARCHAR, ${quote(column._dbName)}, 126)`;
8
8
  }
9
9
 
10
10
  module.exports = formatDateOut;
@@ -0,0 +1,14 @@
1
+ const quote = require('./quote');
2
+
3
+ function formatDateOut(column, alias) {
4
+ if (alias)
5
+ return `FORMAT(${alias}.${quote(column._dbName)}, 'yyyy-MM-ddTHH:mm:sszzz')`;
6
+ // return `LEFT(CONVERT(varchar(33), ${alias}.${quote(column._dbName)}, 127), 25)`;
7
+ else
8
+ return `FORMAT(${quote(column._dbName)}, 'yyyy-MM-ddTHH:mm:sszzz')`;
9
+ // return `LEFT(CONVERT(varchar(33), ${quote(column._dbName)}, 127), 25)`;
10
+
11
+
12
+ }
13
+
14
+ module.exports = formatDateOut;
@@ -4,8 +4,8 @@ var deleteFromSql = require('./deleteFromSql');
4
4
  var selectForUpdateSql = require('./selectForUpdateSql');
5
5
  const limitAndOffset = require('./limitAndOffset');
6
6
  const insertSql = require('./insertSql');
7
- const getManyDto = require('./getManyDto');
8
7
  const formatDateOut = require('./formatDateOut');
8
+ const formatDateTzOut = require('./formatDateTzOut');
9
9
  const formatBigintOut = require('./formatBigintOut');
10
10
  const formatJSONOut = require('./formatJSONOut');
11
11
  const insert = require('./insert');
@@ -18,7 +18,6 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
18
18
  rdb.pool = pool;
19
19
  }
20
20
  rdb.engine = 'mssql';
21
- rdb.getManyDto = getManyDto;
22
21
  rdb.encodeBoolean = encodeBoolean;
23
22
  rdb.decodeJSON = decodeJSON;
24
23
  rdb.encodeJSON = JSON.stringify;
@@ -28,6 +27,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
28
27
  rdb.insertSql = insertSql;
29
28
  rdb.insert = insert;
30
29
  rdb.formatDateOut = formatDateOut;
30
+ rdb.formatDateTzOut = formatDateTzOut;
31
31
  rdb.formatBigintOut = formatBigintOut;
32
32
  rdb.formatJSONOut = formatJSONOut;
33
33
  rdb.multipleStatements = true;