graphql-engine
graphql-engine copied to clipboard
function tstzrange(time with time zone, timestamp with time zone) does not exist.
Version Information
Server Version: v2.4.0 CLI Version (for CLI related issue): v2.4.0
Environment
Running using docker compose
What is the expected behaviour?
I have the following function:
CREATE OR REPLACE FUNCTION public.func_auction_bid_check()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
DECLARE
minimum numeric(18,2);
previous_bid auction_bids%ROWTYPE;
BEGIN
NEW.bid_time := CURRENT_TIMESTAMP;
NEW.replaced_by := NULL;
SELECT bid_min INTO minimum FROM listing WHERE id = NEW.listing_id AND tstzrange(start_at, end_at) @> NEW.bid_time;
IF (NOT FOUND) THEN
RAISE EXCEPTION 'No (open) auction available for ID % @ %', NEW.listing_id, NEW.bid_time;
ELSIF (minimum > NEW.bid) THEN
RAISE EXCEPTION 'New bid must be higher than auction minimum of %: %', minimum, NEW.bid;
ELSE
SELECT * INTO previous_bid
FROM auction_bids
WHERE
replaced_by IS NULL
AND
listing_id = NEW.listing_id
AND
user_id = NEW.user_id
ORDER BY bid_time DESC
LIMIT 1;
IF FOUND THEN
IF previous_bid.bid >= NEW.bid THEN
RAISE EXCEPTION 'New bid must be higher than previous: % >= %', previous_bid.bid, NEW.bid;
END IF;
UPDATE auction_bids SET replaced_by = NEW.id WHERE id = previous_bid.id;
END IF;
END IF;
RETURN NEW;
END;
$function$
;
Keywords
What is the current behaviour?
Inserting an item results in:
function tstzrange(time with time zone, timestamp with time zone) does not exist. null
This seems strange as the tstzrange() function is supported by postgres versions 10 - 14.
How to reproduce the issue?
- You could probably reproduce it calling a function that has something similar to
SELECT bid_min INTO minimum FROM listing WHERE id = NEW.listing_id AND tstzrange(start_at, end_at) @>
If the bug is confirmed, would you be willing to submit a PR?
I dont understand what is causing this issue well enough to say. Happy to help where I can provide help.
Hi @magick93 we wanted to reach out to you regarding your PR. Could you let us know how we could get in touch? Thanks!
Closing as I needed to add btree extension.