Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine query postgres json (contains) json_array

The json_array type of doctrine is saved to a postgres database > 9.2 as json datatype.

Postgres supports contains and lots of other operations on the json datatype. Is there any possibility to use the functionalities in doctrine?

Probably a custom SQLWalker is needed for that? As described here. Also a custom type supporting JSONB would be nice. As described here. This would increase the performance when querying for the json field. Or is there a custom lib that adds the json(b) functionality or is it even possibile using DQL.

like image 213
Robin Avatar asked Apr 09 '15 13:04

Robin


1 Answers

I created a Symfony2 Bundle that supports jsonb.

Hope this helps.

https://github.com/boldtrn/JsonbBundle

Right now I prefer to use NativQueries instead of custom DQL functions to query for my jsonb fields. The custom functions are too cumbersome in my application.

Everything should be documented in the Bundle as well.

like image 173
Robin Avatar answered Oct 04 '22 08:10

Robin