Fork me on GitHub
#sql
<
2018-08-29
>
dadair17:08:12

Anyone successfully using the combination of postgres, JSON in postgres, and hugSQL?

dadair17:08:29

Having issues with a stored procedure returning a JSON result and getting the result back through HugSQL.

tanzoniteblack17:08:28

@dadair what kind of issues?

tanzoniteblack17:08:39

i.e. can you provide error messages, examples, etc.

valtteri18:08:45

I’m using jsonb in HugSQL with great success. I have these simple definitions to transform clojure maps -> jsonb and jsonb -> maps. https://github.com/lipas-liikuntapaikat/lipas/blob/master/webapp/src/clj/lipas/backend/db/utils.clj#L19-L38 Similar approach should work for json-type.

valtteri18:08:34

Actually that snippet knows already how to read both jsonb and json types

dadair19:08:59

Looks like we were messing something up at a more basic level. We are using an open source schema that requires plv8 and we were calling SET .. prior to a select to activate plv8, and the query was returning the result of the SET, rather than the select. Removing the SET and calling a separate jdbc/execute! first before the hugsql query resolved the issue.

dadair19:08:20

So we thought our json result was being messed up, but it was actually a different issue.