varchar.cjs 2.1 KB

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