Doctrine 查询 postgres json(包含)json_array [英] Doctrine query postgres json (contains) json_array
问题描述
json_array
类型的教义被保存到一个 postgres 数据库 > 9.2 作为 json 数据类型.
The json_array
type of doctrine is saved to a postgres database > 9.2 as json datatype.
Postgres 支持 contains 和许多其他操作json 数据类型.有没有可能使用学说中的功能?
Postgres supports contains and lots of other operations on the json datatype. Is there any possibility to use the functionalities in doctrine?
可能需要自定义 SQLWalker 吗?如所述 这里.还有一个支持 JSONB
的自定义类型会很好.如此处所述.这将提高查询 json 字段时的性能.或者是否有添加 json(b)
功能的自定义库,或者甚至可以使用 DQL
.
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
.
推荐答案
我创建了一个支持 jsonb 的 Symfony2 Bundle.
I created a Symfony2 Bundle that supports jsonb.
希望这会有所帮助.
https://github.com/boldtrn/JsonbBundle
现在我更喜欢使用 NativQueries 而不是自定义 DQL 函数来查询我的 jsonb 字段.自定义函数在我的应用中太麻烦了.
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.
这篇关于Doctrine 查询 postgres json(包含)json_array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!