orange-orm 4.7.10 → 4.7.11

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.
Files changed (49) hide show
  1. package/README.md +2 -0
  2. package/dist/index.browser.mjs +264 -113
  3. package/dist/index.mjs +431 -122
  4. package/docs/changelog.md +2 -0
  5. package/package.json +1 -1
  6. package/src/bunSqlite/newTransaction.js +2 -0
  7. package/src/d1/newTransaction.js +2 -0
  8. package/src/map.d.ts +39 -0
  9. package/src/mssql/formatBigintIn.js +5 -0
  10. package/src/mssql/newTransaction.js +4 -0
  11. package/src/mssql/pool/newGenericPool.js +7 -0
  12. package/src/mssql/wrapQuery.js +1 -0
  13. package/src/mySql/formatBigintOut.js +11 -0
  14. package/src/mySql/newTransaction.js +2 -0
  15. package/src/nodeSqlite/newTransaction.js +2 -0
  16. package/src/oracle/formatBigintOut.js +12 -0
  17. package/src/oracle/formatDateOut.js +4 -1
  18. package/src/oracle/insertSql.js +2 -2
  19. package/src/oracle/mergeSql.js +1 -1
  20. package/src/oracle/newTransaction.js +2 -0
  21. package/src/pg/formatDateOut.js +4 -1
  22. package/src/sap/encodeBigint.js +8 -0
  23. package/src/sap/formatBigintIn.js +5 -0
  24. package/src/sap/formatBigintOut.js +11 -0
  25. package/src/sap/formatDateOut.js +4 -1
  26. package/src/sap/insertSql.js +1 -1
  27. package/src/sap/mergeSql.js +1 -1
  28. package/src/sap/newTransaction.js +4 -0
  29. package/src/sqlite/formatBigintOut.js +11 -0
  30. package/src/sqlite/lastInsertedSql.js +1 -1
  31. package/src/sqlite3/newTransaction.js +2 -0
  32. package/src/table/column/bigint/newDecode.js +18 -0
  33. package/src/table/column/bigint/newEncode.js +44 -0
  34. package/src/table/column/bigint.js +16 -0
  35. package/src/table/column/date/formatOut.js +3 -1
  36. package/src/table/column/formatOutGeneric.js +14 -0
  37. package/src/table/column/in.js +7 -5
  38. package/src/table/column/json.js +2 -2
  39. package/src/table/column.js +5 -0
  40. package/src/table/commands/newGetLastInsertedCommandCore.js +11 -1
  41. package/src/table/commands/newInsertCommandCore.js +1 -1
  42. package/src/tedious/formatBigintOut.js +11 -0
  43. package/src/tedious/formatDateOut.js +4 -1
  44. package/src/tedious/formatJSONOut.js +4 -1
  45. package/src/tedious/insertSql.js +5 -5
  46. package/src/tedious/mergeSql.js +3 -3
  47. package/src/tedious/newTransaction.js +2 -0
  48. package/src/tedious/outputInsertedSql.js +11 -2
  49. package/src/table/column/json/formatOut.js +0 -12
package/README.md CHANGED
@@ -1659,6 +1659,7 @@ async function execute() {
1659
1659
 
1660
1660
  - **`string`** maps to VARCHAR or TEXT in sql
1661
1661
  - **`numeric`** maps to INTEGER, DECIMAL, NUMERIC, TINYINT FLOAT/REAL or DOUBLE in sql.
1662
+ - **`bigint`** maps to INTEGER, BIGINT in sql.
1662
1663
  - **`boolean`** maps to BIT, TINYINT(1) or INTEGER in sql.
1663
1664
  - **`uuid`** is represented as string in javascript and maps to UUID, GUID or VARCHAR in sql.
1664
1665
  - **`date`** is represented as ISO 8601 string in javascript and maps to DATE, DATETIME, TIMESTAMP or DAY in sql. Representing datetime values as ISO 8601 strings, rather than relying on JavaScript's native Date object, has multiple advantages, especially when dealing with databases and servers in different time zones. The datetime values are inherently accompanied by their respective time zones. This ensures that the datetime value remains consistent regardless of where it's being viewed or interpreted. On the other hand, JavaScript's Date object is typically tied to the time zone of the environment in which it's executed, which could lead to inconsistencies between the client and the database server.
@@ -1680,6 +1681,7 @@ const map = orange.map(x => ({
1680
1681
  id: x.column('id').uuid().primary().notNull(),
1681
1682
  name: x.column('name').string(),
1682
1683
  balance: x.column('balance').numeric(),
1684
+ discordId: x.column('balance').bigint(),
1683
1685
  regularDate: x.column('regularDate').date(),
1684
1686
  tzDate: x.column('tzDate').dateWithTimeZone(),
1685
1687
  picture: x.column('picture').binary(),
@@ -3929,13 +3929,15 @@ function require_in () {
3929
3929
  }
3930
3930
  const firstPart = `${quote(context, alias)}.${quote(context, column._dbName)} in (`;
3931
3931
 
3932
- const encode = column.encode.direct;
3933
- const params = new Array(values.length);
3932
+ const encode = column.encode;
3933
+ const paramsSql = new Array(values.length);
3934
+ let paramsValues = [];
3934
3935
  for (let i = 0; i < values.length; i++) {
3935
- params[i] = encode(context, values[i]);
3936
+ paramsSql[i] = encode(context, values[i]);
3937
+ paramsValues = [...paramsValues, ...paramsSql[i].parameters];
3936
3938
  }
3937
- const sql = `${firstPart + new Array(values.length).fill('?').join(',')})`;
3938
- return newBoolean(newParameterized(sql, params));
3939
+ const sql = `${firstPart + paramsSql.map(x => x.sql()).join(',')})`;
3940
+ return newBoolean(newParameterized(sql, paramsValues));
3939
3941
  }
3940
3942
 
3941
3943
  _in_1 = _in;
@@ -4262,12 +4264,12 @@ function requirePurify$6 () {
4262
4264
  return purify_1$5;
4263
4265
  }
4264
4266
 
4265
- var newEncode$7;
4266
- var hasRequiredNewEncode$7;
4267
+ var newEncode$8;
4268
+ var hasRequiredNewEncode$8;
4267
4269
 
4268
- function requireNewEncode$7 () {
4269
- if (hasRequiredNewEncode$7) return newEncode$7;
4270
- hasRequiredNewEncode$7 = 1;
4270
+ function requireNewEncode$8 () {
4271
+ if (hasRequiredNewEncode$8) return newEncode$8;
4272
+ hasRequiredNewEncode$8 = 1;
4271
4273
  var newPara = requireNewParameterized();
4272
4274
  var purify = requirePurify$6();
4273
4275
 
@@ -4301,8 +4303,8 @@ function requireNewEncode$7 () {
4301
4303
 
4302
4304
  }
4303
4305
 
4304
- newEncode$7 = _new;
4305
- return newEncode$7;
4306
+ newEncode$8 = _new;
4307
+ return newEncode$8;
4306
4308
  }
4307
4309
 
4308
4310
  var newDecodeCore;
@@ -4507,7 +4509,7 @@ var hasRequiredString;
4507
4509
  function requireString () {
4508
4510
  if (hasRequiredString) return string;
4509
4511
  hasRequiredString = 1;
4510
- var newEncode = requireNewEncode$7();
4512
+ var newEncode = requireNewEncode$8();
4511
4513
  var newDecode = requireNewDecodeCore();
4512
4514
  var startsWith = requireStartsWith();
4513
4515
  var endsWith = requireEndsWith();
@@ -4581,12 +4583,12 @@ function requirePurify$5 () {
4581
4583
  return purify_1$4;
4582
4584
  }
4583
4585
 
4584
- var newEncode$6;
4585
- var hasRequiredNewEncode$6;
4586
+ var newEncode$7;
4587
+ var hasRequiredNewEncode$7;
4586
4588
 
4587
- function requireNewEncode$6 () {
4588
- if (hasRequiredNewEncode$6) return newEncode$6;
4589
- hasRequiredNewEncode$6 = 1;
4589
+ function requireNewEncode$7 () {
4590
+ if (hasRequiredNewEncode$7) return newEncode$7;
4591
+ hasRequiredNewEncode$7 = 1;
4590
4592
  var newPara = requireNewParameterized();
4591
4593
  var purify = requirePurify$5();
4592
4594
  var getSessionSingleton = requireGetSessionSingleton();
@@ -4636,16 +4638,16 @@ function requireNewEncode$6 () {
4636
4638
  return encode;
4637
4639
  }
4638
4640
 
4639
- newEncode$6 = _new;
4640
- return newEncode$6;
4641
+ newEncode$7 = _new;
4642
+ return newEncode$7;
4641
4643
  }
4642
4644
 
4643
- var newDecode$5;
4644
- var hasRequiredNewDecode$5;
4645
+ var newDecode$6;
4646
+ var hasRequiredNewDecode$6;
4645
4647
 
4646
- function requireNewDecode$5 () {
4647
- if (hasRequiredNewDecode$5) return newDecode$5;
4648
- hasRequiredNewDecode$5 = 1;
4648
+ function requireNewDecode$6 () {
4649
+ if (hasRequiredNewDecode$6) return newDecode$6;
4650
+ hasRequiredNewDecode$6 = 1;
4649
4651
  let newDecodeCore = requireNewDecodeCore();
4650
4652
  let getSessionContext = requireGetSessionContext();
4651
4653
 
@@ -4666,29 +4668,31 @@ function requireNewDecode$5 () {
4666
4668
  };
4667
4669
  }
4668
4670
 
4669
- newDecode$5 = _new;
4670
- return newDecode$5;
4671
+ newDecode$6 = _new;
4672
+ return newDecode$6;
4671
4673
  }
4672
4674
 
4673
- var formatOut_1$1;
4674
- var hasRequiredFormatOut$1;
4675
+ var formatOutGeneric_1;
4676
+ var hasRequiredFormatOutGeneric;
4675
4677
 
4676
- function requireFormatOut$1 () {
4677
- if (hasRequiredFormatOut$1) return formatOut_1$1;
4678
- hasRequiredFormatOut$1 = 1;
4678
+ function requireFormatOutGeneric () {
4679
+ if (hasRequiredFormatOutGeneric) return formatOutGeneric_1;
4680
+ hasRequiredFormatOutGeneric = 1;
4679
4681
  var getSessionSingleton = requireGetSessionSingleton();
4680
4682
  const quote = requireQuote$2();
4681
4683
 
4682
- function formatOut(context, column, alias) {
4683
- var formatColumn = getSessionSingleton(context, 'formatJSONOut');
4684
+ function formatOutGeneric(context, column, fnName, alias) {
4685
+ var formatColumn = getSessionSingleton(context, fnName);
4684
4686
  if (formatColumn)
4685
4687
  return formatColumn(column, alias);
4686
- else
4688
+ else if (alias)
4687
4689
  return `${alias}.${quote(context, column._dbName)}`;
4690
+ else
4691
+ return `${quote(context, column._dbName)}`;
4688
4692
  }
4689
4693
 
4690
- formatOut_1$1 = formatOut;
4691
- return formatOut_1$1;
4694
+ formatOutGeneric_1 = formatOutGeneric;
4695
+ return formatOutGeneric_1;
4692
4696
  }
4693
4697
 
4694
4698
  var require$$10 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(onChange);
@@ -4699,9 +4703,9 @@ var hasRequiredJson;
4699
4703
  function requireJson () {
4700
4704
  if (hasRequiredJson) return json;
4701
4705
  hasRequiredJson = 1;
4702
- var newEncode = requireNewEncode$6();
4703
- var newDecode = requireNewDecode$5();
4704
- var formatOut = requireFormatOut$1();
4706
+ var newEncode = requireNewEncode$7();
4707
+ var newDecode = requireNewDecode$6();
4708
+ var formatOut = requireFormatOutGeneric();
4705
4709
  var purify = requirePurify$5();
4706
4710
  var onChange = require$$10;
4707
4711
  let clone = require$$5;
@@ -4711,7 +4715,7 @@ function requireJson () {
4711
4715
  column.purify = purify;
4712
4716
  column.encode = newEncode(column);
4713
4717
  column.decode = newDecode(column);
4714
- column.formatOut = (context, ...rest) => formatOut.apply(null, [context, column, ...rest]);
4718
+ column.formatOut = (context, ...rest) => formatOut.apply(null, [context, column, 'formatJSONOut', ...rest]);
4715
4719
 
4716
4720
  column.onChange = onChange;
4717
4721
  column.toDto = toDto;
@@ -4744,12 +4748,12 @@ function requirePurify$4 () {
4744
4748
  return purify;
4745
4749
  }
4746
4750
 
4747
- var newEncode$5;
4748
- var hasRequiredNewEncode$5;
4751
+ var newEncode$6;
4752
+ var hasRequiredNewEncode$6;
4749
4753
 
4750
- function requireNewEncode$5 () {
4751
- if (hasRequiredNewEncode$5) return newEncode$5;
4752
- hasRequiredNewEncode$5 = 1;
4754
+ function requireNewEncode$6 () {
4755
+ if (hasRequiredNewEncode$6) return newEncode$6;
4756
+ hasRequiredNewEncode$6 = 1;
4753
4757
  var newPara = requireNewParameterized();
4754
4758
  var purify = requirePurify$4();
4755
4759
 
@@ -4783,16 +4787,16 @@ function requireNewEncode$5 () {
4783
4787
  return encode;
4784
4788
  }
4785
4789
 
4786
- newEncode$5 = _new;
4787
- return newEncode$5;
4790
+ newEncode$6 = _new;
4791
+ return newEncode$6;
4788
4792
  }
4789
4793
 
4790
- var newDecode$4;
4791
- var hasRequiredNewDecode$4;
4794
+ var newDecode$5;
4795
+ var hasRequiredNewDecode$5;
4792
4796
 
4793
- function requireNewDecode$4 () {
4794
- if (hasRequiredNewDecode$4) return newDecode$4;
4795
- hasRequiredNewDecode$4 = 1;
4797
+ function requireNewDecode$5 () {
4798
+ if (hasRequiredNewDecode$5) return newDecode$5;
4799
+ hasRequiredNewDecode$5 = 1;
4796
4800
  function _new(column) {
4797
4801
 
4798
4802
  return function(_context, value) {
@@ -4802,8 +4806,8 @@ function requireNewDecode$4 () {
4802
4806
  };
4803
4807
  }
4804
4808
 
4805
- newDecode$4 = _new;
4806
- return newDecode$4;
4809
+ newDecode$5 = _new;
4810
+ return newDecode$5;
4807
4811
  }
4808
4812
 
4809
4813
  var guid;
@@ -4812,8 +4816,8 @@ var hasRequiredGuid;
4812
4816
  function requireGuid () {
4813
4817
  if (hasRequiredGuid) return guid;
4814
4818
  hasRequiredGuid = 1;
4815
- var newEncode = requireNewEncode$5();
4816
- var newDecode = requireNewDecode$4();
4819
+ var newEncode = requireNewEncode$6();
4820
+ var newDecode = requireNewDecode$5();
4817
4821
  var purify = requirePurify$4();
4818
4822
 
4819
4823
  function _new(column) {
@@ -4874,12 +4878,12 @@ function requirePurify$3 () {
4874
4878
  return purify_1$3;
4875
4879
  }
4876
4880
 
4877
- var newEncode$4;
4878
- var hasRequiredNewEncode$4;
4881
+ var newEncode$5;
4882
+ var hasRequiredNewEncode$5;
4879
4883
 
4880
- function requireNewEncode$4 () {
4881
- if (hasRequiredNewEncode$4) return newEncode$4;
4882
- hasRequiredNewEncode$4 = 1;
4884
+ function requireNewEncode$5 () {
4885
+ if (hasRequiredNewEncode$5) return newEncode$5;
4886
+ hasRequiredNewEncode$5 = 1;
4883
4887
  var newPara = requireNewParameterized();
4884
4888
  var purify = requirePurify$3();
4885
4889
  var getSessionContext = requireGetSessionContext();
@@ -4931,16 +4935,16 @@ function requireNewEncode$4 () {
4931
4935
  }
4932
4936
 
4933
4937
 
4934
- newEncode$4 = _new;
4935
- return newEncode$4;
4938
+ newEncode$5 = _new;
4939
+ return newEncode$5;
4936
4940
  }
4937
4941
 
4938
- var newDecode$3;
4939
- var hasRequiredNewDecode$3;
4942
+ var newDecode$4;
4943
+ var hasRequiredNewDecode$4;
4940
4944
 
4941
- function requireNewDecode$3 () {
4942
- if (hasRequiredNewDecode$3) return newDecode$3;
4943
- hasRequiredNewDecode$3 = 1;
4945
+ function requireNewDecode$4 () {
4946
+ if (hasRequiredNewDecode$4) return newDecode$4;
4947
+ hasRequiredNewDecode$4 = 1;
4944
4948
  var newDecodeCore = requireNewDecodeCore();
4945
4949
  var dateToISOString = requireDateToISOString();
4946
4950
 
@@ -4957,8 +4961,8 @@ function requireNewDecode$3 () {
4957
4961
  };
4958
4962
  }
4959
4963
 
4960
- newDecode$3 = _new;
4961
- return newDecode$3;
4964
+ newDecode$4 = _new;
4965
+ return newDecode$4;
4962
4966
  }
4963
4967
 
4964
4968
  var formatOut_1;
@@ -4974,8 +4978,10 @@ function requireFormatOut () {
4974
4978
  var formatColumn = getSessionSingleton(context, 'formatDateOut');
4975
4979
  if (formatColumn)
4976
4980
  return formatColumn(column, alias);
4977
- else
4981
+ else if (alias)
4978
4982
  return `${alias}.${quote(context, column._dbName)}`;
4983
+ else
4984
+ return `${quote(context, column._dbName)}`;
4979
4985
  }
4980
4986
 
4981
4987
  formatOut_1 = formatOut;
@@ -4988,8 +4994,8 @@ var hasRequiredDate;
4988
4994
  function requireDate () {
4989
4995
  if (hasRequiredDate) return date;
4990
4996
  hasRequiredDate = 1;
4991
- var newEncode = requireNewEncode$4();
4992
- var newDecode = requireNewDecode$3();
4997
+ var newEncode = requireNewEncode$5();
4998
+ var newDecode = requireNewDecode$4();
4993
4999
  var formatOut = requireFormatOut();
4994
5000
  var purify = requirePurify$3();
4995
5001
 
@@ -5005,12 +5011,12 @@ function requireDate () {
5005
5011
  return date;
5006
5012
  }
5007
5013
 
5008
- var newEncode$3;
5009
- var hasRequiredNewEncode$3;
5014
+ var newEncode$4;
5015
+ var hasRequiredNewEncode$4;
5010
5016
 
5011
- function requireNewEncode$3 () {
5012
- if (hasRequiredNewEncode$3) return newEncode$3;
5013
- hasRequiredNewEncode$3 = 1;
5017
+ function requireNewEncode$4 () {
5018
+ if (hasRequiredNewEncode$4) return newEncode$4;
5019
+ hasRequiredNewEncode$4 = 1;
5014
5020
  var newPara = requireNewParameterized();
5015
5021
  var purify = requirePurify$3();
5016
5022
 
@@ -5054,8 +5060,8 @@ function requireNewEncode$3 () {
5054
5060
  }
5055
5061
 
5056
5062
 
5057
- newEncode$3 = _new;
5058
- return newEncode$3;
5063
+ newEncode$4 = _new;
5064
+ return newEncode$4;
5059
5065
  }
5060
5066
 
5061
5067
  var dateWithTimeZone;
@@ -5064,8 +5070,8 @@ var hasRequiredDateWithTimeZone;
5064
5070
  function requireDateWithTimeZone () {
5065
5071
  if (hasRequiredDateWithTimeZone) return dateWithTimeZone;
5066
5072
  hasRequiredDateWithTimeZone = 1;
5067
- var newEncode = requireNewEncode$3();
5068
- var newDecode = requireNewDecode$3();
5073
+ var newEncode = requireNewEncode$4();
5074
+ var newDecode = requireNewDecode$4();
5069
5075
  var formatOut = requireFormatOut();
5070
5076
  var purify = requirePurify$3();
5071
5077
 
@@ -5102,16 +5108,16 @@ function requirePurify$2 () {
5102
5108
  return purify_1$2;
5103
5109
  }
5104
5110
 
5105
- var newEncode$2;
5106
- var hasRequiredNewEncode$2;
5111
+ var newEncode$3;
5112
+ var hasRequiredNewEncode$3;
5107
5113
 
5108
- function requireNewEncode$2 () {
5109
- if (hasRequiredNewEncode$2) return newEncode$2;
5110
- hasRequiredNewEncode$2 = 1;
5114
+ function requireNewEncode$3 () {
5115
+ if (hasRequiredNewEncode$3) return newEncode$3;
5116
+ hasRequiredNewEncode$3 = 1;
5111
5117
  var purify = requirePurify$2();
5112
5118
  var newParam = requireNewParameterized();
5113
5119
 
5114
- newEncode$2 = function(column) {
5120
+ newEncode$3 = function(column) {
5115
5121
 
5116
5122
  function encode(_context, value) {
5117
5123
  value = purify(value);
@@ -5137,15 +5143,15 @@ function requireNewEncode$2 () {
5137
5143
 
5138
5144
  return encode;
5139
5145
  };
5140
- return newEncode$2;
5146
+ return newEncode$3;
5141
5147
  }
5142
5148
 
5143
- var newDecode$2;
5144
- var hasRequiredNewDecode$2;
5149
+ var newDecode$3;
5150
+ var hasRequiredNewDecode$3;
5145
5151
 
5146
- function requireNewDecode$2 () {
5147
- if (hasRequiredNewDecode$2) return newDecode$2;
5148
- hasRequiredNewDecode$2 = 1;
5152
+ function requireNewDecode$3 () {
5153
+ if (hasRequiredNewDecode$3) return newDecode$3;
5154
+ hasRequiredNewDecode$3 = 1;
5149
5155
  var newDecodeCore = requireNewDecodeCore();
5150
5156
 
5151
5157
  function _new(column) {
@@ -5161,8 +5167,8 @@ function requireNewDecode$2 () {
5161
5167
  };
5162
5168
  }
5163
5169
 
5164
- newDecode$2 = _new;
5165
- return newDecode$2;
5170
+ newDecode$3 = _new;
5171
+ return newDecode$3;
5166
5172
  }
5167
5173
 
5168
5174
  var numeric;
@@ -5171,8 +5177,8 @@ var hasRequiredNumeric;
5171
5177
  function requireNumeric () {
5172
5178
  if (hasRequiredNumeric) return numeric;
5173
5179
  hasRequiredNumeric = 1;
5174
- var newEncode = requireNewEncode$2();
5175
- var newDecode = requireNewDecode$2();
5180
+ var newEncode = requireNewEncode$3();
5181
+ var newDecode = requireNewDecode$3();
5176
5182
  var purify = requirePurify$2();
5177
5183
 
5178
5184
  function _new(column) {
@@ -5189,6 +5195,111 @@ function requireNumeric () {
5189
5195
  return numeric;
5190
5196
  }
5191
5197
 
5198
+ var newEncode$2;
5199
+ var hasRequiredNewEncode$2;
5200
+
5201
+ function requireNewEncode$2 () {
5202
+ if (hasRequiredNewEncode$2) return newEncode$2;
5203
+ hasRequiredNewEncode$2 = 1;
5204
+ var newPara = requireNewParameterized();
5205
+ var purify = requirePurify$6();
5206
+ var getSessionContext = requireGetSessionContext();
5207
+ var getSessionSingleton = requireGetSessionSingleton();
5208
+
5209
+ function _new(column) {
5210
+ var encode = function(context, value) {
5211
+ value = purify(value);
5212
+ if (value == null) {
5213
+ if (column.dbNull === null)
5214
+ return newPara('null');
5215
+ return newPara('\'' + column.dbNull + '\'');
5216
+ }
5217
+ var ctx = getSessionContext(context);
5218
+ var encodeCore = ctx.encodeBigint || encodeBigint;
5219
+ var formatIn = ctx.formatBigintIn;
5220
+ return newPara(formatIn ? formatIn('?') : '?', [encodeCore(value)]);
5221
+ };
5222
+
5223
+ encode.unsafe = function(context, value) {
5224
+ value = purify(value);
5225
+ if (value == null) {
5226
+ if (column.dbNull === null)
5227
+ ;
5228
+ return '\'' + column.dbNull + '\'';
5229
+ }
5230
+ var encodeCore = getSessionSingleton(context, 'encodeBigint') || encodeBigint;
5231
+ return encodeCore(value);
5232
+ };
5233
+
5234
+ encode.direct = function(context, value) {
5235
+ var encodeCore = getSessionSingleton(context, 'encodeBigint') || encodeBigint;
5236
+ return encodeCore(value);
5237
+ };
5238
+
5239
+ return encode;
5240
+
5241
+
5242
+ }
5243
+ function encodeBigint(value) {
5244
+ return value;
5245
+ }
5246
+
5247
+ newEncode$2 = _new;
5248
+ return newEncode$2;
5249
+ }
5250
+
5251
+ var newDecode$2;
5252
+ var hasRequiredNewDecode$2;
5253
+
5254
+ function requireNewDecode$2 () {
5255
+ if (hasRequiredNewDecode$2) return newDecode$2;
5256
+ hasRequiredNewDecode$2 = 1;
5257
+ var newDecodeCore = requireNewDecodeCore();
5258
+
5259
+ function _new(column) {
5260
+ var decodeCore = newDecodeCore(column);
5261
+
5262
+ return function(context, value) {
5263
+ value = decodeCore(context, value);
5264
+ if (value === null)
5265
+ return value;
5266
+ if (typeof(value) === 'string')
5267
+ return value;
5268
+ if (value.toString)
5269
+ return value.toString();
5270
+ return value;
5271
+ };
5272
+ }
5273
+
5274
+ newDecode$2 = _new;
5275
+ return newDecode$2;
5276
+ }
5277
+
5278
+ var bigint;
5279
+ var hasRequiredBigint;
5280
+
5281
+ function requireBigint () {
5282
+ if (hasRequiredBigint) return bigint;
5283
+ hasRequiredBigint = 1;
5284
+ var newEncode = requireNewEncode$2();
5285
+ var newDecode = requireNewDecode$2();
5286
+ var formatOut = requireFormatOutGeneric();
5287
+ var purify = requirePurify$6();
5288
+
5289
+ function _new(column) {
5290
+ column.tsType = 'BigintColumn';
5291
+ column.purify = purify;
5292
+ column.lazyDefault = '0';
5293
+ column.encode = newEncode(column);
5294
+ column.decode = newDecode(column);
5295
+ column.formatOut = (context, ...rest) => formatOut.apply(null, [context, column, 'formatBigintOut', ...rest]);
5296
+
5297
+ }
5298
+
5299
+ bigint = _new;
5300
+ return bigint;
5301
+ }
5302
+
5192
5303
  var purify_1$1;
5193
5304
  var hasRequiredPurify$1;
5194
5305
 
@@ -5473,6 +5584,11 @@ function requireColumn () {
5473
5584
  return c;
5474
5585
  };
5475
5586
 
5587
+ c.bigint = function() {
5588
+ requireBigint()(column);
5589
+ return c;
5590
+ };
5591
+
5476
5592
  c.boolean = function() {
5477
5593
  requireBoolean()(column);
5478
5594
  return c;
@@ -12526,6 +12642,36 @@ function requireEncodeBoolean () {
12526
12642
  return encodeBoolean_1;
12527
12643
  }
12528
12644
 
12645
+ var quote$1;
12646
+ var hasRequiredQuote$1;
12647
+
12648
+ function requireQuote$1 () {
12649
+ if (hasRequiredQuote$1) return quote$1;
12650
+ hasRequiredQuote$1 = 1;
12651
+ quote$1 = (name) => `"${name}"`;
12652
+ return quote$1;
12653
+ }
12654
+
12655
+ var formatBigintOut_1;
12656
+ var hasRequiredFormatBigintOut;
12657
+
12658
+ function requireFormatBigintOut () {
12659
+ if (hasRequiredFormatBigintOut) return formatBigintOut_1;
12660
+ hasRequiredFormatBigintOut = 1;
12661
+ const quote = requireQuote$1();
12662
+
12663
+ function formatBigintOut(column, alias) {
12664
+ const quotedCol = quote(column._dbName);
12665
+ if (alias)
12666
+ return `CAST(${alias}.${quotedCol} AS TEXT)`;
12667
+ else
12668
+ return `CAST(${quotedCol} AS TEXT)`;
12669
+ }
12670
+
12671
+ formatBigintOut_1 = formatBigintOut;
12672
+ return formatBigintOut_1;
12673
+ }
12674
+
12529
12675
  var format_1;
12530
12676
  var hasRequiredFormat;
12531
12677
 
@@ -12544,16 +12690,6 @@ function requireFormat () {
12544
12690
  return format_1;
12545
12691
  }
12546
12692
 
12547
- var quote$1;
12548
- var hasRequiredQuote$1;
12549
-
12550
- function requireQuote$1 () {
12551
- if (hasRequiredQuote$1) return quote$1;
12552
- hasRequiredQuote$1 = 1;
12553
- quote$1 = (name) => `"${name}"`;
12554
- return quote$1;
12555
- }
12556
-
12557
12693
  var deleteFromSql_1$1;
12558
12694
  var hasRequiredDeleteFromSql$1;
12559
12695
 
@@ -12596,7 +12732,7 @@ function requireLastInsertedSql$1 () {
12596
12732
  function lastInsertedSql(context, table, keyValues) {
12597
12733
  return keyValues.map((value,i) => {
12598
12734
  let column = table._primaryColumns[i];
12599
- if (value === undefined && column.tsType === 'NumberColumn')
12735
+ if (value === undefined && (column.tsType === 'NumberColumn' || column.tsType === 'BigintColumn'))
12600
12736
  return 'rowid IN (select last_insert_rowid())';
12601
12737
  else
12602
12738
  return column.eq(context, value);
@@ -12875,7 +13011,7 @@ function requireNewInsertCommandCore () {
12875
13011
  if (row['__' + column.alias] !== undefined) {
12876
13012
  let encoded = column.encode(context, row[alias]);
12877
13013
  if (encoded.parameters.length > 0) {
12878
- values.push('?');
13014
+ values.push(encoded.sql());
12879
13015
  parameters.push(encoded.parameters[0]);
12880
13016
  } else
12881
13017
  values.push(encoded.sql());
@@ -12908,7 +13044,17 @@ function requireNewGetLastInsertedCommandCore () {
12908
13044
  return newParameterized(sql, parameters);
12909
13045
 
12910
13046
  function columnNames() {
12911
- return table._columns.map(col => quote(context, col._dbName)).join(',');
13047
+ return table._columns.map(formatColumn).join(',');
13048
+ }
13049
+
13050
+ function formatColumn(column) {
13051
+ const formatted = column.formatOut ? column.formatOut(context) + ' as ' + quote(context, column._dbName) : quote(context, column._dbName);
13052
+ if (column.dbNull === null)
13053
+ return formatted;
13054
+ else {
13055
+ const encoded = column.encode.unsafe(context, column.dbNull);
13056
+ return `CASE WHEN ${formatted}=${encoded} THEN null ELSE ${formatted} END`;
13057
+ }
12912
13058
  }
12913
13059
 
12914
13060
  function whereSql() {
@@ -13039,6 +13185,7 @@ function requireNewTransaction$1 () {
13039
13185
  hasRequiredNewTransaction$1 = 1;
13040
13186
  const wrapQuery = requireWrapQuery$1();
13041
13187
  const encodeBoolean = requireEncodeBoolean();
13188
+ const formatBigintOut = requireFormatBigintOut();
13042
13189
  const deleteFromSql = requireDeleteFromSql$1();
13043
13190
  const selectForUpdateSql = requireSelectForUpdateSql$1();
13044
13191
  const lastInsertedSql = requireLastInsertedSql$1();
@@ -13057,6 +13204,7 @@ function requireNewTransaction$1 () {
13057
13204
  rdb.encodeBoolean = encodeBoolean;
13058
13205
  rdb.decodeJSON = decodeJSON;
13059
13206
  rdb.encodeJSON = JSON.stringify;
13207
+ rdb.formatBigintOut = formatBigintOut;
13060
13208
  rdb.deleteFromSql = deleteFromSql;
13061
13209
  rdb.selectForUpdateSql = selectForUpdateSql;
13062
13210
  rdb.lastInsertedSql = lastInsertedSql;
@@ -14259,7 +14407,10 @@ function requireFormatDateOut () {
14259
14407
  if (hasRequiredFormatDateOut) return formatDateOut_1;
14260
14408
  hasRequiredFormatDateOut = 1;
14261
14409
  function formatDateOut(column, alias) {
14262
- return `${alias}."${(column._dbName)}"::text`;
14410
+ if (alias)
14411
+ return `${alias}."${(column._dbName)}"::text`;
14412
+ else
14413
+ return `"${(column._dbName)}"::text`;
14263
14414
  }
14264
14415
 
14265
14416
  formatDateOut_1 = formatDateOut;