请向我解释这种行为。
此 SQL 查找 ids (type is array::bigint
) 为空的元素。
SELECT * FROM rises WHERE ids = '{}'
-- finds, e.g., 9 rows
Run Code Online (Sandbox Code Playgroud)
此 SQL 未找到任何行:
SELECT * FROM rises WHERE array_length(ids, 1) = 0
--finds always 0 rows
Run Code Online (Sandbox Code Playgroud)
但是这个 SQL 可以找到非空数组
SELECT * FROM rises WHERE array_length(ids, 1) > 0
--finds, e.g., 15 rows
Run Code Online (Sandbox Code Playgroud)
初始化:
CREATE TABLE rises(
id bigserial,
d1 bigint DEFAULT 0,
ids bigint[] DEFAULT '{}',
PRIMARY KEY (id));
Run Code Online (Sandbox Code Playgroud)
为什么array_length
可以找到非空数组,但对空数组不起作用?