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

Proposed solution to issue #50 #53

Closed
wants to merge 1 commit into from
Closed

Conversation

tomaspinho
Copy link

Timestamps are now parsed differently from YYYY-MM-DD date strings. Value is returned unchanged.

Please see #50

@brianc
Copy link
Owner

brianc commented Dec 11, 2016

This looks good to me & looks like a good call! Ultimately @bendrucker is the final say on this repo, but if y'all merge this please open a PR on node-postgres to bump the major-version of node-postgres up a notch as well. That'll serve as a perm reminder I need to get my ducks in a row for what all breaking changes I want in the next version of node-postgres.

This is a pretty world-shattering breaking change if you're not expecting it and rely on existing behavior, so we'll be careful to advertise it and provide an example in the release notes on how you could revert to old behavior if you wanted. We're probably going to drop support for versions of node < 4.0 too so it'll be good to combo this with that as a single new major version.

@brianc
Copy link
Owner

brianc commented Dec 11, 2016

also: apologies for being like 200 years late with my feedback, been kinda crushed w/ life responsibilities these days.

@bendrucker
Copy link
Collaborator

Same goes for me. I'm transitioning into dev ops work and can justify budgeting more open source time for node-postgres. I'd like to keep this PR open until that breaking node-postgres release is ready.

@brianc
Copy link
Owner

brianc commented Dec 11, 2016

okay Rad - just settling down one final discussion & should know soon! Thanks so much for everything you've done here @bendrucker! ❤️

@tomaspinho
Copy link
Author

@brianc that's ok, life happens!
I think it's a good call to treat this breaking change as you mentioned. Keep up the good work :)

Copy link
Contributor

@chamini2 chamini2 left a comment

Choose a reason for hiding this comment

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

Hello!

A bit of an outsider, but decided to check out the code. Made the comments I considered valuable. Since dates are to be left as is, remove them all together from the textParsers.

Removing the parseDateArray (using parseStringArray in it's place) and parseDate functions, since they are no longer needed.

var parseDate = function(value) {
return value;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this function.

@@ -162,9 +179,9 @@ var init = function(register) {
register(1015, parseStringArray); //varchar
register(1008, parseStringArray);
register(1009, parseStringArray);
register(1115, parseDateArray); // timestamp without time zone[]
register(1115, parseTimestampArray); // timestamp without time zone[]
register(1182, parseDateArray); // _date
Copy link
Contributor

Choose a reason for hiding this comment

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

change to parseStringArray

@@ -145,8 +162,8 @@ var init = function(register) {
register(701, parseFloat); // float8/double
register(16, parseBool);
register(1082, parseDate); // date
Copy link
Contributor

Choose a reason for hiding this comment

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

remove 1082

@tomaspinho
Copy link
Author

tomaspinho commented Mar 11, 2017

@chamini2 that's a neat way to save a function call 👍

@glococo
Copy link

glococo commented Jul 5, 2017

Hi,
Am I in the same boat?
I'm migrating a php/pg backend to node/pg and found this bug.
A "date" row returned a "timedate with timezone" value. (minus a day)

// query: "SELECT current_date as TODAY"
// expected: [{"today":"2017-07-05"}]
// returned: [{"today":"2017-07-04T23:00:00.000Z"}]

Is this bug already solved? Should I query in a different way ? Am I doing something wrong ?

Thanks in advance
[pg:6.4.0, pg-types: 1.12.0 ]
Update: process.env.TZ = 'Europe/GMT'; // set same timezone & solve date diff

@mknapik
Copy link

mknapik commented Feb 1, 2018

Are maintainers still interested in merging this fix?

@chamini2
Copy link
Contributor

chamini2 commented Feb 1, 2018

// query: "SELECT current_date as TODAY"
// expected: [{"today":"2017-07-05"}]
// returned: [{"today":"2017-07-04T23:00:00.000Z"}]

@glococo, this is becuase the machine you are running this in has a time zone of -01:00, new Date('2017-07-05') adds a time with time zone T00:00:00.000-01:00 which is converted to UTC in Date .toString: 2017-07-04T23:00:00.000Z

@billinghamj
Copy link

Maybe 2020 is the year this could be fixed? 😉

@tomaspinho
Copy link
Author

Or the year to consider porting your codebases to a language with a better type system 😄

Jokes aside, if the maintainer needs any help with this, I'd be willing to lend a hand.

@bendrucker
Copy link
Collaborator

There are two type parsing behaviors with sharp edges:

  • PG date as JS Date
  • PG int8 as String

With Node 10 in maintenance LTS now seems like a good time to do the latter. No reason to hold this up other than forgetting about it.

If you can fix the conflict, happy to merge and release both of the above changes in a new major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants