1

我正在使用 PostgreSQL 9.4 数据库。在我的bo_lesson表中,我有一个类型的metadata字段jsonb

    Column     |              Type              |            Modifiers            |
---------------+--------------------------------+---------------------------------|
 id            | integer                        | not null                        |
 level         | integer                        |                                 |
 slug          | text                           | not null                        |
 description   | text                           |                                 |
 external_link | character varying(255)         | default NULL::character varying |
 metadata      | jsonb                          |                                 |
 name          | character varying(255)         | not null                        |
 created_at    | timestamp(0) without time zone | not null                        |
 updated_at    | timestamp(0) without time zone | not null                        |
 status        | character varying(45)          | not null                        |

但是当我执行这个查询

INSERT INTO bo_lesson (id, level, slug, description, external_link, metadata, name,
                       created_at, updated_at, status)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)

parameters: $1 = '4', $2 = '1', $3 = 'education-3', $4 = NULL, $5 = NULL, 
            $6 = '"what ever [ i need }} \""', $7 = 'education', 
            $8 = '2015-07-30 14:33:01', $9 = '2015-07-30 14:33:01', $10 = 'draft'

该行已正确插入。

 id | level |    slug     | description | external_link |             metadata       |   name    |     created_at      |     updated_at      | status 
----+-------+-------------+-------------+---------------+----------------------------+-----------+---------------------+---------------------+--------
  4 |     1 | education-3 |             |               | "what ever [ i need }} \"" | education | 2015-07-30 14:33:01 | 2015-07-30 14:33:01 | draft

jsonb字段尚未对插入的内容进行任何验证。我读过它应该这样做。我错过了配置选项吗?

4

0 回答 0