postgres查询序列化的yaml字段

时间:2014-03-19 10:25:14

标签: postgresql psql

我在数据库中有一个字段,可以(遗憾地)序列化到Yaml中。

下面是表格中的字段定义:

  class Account < Sequel::Model
    include ModelManager

    plugin :serialization

    serialize_attributes :yaml, :billing_info

我真的想将它转换为新的json类型,但我们仍然在postgres 9.2.6。

无论如何,我可以查询这些数据,直到我可以迁移它为止?

该字段包含如下的空定义:

--- !ruby/object:BillingInfo {}

或者有这样的数据:

--- !ruby/object:BillingInfo
gateway_identifier: blah 
organisation: blah
billing_email: blah
reference: blah
phone: blah
country: blah
vat: blah
subscription: blah

1 个答案:

答案 0 :(得分:0)

如果您的意思是在PostgreSQL级别进行查询,则必须使用plv8和js-yaml之类的内容添加自己的yaml解析器,如下所述:

Store and index YAML with PostgreSQL, with Javascript lib or reusable functions?