bigint.cjs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var bigint_exports = {};
  20. __export(bigint_exports, {
  21. MySqlBigInt53: () => MySqlBigInt53,
  22. MySqlBigInt53Builder: () => MySqlBigInt53Builder,
  23. MySqlBigInt64: () => MySqlBigInt64,
  24. MySqlBigInt64Builder: () => MySqlBigInt64Builder,
  25. bigint: () => bigint
  26. });
  27. module.exports = __toCommonJS(bigint_exports);
  28. var import_entity = require("../../entity.cjs");
  29. var import_utils = require("../../utils.cjs");
  30. var import_common = require("./common.cjs");
  31. class MySqlBigInt53Builder extends import_common.MySqlColumnBuilderWithAutoIncrement {
  32. static [import_entity.entityKind] = "MySqlBigInt53Builder";
  33. constructor(name, unsigned = false) {
  34. super(name, "number", "MySqlBigInt53");
  35. this.config.unsigned = unsigned;
  36. }
  37. /** @internal */
  38. build(table) {
  39. return new MySqlBigInt53(
  40. table,
  41. this.config
  42. );
  43. }
  44. }
  45. class MySqlBigInt53 extends import_common.MySqlColumnWithAutoIncrement {
  46. static [import_entity.entityKind] = "MySqlBigInt53";
  47. getSQLType() {
  48. return `bigint${this.config.unsigned ? " unsigned" : ""}`;
  49. }
  50. mapFromDriverValue(value) {
  51. if (typeof value === "number") {
  52. return value;
  53. }
  54. return Number(value);
  55. }
  56. }
  57. class MySqlBigInt64Builder extends import_common.MySqlColumnBuilderWithAutoIncrement {
  58. static [import_entity.entityKind] = "MySqlBigInt64Builder";
  59. constructor(name, unsigned = false) {
  60. super(name, "bigint", "MySqlBigInt64");
  61. this.config.unsigned = unsigned;
  62. }
  63. /** @internal */
  64. build(table) {
  65. return new MySqlBigInt64(
  66. table,
  67. this.config
  68. );
  69. }
  70. }
  71. class MySqlBigInt64 extends import_common.MySqlColumnWithAutoIncrement {
  72. static [import_entity.entityKind] = "MySqlBigInt64";
  73. getSQLType() {
  74. return `bigint${this.config.unsigned ? " unsigned" : ""}`;
  75. }
  76. // eslint-disable-next-line unicorn/prefer-native-coercion-functions
  77. mapFromDriverValue(value) {
  78. return BigInt(value);
  79. }
  80. }
  81. function bigint(a, b) {
  82. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  83. if (config.mode === "number") {
  84. return new MySqlBigInt53Builder(name, config.unsigned);
  85. }
  86. return new MySqlBigInt64Builder(name, config.unsigned);
  87. }
  88. // Annotate the CommonJS export names for ESM import in node:
  89. 0 && (module.exports = {
  90. MySqlBigInt53,
  91. MySqlBigInt53Builder,
  92. MySqlBigInt64,
  93. MySqlBigInt64Builder,
  94. bigint
  95. });
  96. //# sourceMappingURL=bigint.cjs.map