real.js 831 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { entityKind } from "../../entity.js";
  2. import { PgColumn, PgColumnBuilder } from "./common.js";
  3. class PgRealBuilder extends PgColumnBuilder {
  4. static [entityKind] = "PgRealBuilder";
  5. constructor(name, length) {
  6. super(name, "number", "PgReal");
  7. this.config.length = length;
  8. }
  9. /** @internal */
  10. build(table) {
  11. return new PgReal(table, this.config);
  12. }
  13. }
  14. class PgReal extends PgColumn {
  15. static [entityKind] = "PgReal";
  16. constructor(table, config) {
  17. super(table, config);
  18. }
  19. getSQLType() {
  20. return "real";
  21. }
  22. mapFromDriverValue = (value) => {
  23. if (typeof value === "string") {
  24. return Number.parseFloat(value);
  25. }
  26. return value;
  27. };
  28. }
  29. function real(name) {
  30. return new PgRealBuilder(name ?? "");
  31. }
  32. export {
  33. PgReal,
  34. PgRealBuilder,
  35. real
  36. };
  37. //# sourceMappingURL=real.js.map