porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.09k stars 259 forks source link

infinity value in Postgres timestamp column returns as 'Invalid Date' #728

Open hanszoons opened 8 months ago

hanszoons commented 8 months ago

I have a table with a column dat has a date field with a default value of infinity.

CREATE TABLE test (
  id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
  expires timestamp with time zone DEFAULT 'infinity' NOT NULL,
  PRIMARY KEY (id),
);

This works fine within postgres and within query logic, e.g. ... WHERE end_date is > now() to select all rows that are not yet expired. But Postgres.js converts the infinity values to a Date, resulting in an 'Invalid Date' object in javascript.

Shouldn't this be converted to JavaScripts'Infinity? Should i make a custom type (but I need to replicate the existing date conversion somehow too)? How would I approach this?

BeeFox-sys commented 5 months ago

I am also having this issue