char.js 964 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { entityKind } from "../../entity.js";
  2. import { getColumnNameAndConfig } from "../../utils.js";
  3. import { MySqlColumn, MySqlColumnBuilder } from "./common.js";
  4. class MySqlCharBuilder extends MySqlColumnBuilder {
  5. static [entityKind] = "MySqlCharBuilder";
  6. constructor(name, config) {
  7. super(name, "string", "MySqlChar");
  8. this.config.length = config.length;
  9. this.config.enum = config.enum;
  10. }
  11. /** @internal */
  12. build(table) {
  13. return new MySqlChar(
  14. table,
  15. this.config
  16. );
  17. }
  18. }
  19. class MySqlChar extends MySqlColumn {
  20. static [entityKind] = "MySqlChar";
  21. length = this.config.length;
  22. enumValues = this.config.enum;
  23. getSQLType() {
  24. return this.length === void 0 ? `char` : `char(${this.length})`;
  25. }
  26. }
  27. function char(a, b = {}) {
  28. const { name, config } = getColumnNameAndConfig(a, b);
  29. return new MySqlCharBuilder(name, config);
  30. }
  31. export {
  32. MySqlChar,
  33. MySqlCharBuilder,
  34. char
  35. };
  36. //# sourceMappingURL=char.js.map