In my show_instance
table, I have a column called dates
with type daterange
.
CREATE TABLE public.show_instance (
id integer NOT NULL,
show_id integer NOT NULL,
dates daterange NOT NULL
);
One of the values for dates is both inclusive and exclusive of day 2010-01-01.
INSERT INTO show_instance(id, show_id, dates)
VALUES
(1, 3, '[2010-01-01, 2010-01-01)'),
(2, 4, '[2010-04-03, 2010-04-04)'),
(3, 5, '[2010-05-29, 2010-05-30)');
This insert statement throws an error:
ERROR: null value in column "id" of relation "show_instance" violates not-null constraint
DETAIL: Failing row contains (null, 3, empty)
When all rows are selected, the daterange for the row is 'empty.'
SELECT show_id FROM show_instance WHERE daterange('2010-01-01', '2010-05-30') <@dates;
show_id
---------
(0 rows)
horse_show_db=# SELECT * FROM show_instance;
id | show_id | dates
----+---------+-------------------------
1 | 3 | empty
2 | 4 | [2010-04-03,2010-04-04)
3 | 5 | [2010-05-29,2010-05-30)
(3 rows)
For some reason, the 'empty' row is selected.
SELECT show_id FROM show_instance WHERE daterange('2010-01-01', '2010-05-30') @>dates;
show_id
---------
3
4
5
(3 rows)
1. Is there a constraint that prevents 'empty' from being inserted in the row?
2. If 'empty' is not equivalent to 'null', what is it?