-
-
Notifications
You must be signed in to change notification settings - Fork 611
Closed
Labels
❔ question😓 cannot-reproduceSomeone has attempted but failed to reproduce this; create an example repo to demonstrate the issue.Someone has attempted but failed to reproduce this; create an example repo to demonstrate the issue.
Description
Why this function of mine cannot be a custom query? Can you please explain for me
create or replace function app.verify_coupon_code(
coupon_code text,
order_input app.orders,
order_lines app.order_lines[]
) returns app.coupons as $$
with coupons_used_count as (
select o.coupon_code, count(o.coupon_code)
from app.orders o
where o.created_by = current_user_id() and o.coupon_code is not null
group by o.coupon_code
),
avai_coupons as (
....
)
select *
from avai_coupons ac
where lower(ac.code) = lower(coupon_code);
$$ language sql stable;if change args to arrays then work
create or replace function app.verify_coupon_code_3(
coupon_code text,
order_input app.orders[],
order_lines app.order_lines[]
) returns app.coupons as $$
select *
from app.coupons ac
where lower(ac.code) = lower(coupon_code)
fetch first row only;
$$ language sql stable;Metadata
Metadata
Assignees
Labels
❔ question😓 cannot-reproduceSomeone has attempted but failed to reproduce this; create an example repo to demonstrate the issue.Someone has attempted but failed to reproduce this; create an example repo to demonstrate the issue.
