Skip to content

Prepare for merger with node-postgres #162

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

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

Conversation

aqeelat
Copy link

@aqeelat aqeelat commented Apr 10, 2025

No description provided.

@brianc
Copy link
Owner

brianc commented Apr 10, 2025

Hey @aqeelat - curious what the changes here do exactly? Thanks for doing them! Would you be able to provide a bit more description/context around what they are? Thank you again!

@brianc
Copy link
Owner

brianc commented Apr 10, 2025

also - the tests are failing 😱

@aqeelat
Copy link
Author

aqeelat commented Apr 11, 2025

@brianc the tests were passing locally. I added a commit to specify the timezone.

Copy link
Author

@aqeelat aqeelat left a comment

Choose a reason for hiding this comment

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

This PR reverses #121, #119, and #129 which is when we started diverting from node-postgres

Comment on lines -34 to -35
if (!Number.isInteger(oid)) {
throw new TypeError('oid must be an integer: ' + oid)
Copy link
Author

Choose a reason for hiding this comment

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

Comment on lines +24 to +40
const result = new Date((rawValue / 1000) + 946684800000)

if (!isUTC) {
result.setTime(result.getTime() + result.getTimezoneOffset() * 60000)
}

// add microseconds to the date
result.usec = rawValue % 1000
result.getMicroSeconds = function () {
return this.usec
}
result.setMicroSeconds = function (value) {
this.usec = value
}
result.getUTCMicroSeconds = function () {
return this.usec
}
Copy link
Author

Choose a reason for hiding this comment

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

@@ -143,8 +127,9 @@ const init = function (register) {
register(700, parseFloat) // float4/real
register(701, parseFloat) // float8/double
register(16, parseBool)
register(1082, parseTimestamp) // date
Copy link
Author

Choose a reason for hiding this comment

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

This change makes it so that we return a date object instead of a string

@@ -165,8 +150,8 @@ const init = function (register) {
register(1040, parseStringArray) // macaddr[]
register(1041, parseStringArray) // inet[]
register(1115, parseTimestampArray) // timestamp without time zone[]
register(1182, parseStringArray) // date[]
register(1185, parseTimestampTzArray) // timestamp with time zone[]
register(1182, parseTimestampArray) // date[]
Copy link
Author

Choose a reason for hiding this comment

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

This is related to 1082. We need to use a date parser instead of a string parser.

Comment on lines -43 to -49
const parseTimestamp = function (value) {
const utc = value.endsWith(' BC')
? value.slice(0, -3) + 'Z BC'
: value + 'Z'

return parseTimestampTz(utc)
}
Copy link
Author

Choose a reason for hiding this comment

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

this function was very problematic because it appends Z to the end of the timestamp, which breaks all tz related tests. It should be brought back later though.

Because this function was removed, I removed all of the range functions related to it.

Comment on lines -112 to -115
],
[
'1000-01-01 00:00:00+00 BC',
dateEquals(-999, 0, 1, 0, 0, 0, 0)
Copy link
Author

Choose a reason for hiding this comment

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

This was added to validated converting the datetime string to "Z BC" and is no longer needed.

Comment on lines -128 to +125
value.toISOString(),
'2010-10-31T00:00:00.000Z'
)
}
],
[
'1000-01-01 00:00:00 BC',
function (t, value) {
t.equal(
value.toISOString(),
'-000999-01-01T00:00:00.000Z'
value.toUTCString(),
new Date(2010, 9, 31, 0, 0, 0, 0).toUTCString()
Copy link
Author

Choose a reason for hiding this comment

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

This was added to validated converting the datetime string to "Z BC" and is no longer needed. I reverted it to how it was before the change

Comment on lines +136 to +144
['2010-10-31', function (t, value) {
const now = new Date(2010, 9, 31)
dateEquals(
2010,
now.getUTCMonth(),
now.getUTCDate(),
now.getUTCHours(), 0, 0, 0)(t, value)
t.equal(value.getHours(), now.getHours())
}]
Copy link
Author

Choose a reason for hiding this comment

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

This was added to validated converting the datetime string to "Z BC" and is no longer needed.

Comment on lines +319 to +328
['(2010-10-31 14:54:13.74,)', tsrangeEquals([[2010, 9, 31, 11, 54, 13, 74], null])],
['(2010-10-31 14:54:13.74,infinity)', tsrangeEquals([[2010, 9, 31, 11, 54, 13, 74], null])],
['(,2010-10-31 14:54:13.74)', tsrangeEquals([null, [2010, 9, 31, 11, 54, 13, 74]])],
['(-infinity,2010-10-31 14:54:13.74)', tsrangeEquals([null, [2010, 9, 31, 11, 54, 13, 74]])],
['(2010-10-30 10:54:13.74,2010-10-31 14:54:13.74)', tsrangeEquals([[2010, 9, 30, 7, 54, 13, 74], [2010, 9, 31, 11, 54, 13, 74]])],
['("2010-10-31 14:54:13.74",)', tsrangeEquals([[2010, 9, 31, 11, 54, 13, 74], null])],
['("2010-10-31 14:54:13.74",infinity)', tsrangeEquals([[2010, 9, 31, 11, 54, 13, 74], null])],
['(,"2010-10-31 14:54:13.74")', tsrangeEquals([null, [2010, 9, 31, 11, 54, 13, 74]])],
['(-infinity,"2010-10-31 14:54:13.74")', tsrangeEquals([null, [2010, 9, 31, 11, 54, 13, 74]])],
['("2010-10-30 10:54:13.74","2010-10-31 14:54:13.74")', tsrangeEquals([[2010, 9, 30, 7, 54, 13, 74], [2010, 9, 31, 11, 54, 13, 74]])]
Copy link
Author

Choose a reason for hiding this comment

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

These were failing because of the tz mismatch between my machine and the runner. They should work now.

Also, there's a potential to use Date() objects here but I'm not familiar with the test harness to create fixtures.

@aqeelat
Copy link
Author

aqeelat commented Apr 11, 2025

@brianc I hope my comments explain the changes I made.

I also dropped the commit that updates package.json because I didn't want to jump the gun. There might be other changes that we could do such as aligning the node engine version, updating the dependencies, and perhaps adopting typescript.

@aqeelat
Copy link
Author

aqeelat commented Apr 18, 2025

@brianc were able to look at the comments?

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.

2 participants