smallint.cjs 2.2 KB

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