Changes between Version 23 and Version 24 of DatabaseProgramming


Ignore:
Timestamp:
06/14/26 15:05:22 (38 hours ago)
Author:
231028
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseProgramming

    v23 v24  
    188188as $$
    189189    begin
     190        if not exists(
     191            select 1
     192            from Ride r
     193            join Request req on r.request_id=req.id
     194            where r.id=id_ride and req.customer_user_id=id_customer
     195        )
     196        then
     197            raise exception 'Customer can not give a rating on a ride they do not have.';
     198        end if;
    190199        insert into review (rating, comment, ride_id, customer_user_id)
    191200        values (write_rating.rating,write_rating.comment,id_ride,id_customer);
     
    203212as $$
    204213    begin
     214        if not exists(
     215            select 1
     216            from Ride r
     217            join Request req on r.request_id=req.id
     218            where r.id=id_ride and req.customer_user_id=id_user
     219        )
     220        then
     221            raise exception 'User can not write a chat for a ride they do not have.';
     222        end if;
    205223        insert into chatmessage(message, user_id_from, ride_id)
    206224        values (new_message,id_user,id_ride);
     
    218236as $$
    219237    begin
     238        if not exists(
     239            select 1
     240            from Ride r
     241            join Request req on r.request_id=req.id
     242            where r.id=id_ride and req.customer_user_id=user_id
     243        )
     244        then
     245            raise exception 'Customer can not write a report on a ride they do not have.';
     246        end if;
    220247        insert into report(ride_id, customer_user_id, message, title, latitude, longitude, reason)
    221248        values (id_ride,user_id,new_message,new_title,temp_latitude,temp_long,new_reason);