[英]PostgreSQL range containment operator @> not working as expected for the upper boundary
Postgres range datatype's "contains" operator is not working as I expect it. Postgres 范围数据类型的“包含”运算符没有像我预期的那样工作。 Can anyone help me to solve this
谁能帮我解决这个问题
select INT4RANGE(1,5) @> 5
giving false
result, where it should be true because 5 in that range select INT4RANGE(1,5) @> 5
给出false
的结果,它应该是真的,因为 5 在那个范围内
Ranges that don't specify if the bounds are inclusive or exclusive are created with exclusive upper bound未指定边界是包含还是排他的范围是使用排他上限创建的
he two-argument form constructs a range in standard form (lower bound inclusive, upper bound exclusive)
双参数形式以标准形式构造一个范围(包括下限,不包括上限)
So int4range(1,5)
is the same as int4range(1,5,'[)')
which excludes the value 5.所以
int4range(1,5)
与int4range(1,5,'[)')
相同,后者不包括值 5。
If you want the 5 to be included, create the range with an inclusive upper bound: int4range(1,5,'[]')
如果要包含 5,请创建包含上限的范围:
int4range(1,5,'[]')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.