porsager / porsager/postgres

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

Open
#728 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source files or tests. Start by reproducing the provided PostgreSQL table and query in Postgres.js, then trace how timestamp values are converted; done means infinity no longer becomes an Invalid Date while ordinary timestamp conversion still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgres
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.