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
Better support for non-primitive types #94
Comments
I am testing this lib out and am having the same issue with timestamp fields. It appears that this should be working already - it's the goal of the typeParsers, right? |
@ivan-kleshnin ok, I got it... I misread what the the default typeParsers do, which is the opposite of what I (and I think you) want. You can remove the timestamp(tz) typeParsers when creating the pool so that you get Dates back instead. here I've removed all default slonik parsers and added the transformer for column names
|
@camflan thanks man! I confirm that Btw. I have all my PG fields in camel case – I find it more bullet-proof with custom (think GraphQL) data filters like |
With regards to Date, I will open a separate issue. Beyond the mentioned |
What I find odd about this (overall great) library is that, while it's built on top of
PG
, it sometimes feels even more low-level.For example, when you read a
timestamp
field, PG returns aDate
object while Slonik returns anumber
:The same happens when you write a
Date
object. PG accepts it and Slonik doesn't.The same happens with JSON objects and arrays, though I remember your concerns about them.
undefined
values are problematic (see below).All that requires to immediately wrap Slonik in an additional layer of data transformations. Preferences may vary, but I personally don't like to import a bunch of helpers for even the simplest maintenance scripts when I've just installed a specialized library.
Probably a topic for another issue but...
undefined
values resulting inUnexpected value expression
are very hard to debug.Multiple times already I had to comment out SQL lines and model fields gradually, one by one, to discover where the problem really is. You can say "use TS", but that's not always possible.
In one case I ended up with a loop which replaced allundefined
s withnull
s because the first gave me obscure parsing errors from Slonik while the latter gave me clear runtime errors from Postgres. Didn't have such problems with PG whereundefined
andnull
are simply treated in the same way.moved to #95
The text was updated successfully, but these errors were encountered: