Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Postgres Node): Special datetime values cause errors #11225

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

riascho
Copy link
Contributor

@riascho riascho commented Oct 11, 2024

Summary

The Postgres Node uses the pg module to parse the postgres query response. However, this would fail for some special datetime values in postgres, e.g. infinity, and throw an error "Invalid time value".

This PR adds a check to catch these and return them unparsed.

Since the modified parse function is only for TIMESTAMP or TIMESTAMPTZ values, the only other possible edge case would be null, which is returned correctly. The test table covers that.

To Test:

  1. Set up Postgres Test Table:
CREATE TABLE IF NOT EXISTS special_dates
(
   ts timestamp with time zone DEFAULT now()
);

INSERT INTO special_dates (ts)
VALUES
    ('infinity'::timestamptz),
    ('-infinity'::timestamptz),
    ('epoch'::timestamptz),
    ('now'::timestamptz),
    ('today'::timestamptz),
    ('tomorrow'::timestamptz),
    ('yesterday'::timestamptz)
    (NULL);
  1. Run the Postgres - Execute Query Node with this query:
SELECT * FROM special_dates;
  1. All rows should be output and no error.

image

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team node/improvement New feature or request labels Oct 11, 2024
include valid date check

Co-authored-by: Elias Meire <elias@meire.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team node/improvement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants