postgrejs 2.22.9 → 2.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/{esm/connection → connection}/bind-param.js +2 -0
  3. package/{esm/connection → connection}/connection.js +4 -2
  4. package/{esm/connection → connection}/cursor.js +8 -3
  5. package/{esm/connection → connection}/intl-connection.js +6 -3
  6. package/{esm/connection → connection}/pool.js +4 -1
  7. package/{esm/connection → connection}/portal.js +3 -1
  8. package/{esm/connection → connection}/prepared-statement.js +6 -3
  9. package/{esm/constants.js → constants.js} +1 -1
  10. package/{types/data-type-map.d.ts → data-type-map.d.ts} +2 -2
  11. package/{esm/data-type-map.js → data-type-map.js} +2 -2
  12. package/{esm/data-types → data-types}/int2-vector-type.js +1 -0
  13. package/{types/data-types → data-types}/timestamptz-type.d.ts +1 -1
  14. package/{esm/data-types → data-types}/timestamptz-type.js +1 -0
  15. package/package.json +12 -31
  16. package/{esm/protocol → protocol}/backend.js +1 -0
  17. package/{esm/protocol → protocol}/buffer-reader.js +2 -1
  18. package/{esm/protocol → protocol}/database-error.js +17 -0
  19. package/{esm/protocol → protocol}/frontend.js +2 -0
  20. package/{types/protocol → protocol}/pg-socket.d.ts +1 -1
  21. package/{esm/protocol → protocol}/pg-socket.js +9 -3
  22. package/{esm/protocol → protocol}/smart-buffer.js +9 -5
  23. package/{esm/util → util}/bigint-methods.js +1 -0
  24. package/cjs/connection/bind-param.js +0 -10
  25. package/cjs/connection/connection.js +0 -295
  26. package/cjs/connection/cursor.js +0 -91
  27. package/cjs/connection/intl-connection.js +0 -258
  28. package/cjs/connection/pool.js +0 -236
  29. package/cjs/connection/portal.js +0 -157
  30. package/cjs/connection/prepared-statement.js +0 -226
  31. package/cjs/constants.js +0 -249
  32. package/cjs/data-type-map.js +0 -131
  33. package/cjs/data-types/bool-type.js +0 -33
  34. package/cjs/data-types/box-type.js +0 -52
  35. package/cjs/data-types/bytea-type.js +0 -28
  36. package/cjs/data-types/char-type.js +0 -27
  37. package/cjs/data-types/circle-type.js +0 -51
  38. package/cjs/data-types/date-type.js +0 -75
  39. package/cjs/data-types/float4-type.js +0 -25
  40. package/cjs/data-types/float8-type.js +0 -25
  41. package/cjs/data-types/int2-type.js +0 -26
  42. package/cjs/data-types/int2-vector-type.js +0 -42
  43. package/cjs/data-types/int4-type.js +0 -28
  44. package/cjs/data-types/int8-type.js +0 -36
  45. package/cjs/data-types/json-type.js +0 -40
  46. package/cjs/data-types/jsonb-type.js +0 -44
  47. package/cjs/data-types/lseg-type.js +0 -55
  48. package/cjs/data-types/numeric-type.js +0 -125
  49. package/cjs/data-types/oid-type.js +0 -32
  50. package/cjs/data-types/point-type.js +0 -42
  51. package/cjs/data-types/time-type.js +0 -66
  52. package/cjs/data-types/timestamp-type.js +0 -89
  53. package/cjs/data-types/timestamptz-type.js +0 -76
  54. package/cjs/data-types/uuid-type.js +0 -39
  55. package/cjs/data-types/varchar-type.js +0 -27
  56. package/cjs/index.js +0 -28
  57. package/cjs/interfaces/command-result.js +0 -2
  58. package/cjs/interfaces/data-mapping-options.js +0 -2
  59. package/cjs/interfaces/data-type.js +0 -2
  60. package/cjs/interfaces/database-connection-params.js +0 -2
  61. package/cjs/interfaces/field-info.js +0 -2
  62. package/cjs/interfaces/query-options.js +0 -2
  63. package/cjs/interfaces/query-result.js +0 -2
  64. package/cjs/interfaces/script-execute-options.js +0 -2
  65. package/cjs/interfaces/script-result.js +0 -2
  66. package/cjs/interfaces/statement-prepare-options.js +0 -2
  67. package/cjs/package.json +0 -3
  68. package/cjs/protocol/backend.js +0 -262
  69. package/cjs/protocol/buffer-reader.js +0 -78
  70. package/cjs/protocol/database-error.js +0 -17
  71. package/cjs/protocol/frontend.js +0 -255
  72. package/cjs/protocol/pg-socket.js +0 -367
  73. package/cjs/protocol/protocol.js +0 -71
  74. package/cjs/protocol/sasl.js +0 -108
  75. package/cjs/protocol/smart-buffer.js +0 -178
  76. package/cjs/safe-event-emitter.js +0 -17
  77. package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
  78. package/cjs/types.js +0 -2
  79. package/cjs/util/array-calculatedim.js +0 -18
  80. package/cjs/util/bigint-methods.js +0 -44
  81. package/cjs/util/config-from-env.js +0 -29
  82. package/cjs/util/connection-config.js +0 -61
  83. package/cjs/util/convert-row-to-object.js +0 -12
  84. package/cjs/util/decode-binaryarray.js +0 -38
  85. package/cjs/util/encode-binaryarray.js +0 -44
  86. package/cjs/util/escape-literal.js +0 -26
  87. package/cjs/util/fast-parseint.js +0 -31
  88. package/cjs/util/get-parsers.js +0 -41
  89. package/cjs/util/parse-array.js +0 -60
  90. package/cjs/util/parse-datetime.js +0 -37
  91. package/cjs/util/parse-row.js +0 -11
  92. package/cjs/util/parse-time.js +0 -30
  93. package/cjs/util/stringify-arrayliteral.js +0 -37
  94. package/cjs/util/stringify-for-sql.js +0 -29
  95. package/cjs/util/wrap-row-description.js +0 -34
  96. package/esm/package.json +0 -3
  97. package/types/index.d.cts +0 -25
  98. /package/{types/connection → connection}/bind-param.d.ts +0 -0
  99. /package/{types/connection → connection}/connection.d.ts +0 -0
  100. /package/{types/connection → connection}/cursor.d.ts +0 -0
  101. /package/{types/connection → connection}/intl-connection.d.ts +0 -0
  102. /package/{types/connection → connection}/pool.d.ts +0 -0
  103. /package/{types/connection → connection}/portal.d.ts +0 -0
  104. /package/{types/connection → connection}/prepared-statement.d.ts +0 -0
  105. /package/{types/constants.d.ts → constants.d.ts} +0 -0
  106. /package/{types/data-types → data-types}/bool-type.d.ts +0 -0
  107. /package/{esm/data-types → data-types}/bool-type.js +0 -0
  108. /package/{types/data-types → data-types}/box-type.d.ts +0 -0
  109. /package/{esm/data-types → data-types}/box-type.js +0 -0
  110. /package/{types/data-types → data-types}/bytea-type.d.ts +0 -0
  111. /package/{esm/data-types → data-types}/bytea-type.js +0 -0
  112. /package/{types/data-types → data-types}/char-type.d.ts +0 -0
  113. /package/{esm/data-types → data-types}/char-type.js +0 -0
  114. /package/{types/data-types → data-types}/circle-type.d.ts +0 -0
  115. /package/{esm/data-types → data-types}/circle-type.js +0 -0
  116. /package/{types/data-types → data-types}/date-type.d.ts +0 -0
  117. /package/{esm/data-types → data-types}/date-type.js +0 -0
  118. /package/{types/data-types → data-types}/float4-type.d.ts +0 -0
  119. /package/{esm/data-types → data-types}/float4-type.js +0 -0
  120. /package/{types/data-types → data-types}/float8-type.d.ts +0 -0
  121. /package/{esm/data-types → data-types}/float8-type.js +0 -0
  122. /package/{types/data-types → data-types}/int2-type.d.ts +0 -0
  123. /package/{esm/data-types → data-types}/int2-type.js +0 -0
  124. /package/{types/data-types → data-types}/int2-vector-type.d.ts +0 -0
  125. /package/{types/data-types → data-types}/int4-type.d.ts +0 -0
  126. /package/{esm/data-types → data-types}/int4-type.js +0 -0
  127. /package/{types/data-types → data-types}/int8-type.d.ts +0 -0
  128. /package/{esm/data-types → data-types}/int8-type.js +0 -0
  129. /package/{types/data-types → data-types}/json-type.d.ts +0 -0
  130. /package/{esm/data-types → data-types}/json-type.js +0 -0
  131. /package/{types/data-types → data-types}/jsonb-type.d.ts +0 -0
  132. /package/{esm/data-types → data-types}/jsonb-type.js +0 -0
  133. /package/{types/data-types → data-types}/lseg-type.d.ts +0 -0
  134. /package/{esm/data-types → data-types}/lseg-type.js +0 -0
  135. /package/{types/data-types → data-types}/numeric-type.d.ts +0 -0
  136. /package/{esm/data-types → data-types}/numeric-type.js +0 -0
  137. /package/{types/data-types → data-types}/oid-type.d.ts +0 -0
  138. /package/{esm/data-types → data-types}/oid-type.js +0 -0
  139. /package/{types/data-types → data-types}/point-type.d.ts +0 -0
  140. /package/{esm/data-types → data-types}/point-type.js +0 -0
  141. /package/{types/data-types → data-types}/time-type.d.ts +0 -0
  142. /package/{esm/data-types → data-types}/time-type.js +0 -0
  143. /package/{types/data-types → data-types}/timestamp-type.d.ts +0 -0
  144. /package/{esm/data-types → data-types}/timestamp-type.js +0 -0
  145. /package/{types/data-types → data-types}/uuid-type.d.ts +0 -0
  146. /package/{esm/data-types → data-types}/uuid-type.js +0 -0
  147. /package/{types/data-types → data-types}/varchar-type.d.ts +0 -0
  148. /package/{esm/data-types → data-types}/varchar-type.js +0 -0
  149. /package/{types/index.d.ts → index.d.ts} +0 -0
  150. /package/{esm/index.js → index.js} +0 -0
  151. /package/{types/interfaces → interfaces}/command-result.d.ts +0 -0
  152. /package/{esm/interfaces → interfaces}/command-result.js +0 -0
  153. /package/{types/interfaces → interfaces}/data-mapping-options.d.ts +0 -0
  154. /package/{esm/interfaces → interfaces}/data-mapping-options.js +0 -0
  155. /package/{types/interfaces → interfaces}/data-type.d.ts +0 -0
  156. /package/{esm/interfaces → interfaces}/data-type.js +0 -0
  157. /package/{types/interfaces → interfaces}/database-connection-params.d.ts +0 -0
  158. /package/{esm/interfaces → interfaces}/database-connection-params.js +0 -0
  159. /package/{types/interfaces → interfaces}/field-info.d.ts +0 -0
  160. /package/{esm/interfaces → interfaces}/field-info.js +0 -0
  161. /package/{types/interfaces → interfaces}/query-options.d.ts +0 -0
  162. /package/{esm/interfaces → interfaces}/query-options.js +0 -0
  163. /package/{types/interfaces → interfaces}/query-result.d.ts +0 -0
  164. /package/{esm/interfaces → interfaces}/query-result.js +0 -0
  165. /package/{types/interfaces → interfaces}/script-execute-options.d.ts +0 -0
  166. /package/{esm/interfaces → interfaces}/script-execute-options.js +0 -0
  167. /package/{types/interfaces → interfaces}/script-result.d.ts +0 -0
  168. /package/{esm/interfaces → interfaces}/script-result.js +0 -0
  169. /package/{types/interfaces → interfaces}/statement-prepare-options.d.ts +0 -0
  170. /package/{esm/interfaces → interfaces}/statement-prepare-options.js +0 -0
  171. /package/{types/protocol → protocol}/backend.d.ts +0 -0
  172. /package/{types/protocol → protocol}/buffer-reader.d.ts +0 -0
  173. /package/{types/protocol → protocol}/database-error.d.ts +0 -0
  174. /package/{types/protocol → protocol}/frontend.d.ts +0 -0
  175. /package/{types/protocol → protocol}/protocol.d.ts +0 -0
  176. /package/{esm/protocol → protocol}/protocol.js +0 -0
  177. /package/{types/protocol → protocol}/sasl.d.ts +0 -0
  178. /package/{esm/protocol → protocol}/sasl.js +0 -0
  179. /package/{types/protocol → protocol}/smart-buffer.d.ts +0 -0
  180. /package/{types/safe-event-emitter.d.ts → safe-event-emitter.d.ts} +0 -0
  181. /package/{esm/safe-event-emitter.js → safe-event-emitter.js} +0 -0
  182. /package/{types/types.d.ts → types.d.ts} +0 -0
  183. /package/{esm/types.js → types.js} +0 -0
  184. /package/{types/util → util}/array-calculatedim.d.ts +0 -0
  185. /package/{esm/util → util}/array-calculatedim.js +0 -0
  186. /package/{types/util → util}/bigint-methods.d.ts +0 -0
  187. /package/{types/util → util}/config-from-env.d.ts +0 -0
  188. /package/{esm/util → util}/config-from-env.js +0 -0
  189. /package/{types/util → util}/connection-config.d.ts +0 -0
  190. /package/{esm/util → util}/connection-config.js +0 -0
  191. /package/{types/util → util}/convert-row-to-object.d.ts +0 -0
  192. /package/{esm/util → util}/convert-row-to-object.js +0 -0
  193. /package/{types/util → util}/decode-binaryarray.d.ts +0 -0
  194. /package/{esm/util → util}/decode-binaryarray.js +0 -0
  195. /package/{types/util → util}/encode-binaryarray.d.ts +0 -0
  196. /package/{esm/util → util}/encode-binaryarray.js +0 -0
  197. /package/{types/util → util}/escape-literal.d.ts +0 -0
  198. /package/{esm/util → util}/escape-literal.js +0 -0
  199. /package/{types/util → util}/fast-parseint.d.ts +0 -0
  200. /package/{esm/util → util}/fast-parseint.js +0 -0
  201. /package/{types/util → util}/get-parsers.d.ts +0 -0
  202. /package/{esm/util → util}/get-parsers.js +0 -0
  203. /package/{types/util → util}/parse-array.d.ts +0 -0
  204. /package/{esm/util → util}/parse-array.js +0 -0
  205. /package/{types/util → util}/parse-datetime.d.ts +0 -0
  206. /package/{esm/util → util}/parse-datetime.js +0 -0
  207. /package/{types/util → util}/parse-row.d.ts +0 -0
  208. /package/{esm/util → util}/parse-row.js +0 -0
  209. /package/{types/util → util}/parse-time.d.ts +0 -0
  210. /package/{esm/util → util}/parse-time.js +0 -0
  211. /package/{types/util → util}/stringify-arrayliteral.d.ts +0 -0
  212. /package/{esm/util → util}/stringify-arrayliteral.js +0 -0
  213. /package/{types/util → util}/stringify-for-sql.d.ts +0 -0
  214. /package/{esm/util → util}/stringify-for-sql.js +0 -0
  215. /package/{types/util → util}/wrap-row-description.d.ts +0 -0
  216. /package/{esm/util → util}/wrap-row-description.js +0 -0
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fastParseInt = fastParseInt;
4
- function fastParseInt(str) {
5
- /* istanbul ignore next */
6
- if (typeof str === 'number')
7
- return Math.floor(str);
8
- // noinspection SuspiciousTypeOfGuard
9
- if (typeof str !== 'string')
10
- return NaN;
11
- const strLength = str.length;
12
- let res = 0;
13
- let i = 0;
14
- let neg = false;
15
- if (str.startsWith('-')) {
16
- neg = true;
17
- i++;
18
- }
19
- do {
20
- const charCode = str.charCodeAt(i);
21
- /* istanbul ignore next */
22
- if (charCode === 46)
23
- return res;
24
- /* istanbul ignore next */
25
- if (charCode < 48 || charCode > 57)
26
- return NaN;
27
- res *= 10;
28
- res += charCode - 48;
29
- } while (++i < strLength);
30
- return neg ? -res : res;
31
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getParsers = getParsers;
4
- const constants_js_1 = require("../constants.js");
5
- const decode_binaryarray_js_1 = require("./decode-binaryarray.js");
6
- const parse_array_js_1 = require("./parse-array.js");
7
- const DefaultColumnParser = (v) => v;
8
- function getParsers(typeMap, fields) {
9
- const parsers = new Array(fields.length);
10
- const l = fields.length;
11
- let f;
12
- let i;
13
- for (i = 0; i < l; i++) {
14
- f = fields[i];
15
- const dataTypeReg = typeMap.get(f.dataTypeId);
16
- if (dataTypeReg) {
17
- const isArray = !!dataTypeReg.elementsOID;
18
- if (f.format === constants_js_1.DataFormat.binary) {
19
- const decode = dataTypeReg.parseBinary;
20
- if (decode) {
21
- parsers[i] = !isArray
22
- ? decode
23
- : (v, options) => (0, decode_binaryarray_js_1.decodeBinaryArray)(v, decode, options);
24
- }
25
- }
26
- else if (f.format === constants_js_1.DataFormat.text) {
27
- const parse = dataTypeReg.parseText;
28
- if (parse) {
29
- parsers[i] = !isArray
30
- ? parse
31
- : (v, options) => (0, parse_array_js_1.parsePostgresArray)(v, {
32
- transform: x => parse(x, options),
33
- separator: dataTypeReg.arraySeparator,
34
- });
35
- }
36
- }
37
- }
38
- parsers[i] = parsers[i] || DefaultColumnParser;
39
- }
40
- return parsers;
41
- }
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePostgresArray = parsePostgresArray;
4
- function parsePostgresArray(s, opts) {
5
- if (!s)
6
- return;
7
- const sep = (opts?.separator || ',').substring(0, 1);
8
- const transform = opts?.transform;
9
- const len = s.length;
10
- let idx = 0;
11
- const out = [];
12
- const iterate = (arr) => {
13
- let c;
14
- let exactlyValue = false;
15
- let token = '';
16
- let quote = '';
17
- while (idx < len) {
18
- c = s.charAt(idx++);
19
- if (!quote) {
20
- if (!token && c === '{') {
21
- const a = [];
22
- arr.push(a);
23
- iterate(a);
24
- continue;
25
- }
26
- if (c === '}' || c === sep) {
27
- if (token) {
28
- if (token === 'NULL' && !exactlyValue)
29
- arr.push(null);
30
- else
31
- arr.push(transform ? transform(token) : token);
32
- exactlyValue = false;
33
- }
34
- token = '';
35
- if (c === '}')
36
- return;
37
- continue;
38
- }
39
- }
40
- if (c === '\\') {
41
- c = s.charAt(idx++);
42
- token += c;
43
- continue;
44
- }
45
- if (c === '"' || c === "'") {
46
- if (quote && quote === c) {
47
- quote = '';
48
- }
49
- else {
50
- exactlyValue = true;
51
- quote = c;
52
- }
53
- continue;
54
- }
55
- token += c;
56
- }
57
- };
58
- iterate(out);
59
- return out.length ? out[0] : undefined;
60
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseDateTime = parseDateTime;
4
- // noinspection RegExpUnnecessaryNonCapturingGroup
5
- const fast_parseint_js_1 = require("./fast-parseint.js");
6
- // noinspection RegExpUnnecessaryNonCapturingGroup
7
- const TIMESTAMP_PATTERN = /^(\d{4})-?(0[1-9]|1[012])?-?([123]0|[012][1-9]|31)?(?:[T ]?([01][0-9]|2[0-3]):?([0-5][0-9]):?([0-5][0-9])?(?:\.(\d+))?(?:(Z)|(?:([+-])([01]?[0-9]|2[0-3]):?([0-5][0-9])?))?)?$/;
8
- const INFINITY_PATTERN = /^-?infinity$/;
9
- function parseDateTime(str, parseTime, parseTimeZone, utc) {
10
- let m = str.match(TIMESTAMP_PATTERN);
11
- if (!m) {
12
- m = str.match(INFINITY_PATTERN);
13
- if (m)
14
- return Number(str.replace('i', 'I'));
15
- return new Date('invalid');
16
- }
17
- const args = [
18
- 1970, 0, 1, 0, 0, 0, 0,
19
- ];
20
- const l = parseTime ? 7 : 3;
21
- for (let i = 0; i < l; i++) {
22
- const s = m[i + 1];
23
- args[i] = (0, fast_parseint_js_1.fastParseInt)(s) || 0;
24
- }
25
- // Months starts from 0
26
- if (args[1] > 0)
27
- args[1]--;
28
- if (parseTimeZone && parseTime && m[9]) {
29
- const r = m[9] === '-' ? -1 : 1;
30
- args[3] -= ((0, fast_parseint_js_1.fastParseInt)(m[10]) || 0) * r;
31
- args[4] -= ((0, fast_parseint_js_1.fastParseInt)(m[11]) || 0) * r;
32
- return new Date(Date.UTC(...args));
33
- }
34
- if (m[8] || utc)
35
- return new Date(Date.UTC(...args));
36
- return new Date(...args);
37
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseRow = parseRow;
4
- function parseRow(parsers, row, options) {
5
- const l = row.length;
6
- let i;
7
- for (i = 0; i < l; i++) {
8
- row[i] =
9
- row[i] == null ? null : parsers[i].call(undefined, row[i], options);
10
- }
11
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TIME_PATTERN = exports.STRICT_TIME_PATTERN = void 0;
4
- exports.parseTime = parseTime;
5
- const fast_parseint_js_1 = require("./fast-parseint.js");
6
- // noinspection RegExpUnnecessaryNonCapturingGroup
7
- exports.STRICT_TIME_PATTERN = /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(?:\.(\d+))?(?:(Z)|(?:([+-])([01]?[0-9]|2[0-3]):?([0-5][0-9])?))?$/;
8
- // noinspection RegExpUnnecessaryNonCapturingGroup
9
- exports.TIME_PATTERN = /^([01][0-9]|2[0-3]):?([0-5][0-9]):?([0-5][0-9])?(?:\.(\d+))?(?:(Z)|(?:([+-])([01]?[0-9]|2[0-3]):?([0-5][0-9])?))?$/;
10
- function parseTime(str, parseTimeZone, utc) {
11
- const m = str.match(exports.TIME_PATTERN);
12
- if (!m)
13
- return new Date('invalid');
14
- const args = [
15
- 1970, 0, 1, 0, 0, 0, 0,
16
- ];
17
- for (let i = 1; i < 4; i++) {
18
- const s = m[i];
19
- args[i + 2] = (0, fast_parseint_js_1.fastParseInt)(s) || 0;
20
- }
21
- if (parseTimeZone && m[6]) {
22
- const r = m[9] === '-' ? -1 : 1;
23
- args[3] -= ((0, fast_parseint_js_1.fastParseInt)(m[7]) || 0) * r;
24
- args[4] -= ((0, fast_parseint_js_1.fastParseInt)(m[8]) || 0) * r;
25
- return new Date(Date.UTC(...args));
26
- }
27
- if (m[5] || utc)
28
- return new Date(Date.UTC(...args));
29
- return new Date(...args);
30
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringifyArrayLiteral = stringifyArrayLiteral;
4
- const array_calculatedim_js_1 = require("./array-calculatedim.js");
5
- function stringifyArrayLiteral(value, options, encode) {
6
- const dim = (0, array_calculatedim_js_1.arrayCalculateDim)(value);
7
- const writeDim = (arr, level) => {
8
- const elemCount = dim[level];
9
- const out = [];
10
- for (let i = 0; i < elemCount; i++) {
11
- let x = arr && arr[i];
12
- if (level < dim.length - 1) {
13
- if (x != null && !Array.isArray(x))
14
- x = [x];
15
- out.push(writeDim(x, level + 1));
16
- continue;
17
- }
18
- // if value is null
19
- if (x == null) {
20
- out.push('NULL');
21
- continue;
22
- }
23
- if (Array.isArray(x)) {
24
- out.push(stringifyArrayLiteral(x, options, encode));
25
- continue;
26
- }
27
- if (encode)
28
- x = encode(x, options || {});
29
- out.push(escapeArrayItem('' + x));
30
- }
31
- return '{' + out.join(',') + '}';
32
- };
33
- return writeDim(value, 0);
34
- }
35
- function escapeArrayItem(str) {
36
- return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
37
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringifyArrayForSQL = stringifyArrayForSQL;
4
- exports.stringifyValueForSQL = stringifyValueForSQL;
5
- const uuid_type_js_1 = require("../data-types/uuid-type.js");
6
- const escape_literal_js_1 = require("./escape-literal.js");
7
- function stringifyArrayForSQL(v, options, encode) {
8
- const arr = v.map(x => stringifyValueForSQL(x, options, encode));
9
- return 'ARRAY[' + arr.join(',') + ']';
10
- }
11
- function stringifyValueForSQL(v, options, encode) {
12
- if (v == null)
13
- return 'null';
14
- if (typeof v === 'boolean')
15
- return v ? 'true' : 'false';
16
- if (Array.isArray(v))
17
- return stringifyArrayForSQL(v, options, encode);
18
- if (encode)
19
- v = encode(v, options || {});
20
- if (typeof v === 'number')
21
- return '' + v;
22
- if (typeof v === 'bigint')
23
- return v.toString();
24
- if (typeof v === 'string' && uuid_type_js_1.UuidType.isType(v))
25
- return (0, escape_literal_js_1.escapeLiteral)('' + v) + '::uuid';
26
- if (typeof v === 'object')
27
- return (0, escape_literal_js_1.escapeLiteral)(JSON.stringify(v)) + '::json';
28
- return (0, escape_literal_js_1.escapeLiteral)('' + v);
29
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapRowDescription = wrapRowDescription;
4
- const constants_js_1 = require("../constants.js");
5
- function wrapRowDescription(typeMap, fields, columnFormat) {
6
- return fields.map((f, idx) => {
7
- const cf = Array.isArray(columnFormat) ? columnFormat[idx] : columnFormat;
8
- const x = {
9
- fieldName: f.fieldName,
10
- tableId: f.tableId,
11
- columnId: f.columnId,
12
- dataTypeId: f.dataTypeId,
13
- dataTypeName: constants_js_1.DataTypeNames[f.dataTypeId] || '',
14
- jsType: cf === constants_js_1.DataFormat.binary ? 'Buffer' : 'string',
15
- };
16
- x.isArray = x.dataTypeName.startsWith('_');
17
- if (x.isArray) {
18
- x.elementDataTypeName = x.dataTypeName.substring(1);
19
- for (const oid of Object.keys(constants_js_1.DataTypeNames)) {
20
- if (constants_js_1.DataTypeNames[oid] === x.elementDataTypeName)
21
- x.elementDataTypeId = parseInt(oid, 10);
22
- }
23
- }
24
- if (f.fixedSize && f.fixedSize > 0)
25
- x.fixedSize = f.fixedSize;
26
- if (f.modifier && f.modifier > 0)
27
- x.modifier = f.modifier;
28
- const reg = typeMap.get(x.dataTypeId);
29
- if (reg) {
30
- x.jsType = reg.jsType;
31
- }
32
- return x;
33
- });
34
- }
package/esm/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/types/index.d.cts DELETED
@@ -1,25 +0,0 @@
1
- export * from './connection/bind-param.js';
2
- export * from './connection/connection.js';
3
- export * from './connection/cursor.js';
4
- export * from './connection/pool.js';
5
- export * from './connection/prepared-statement.js';
6
- export * from './constants.js';
7
- export * from './data-type-map.js';
8
- export * from './interfaces/command-result.js';
9
- export * from './interfaces/data-mapping-options.js';
10
- export * from './interfaces/data-type.js';
11
- export * from './interfaces/database-connection-params.js';
12
- export * from './interfaces/field-info.js';
13
- export * from './interfaces/query-options.js';
14
- export * from './interfaces/query-result.js';
15
- export * from './interfaces/script-execute-options.js';
16
- export * from './interfaces/script-result.js';
17
- export * from './interfaces/statement-prepare-options.js';
18
- export * from './protocol/database-error.js';
19
- export * from './protocol/smart-buffer.js';
20
- export * from './types.js';
21
- export * from './util/connection-config.js';
22
- export * from './util/escape-literal.js';
23
- export * from './util/parse-datetime.js';
24
- export * from './util/stringify-arrayliteral.js';
25
- export * from './util/stringify-for-sql.js';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes