double.cjs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 double_exports = {};
  20. __export(double_exports, {
  21. MySqlDouble: () => MySqlDouble,
  22. MySqlDoubleBuilder: () => MySqlDoubleBuilder,
  23. double: () => double
  24. });
  25. module.exports = __toCommonJS(double_exports);
  26. var import_entity = require("../../entity.cjs");
  27. var import_utils = require("../../utils.cjs");
  28. var import_common = require("./common.cjs");
  29. class MySqlDoubleBuilder extends import_common.MySqlColumnBuilderWithAutoIncrement {
  30. static [import_entity.entityKind] = "MySqlDoubleBuilder";
  31. constructor(name, config) {
  32. super(name, "number", "MySqlDouble");
  33. this.config.precision = config?.precision;
  34. this.config.scale = config?.scale;
  35. this.config.unsigned = config?.unsigned;
  36. }
  37. /** @internal */
  38. build(table) {
  39. return new MySqlDouble(table, this.config);
  40. }
  41. }
  42. class MySqlDouble extends import_common.MySqlColumnWithAutoIncrement {
  43. static [import_entity.entityKind] = "MySqlDouble";
  44. precision = this.config.precision;
  45. scale = this.config.scale;
  46. unsigned = this.config.unsigned;
  47. getSQLType() {
  48. let type = "";
  49. if (this.precision !== void 0 && this.scale !== void 0) {
  50. type += `double(${this.precision},${this.scale})`;
  51. } else if (this.precision === void 0) {
  52. type += "double";
  53. } else {
  54. type += `double(${this.precision})`;
  55. }
  56. return this.unsigned ? `${type} unsigned` : type;
  57. }
  58. }
  59. function double(a, b) {
  60. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  61. return new MySqlDoubleBuilder(name, config);
  62. }
  63. // Annotate the CommonJS export names for ESM import in node:
  64. 0 && (module.exports = {
  65. MySqlDouble,
  66. MySqlDoubleBuilder,
  67. double
  68. });
  69. //# sourceMappingURL=double.cjs.map