您好,我们有一个名为billing_infos的表,其中在account_id
、state_id
和deleted_at
这三个字段上创建了部分索引,其中deleted_at
是NULL
,
我希望插入操作在try 插入account_id
、state_id
、deleted_at = null
的重复值时失败.
但它似乎正在创建另一个具有重复项的条目.当我们判断NULL条件时,部分索引有什么需要注意的吗?我已经判断了官方的documentation,但找不到一个,下面是我的表模式的片段
Porterbizz=>;\d+应用程序.billing_infos; 表格
"application.billing_infos"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
-----------------+-----------------------------+-----------+----------+-------------------------------------------------------+----------+--------------+-------------
id | integer | | not null | nextval('application.billing_infos_id_seq'::regclass) | plain | |
account_id | integer | | not null | | plain | |
gst_in | character varying(256) | | not null | | extended | |
gst_reg_address | character varying(256) | | not null | | extended | |
invoice_address | character varying(256) | | not null | | extended | |
state_id | integer | | not null | | plain | |
default | boolean | | not null | false | plain | |
deleted_at | timestamp without time zone | | | | plain | |
Indexes:
"billing_infos_pkey" PRIMARY KEY, btree (id)
"account_id_state_id_deleted_at_uniq_index" UNIQUE, btree (account_id, state_id, deleted_at) WHERE deleted_at IS NULL