double-precision.js 885 B

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