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

setTypeParser within json_agg #60

Closed
nickell opened this issue Mar 21, 2017 · 3 comments
Closed

setTypeParser within json_agg #60

nickell opened this issue Mar 21, 2017 · 3 comments

Comments

@nickell
Copy link

nickell commented Mar 21, 2017

Hi, I'm using the example provided to do this:

pg.types.setTypeParser(3912, parseDaterange)

However, when I've grouped documents using json_agg it doesn't seem to run those type parsers. This makes sense to me because I'm sure it's formatted as JSON by Postgres before the type parser ever sees it. I'm just curious if there's a recommended approach to parsing data types inside something like this?

@leothelocust
Copy link

I'm having the same issue/question.

@Kyrluckechuck
Copy link

Can attest I am having these problems too -- Any solution/workaround found?

@nickell
Copy link
Author

nickell commented May 14, 2018

Hey @Kyrluckechuck there is no workaround that I'm aware of relevant to this package so I decided to handle it with a couple postgres functions. My use-case is for camelizing json object keys and I've created a gist to share the functions with you here.

So now I can write my queries like this:

select camelize_keys(json_field) from table

or

select camelize_array(json_array_of_objects) from table

I think it makes sense to handle this sort of thing natively inside postgres. Hope that helps!

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

No branches or pull requests

4 participants