numeric.cjs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 numeric_exports = {};
  20. __export(numeric_exports, {
  21. SQLiteNumeric: () => SQLiteNumeric,
  22. SQLiteNumericBigInt: () => SQLiteNumericBigInt,
  23. SQLiteNumericBigIntBuilder: () => SQLiteNumericBigIntBuilder,
  24. SQLiteNumericBuilder: () => SQLiteNumericBuilder,
  25. SQLiteNumericNumber: () => SQLiteNumericNumber,
  26. SQLiteNumericNumberBuilder: () => SQLiteNumericNumberBuilder,
  27. numeric: () => numeric
  28. });
  29. module.exports = __toCommonJS(numeric_exports);
  30. var import_entity = require("../../entity.cjs");
  31. var import_utils = require("../../utils.cjs");
  32. var import_common = require("./common.cjs");
  33. class SQLiteNumericBuilder extends import_common.SQLiteColumnBuilder {
  34. static [import_entity.entityKind] = "SQLiteNumericBuilder";
  35. constructor(name) {
  36. super(name, "string", "SQLiteNumeric");
  37. }
  38. /** @internal */
  39. build(table) {
  40. return new SQLiteNumeric(
  41. table,
  42. this.config
  43. );
  44. }
  45. }
  46. class SQLiteNumeric extends import_common.SQLiteColumn {
  47. static [import_entity.entityKind] = "SQLiteNumeric";
  48. mapFromDriverValue(value) {
  49. if (typeof value === "string") return value;
  50. return String(value);
  51. }
  52. getSQLType() {
  53. return "numeric";
  54. }
  55. }
  56. class SQLiteNumericNumberBuilder extends import_common.SQLiteColumnBuilder {
  57. static [import_entity.entityKind] = "SQLiteNumericNumberBuilder";
  58. constructor(name) {
  59. super(name, "number", "SQLiteNumericNumber");
  60. }
  61. /** @internal */
  62. build(table) {
  63. return new SQLiteNumericNumber(
  64. table,
  65. this.config
  66. );
  67. }
  68. }
  69. class SQLiteNumericNumber extends import_common.SQLiteColumn {
  70. static [import_entity.entityKind] = "SQLiteNumericNumber";
  71. mapFromDriverValue(value) {
  72. if (typeof value === "number") return value;
  73. return Number(value);
  74. }
  75. mapToDriverValue = String;
  76. getSQLType() {
  77. return "numeric";
  78. }
  79. }
  80. class SQLiteNumericBigIntBuilder extends import_common.SQLiteColumnBuilder {
  81. static [import_entity.entityKind] = "SQLiteNumericBigIntBuilder";
  82. constructor(name) {
  83. super(name, "bigint", "SQLiteNumericBigInt");
  84. }
  85. /** @internal */
  86. build(table) {
  87. return new SQLiteNumericBigInt(
  88. table,
  89. this.config
  90. );
  91. }
  92. }
  93. class SQLiteNumericBigInt extends import_common.SQLiteColumn {
  94. static [import_entity.entityKind] = "SQLiteNumericBigInt";
  95. mapFromDriverValue = BigInt;
  96. mapToDriverValue = String;
  97. getSQLType() {
  98. return "numeric";
  99. }
  100. }
  101. function numeric(a, b) {
  102. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  103. const mode = config?.mode;
  104. return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
  105. }
  106. // Annotate the CommonJS export names for ESM import in node:
  107. 0 && (module.exports = {
  108. SQLiteNumeric,
  109. SQLiteNumericBigInt,
  110. SQLiteNumericBigIntBuilder,
  111. SQLiteNumericBuilder,
  112. SQLiteNumericNumber,
  113. SQLiteNumericNumberBuilder,
  114. numeric
  115. });
  116. //# sourceMappingURL=numeric.cjs.map