EnterpriseDB / mongo_fdw

PostgreSQL foreign data wrapper for MongoDB
GNU Lesser General Public License v3.0
326 stars 70 forks source link

Server Crash while accessing nested field through mongo_fdw #36

Closed ibrarahmad closed 9 years ago

ibrarahmad commented 9 years ago

Pushed a fix. Here is the working example

{ "_id" : ObjectId("55dc6a1f097aef7fcf1b900a"), "name" : { "first" : "John", "last" : "Doe" }, "gender" : "MALE", "addresses" : [ { "city" : "Copenhagen", "country" : "Denmark" }, { "city" : "Stockholm", "country" : "Sweden" } ] }

postgres=# \d tt Foreign table "public.tt" Column | Type | Modifiers | FDW Options -----------+------+-----------+------------- _id | name | | name | json | | gender | text | | addresses | json | | Server: mongo_svr FDW Options: (database 'testdb')

postgres=# select json_each(addresses->0) from tt;

json_each

(city,"""Copenhagen""") (country,"""Denmark""") (2 rows)

postgres=# select json_each(addresses->1) from tt;

json_each

(city,"""Stockholm""") (country,"""Sweden""") (2 rows)

postgres=# select json_each(name) from tt;

json_each

(first,"""John""") (last,"""Doe""") (2 rows)