Closed JesseVelden closed 2 years ago
@JesseVelden Thanks for trying this out. This library is pretty much agnostic of the data type of the range and, as you correctly pointed out, relies on the transform
function to return the correct type. So I believe this has to do with the way it is used in pg-types. I will investigate later today and let you know.
Actually, after some investigation, I believe this library needs to parse quoted values as well. I will try to update the algorithm to mirror postgres' behavior.
@JesseVelden This should now be fixed here. Going to send a patch to pg-types
to use the new updated version. In the meantime, you can give it a try yourself and let me know if you see any problems. Thanks again for reporting this!
PR created here: https://github.com/brianc/node-pg-types/pull/134
Nice! It seems that parsing works with quotes. However, now the -infinity
value is not recognized. I think a simple value.endsWith('infinity')
should work for this, as you had earlier.
Oh thanks for pointing that out! Will push a fix shortly.
This should be fixed now.
I was trying out the latest pg-types version based on the latest Github commit, to try out your range-types, but I found that my
tstzrange
result text from the database is as follows:["2021-12-31 10:19:24.036+01","2022-01-01 10:19:24.035+01"]
and so the lowerStr and upperStr used here: https://github.com/martianboy/postgres-range/blob/895a57703420104634a1f220359b5e57e1b1a482/index.js#L116 contains double quotes like this:"2021-12-31 10:19:24.036+01"
so parsing failes and returns null. I've debugged this on that point and tried to remove the double quotes by:transform(lowerStr.slice(1,-1))
and that worked.