{"action":"opened","issue":{"url":"https://api.github.com/repos/will/crystal-pg/issues/156","repository_url":"https://api.github.com/repos/will/crystal-pg","labels_url":"https://api.github.com/repos/will/crystal-pg/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/will/crystal-pg/issues/156/comments","events_url":"https://api.github.com/repos/will/crystal-pg/issues/156/events","html_url":"https://github.com/will/crystal-pg/issues/156","id":382639190,"node_id":"MDU6SXNzdWUzODI2MzkxOTA=","number":156,"title":"Support for Array of hash as a result type","user":{"login":"rishavs","id":1210239,"node_id":"MDQ6VXNlcjEyMTAyMzk=","avatar_url":"https://avatars3.githubusercontent.com/u/1210239?v=4","gravatar_id":"","url":"https://api.github.com/users/rishavs","html_url":"https://github.com/rishavs","followers_url":"https://api.github.com/users/rishavs/followers","following_url":"https://api.github.com/users/rishavs/following{/other_user}","gists_url":"https://api.github.com/users/rishavs/gists{/gist_id}","starred_url":"https://api.github.com/users/rishavs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rishavs/subscriptions","organizations_url":"https://api.github.com/users/rishavs/orgs","repos_url":"https://api.github.com/users/rishavs/repos","events_url":"https://api.github.com/users/rishavs/events{/privacy}","received_events_url":"https://api.github.com/users/rishavs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-20T12:22:30Z","updated_at":"2018-11-20T12:22:30Z","closed_at":null,"author_association":"NONE","body":"Hi guys\r\n\r\nI have a query which uses the json_object_agg function and returns an array of hashes. Howeveer, on Crystal side, I am not able to map it with any data structure.\r\nMy query and mapping which I need are;\r\n```\r\npost= DB.query_one? \"SELECT posts.unqid, posts.title, posts.content, posts.user_id, \r\n                      json_object_agg(tags.name, tags.voted) as tagsdata,\r\n                      json_object_agg(comments.unqid, comments.content) as commentsdata\r\n                    FROM posts\r\n                    LEFT JOIN tags\r\n                        ON posts.unqid = tags.post_id\r\n                    LEFT JOIN comments\r\n                        ON posts.unqid = comments.post_id\r\n                    WHERE posts.unqid = '#{post_id}'\r\n                    GROUP BY posts.unqid, posts.title, posts.content, posts.user_id\", \r\n                    as: {unqid: String, title: String, content: String, user_id: String,\r\n                        tagsdata: Array({name: String, voted: String}), \r\n                        commentsdata: Array({unqid: String, content: String})}\r\n```\r\ncurrently if I try to run this, I get;\r\n```\r\nin lib/pg/src/pg/decoders/array_decoder.cr:66: no overload matches 'PG::Decoders.decode_array_element' with types IO+, NamedTuple(name: String, voted: String).class, Array(NamedTuple(dim: Int32, lbound: Int32))\r\nOverloads are:\r\n - PG::Decoders.decode_array_element(io, t : Array(T).class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Bool.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Bool | ::Nil.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Char.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Char | ::Nil.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Int16.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Int16 | ::Nil.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Int32.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Int32 | ::Nil.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : String.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : String | ::Nil.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Int64.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Int64 | ::Nil.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Float32.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Float32 | ::Nil.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Float64.class, dim_info)\r\n - PG::Decoders.decode_array_element(io, t : Float64 | ::Nil.class, dim_info)\r\n\r\n      Array(T).new(size) { decode_array_element(io, T, rest) }\r\n```"}}
{"actor":{"display_login":"rishavs"}}