Skip to content

Instantly share code, notes, and snippets.

@davetapley
Last active August 29, 2015 14:03
Show Gist options
  • Save davetapley/94815699db8646451248 to your computer and use it in GitHub Desktop.
Save davetapley/94815699db8646451248 to your computer and use it in GitHub Desktop.
Postgres range empty check, with inclusive/exclusive end bound
test=# SELECT isempty('[0,0]' :: int4range);
isempty
---------
f
(1 row)
test=# SELECT isempty('[0,0)' :: int4range);
isempty
---------
t
(1 row)
>> Sequel::Postgres::PGRange.from_range(0 .. 0).empty?
=> false
>> Sequel::Postgres::PGRange.from_range(0 ... 0).empty?
=> false
>> Sequel::Postgres::PGRange.new(0, 0, exclude_end: false).empty?
=> false
>> Sequel::Postgres::PGRange.new(0, 0, exclude_end: true).empty?
=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment