real.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { entityKind } from "../../entity.js";
  2. import { getColumnNameAndConfig } from "../../utils.js";
  3. import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from "./common.js";
  4. class MySqlRealBuilder extends MySqlColumnBuilderWithAutoIncrement {
  5. static [entityKind] = "MySqlRealBuilder";
  6. constructor(name, config) {
  7. super(name, "number", "MySqlReal");
  8. this.config.precision = config?.precision;
  9. this.config.scale = config?.scale;
  10. }
  11. /** @internal */
  12. build(table) {
  13. return new MySqlReal(table, this.config);
  14. }
  15. }
  16. class MySqlReal extends MySqlColumnWithAutoIncrement {
  17. static [entityKind] = "MySqlReal";
  18. precision = this.config.precision;
  19. scale = this.config.scale;
  20. getSQLType() {
  21. if (this.precision !== void 0 && this.scale !== void 0) {
  22. return `real(${this.precision}, ${this.scale})`;
  23. } else if (this.precision === void 0) {
  24. return "real";
  25. } else {
  26. return `real(${this.precision})`;
  27. }
  28. }
  29. }
  30. function real(a, b = {}) {
  31. const { name, config } = getColumnNameAndConfig(a, b);
  32. return new MySqlRealBuilder(name, config);
  33. }
  34. export {
  35. MySqlReal,
  36. MySqlRealBuilder,
  37. real
  38. };
  39. //# sourceMappingURL=real.js.map