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

Merged
merged 3 commits into from
Oct 22, 2024

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 <[email protected]>
@ShireenMissi ShireenMissi added the tests-needed This PR needs additional tests label Oct 21, 2024
Copy link
Contributor

@ShireenMissi ShireenMissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

Copy link

cypress bot commented Oct 21, 2024

n8n    Run #7477

Run Properties:  status check passed Passed #7477  •  git commit 0ccff01df8: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 riascho 🗃️ e2e/*
Project n8n
Branch Review node-1245-postgres-special-datetime-values-cause-errors
Run status status check passed Passed #7477
Run duration 04m 22s
Commit git commit 0ccff01df8: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 riascho 🗃️ e2e/*
Committer Elias Meire
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 458
View all changes introduced in this branch ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

@elsmr elsmr merged commit 3c57f46 into master Oct 22, 2024
33 checks passed
@elsmr elsmr deleted the node-1245-postgres-special-datetime-values-cause-errors branch October 22, 2024 10:02
@github-actions github-actions bot mentioned this pull request Oct 24, 2024
@janober
Copy link
Member

janober commented Oct 24, 2024

Got released with [email protected]

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 Released tests-needed This PR needs additional tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants