Skip to content

Commit

Permalink
fixed error ranges and add trigger tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danicc097 committed Dec 1, 2022
1 parent 4280771 commit 6680828
Show file tree
Hide file tree
Showing 6 changed files with 507 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CREATE TABLE users_1 (
id integer not null PRIMARY KEY,
updated_at timestamp with time zone not null DEFAULT now()
);
CREATE TABLE users_2 (
id integer not null PRIMARY KEY
);
CREATE TABLE users_3 (
id integer not null PRIMARY KEY
);

DROP trigger IF EXISTS update_users_1_modtime on user_1;
DROP trigger IF EXISTS update_users_2_modtime on user_2;
DROP trigger IF EXISTS update_users_3_modtime on user_3;

create or replace function update_updated_at_column ()
returns trigger
language plpgsql
as $function$
begin
new.updated_at = NOW();
return new;
end;
$function$;

create trigger update_users_3_modtime -- should raise error
before update on users_3 for each row
execute function update_updated_at_column ();

create trigger update_users_1_modtime
before update on users_1 for each row
execute function update_updated_at_column ();

create trigger update_users_2_modtime -- should raise error
before update on users_2 for each row
execute function update_updated_at_column ();
Loading

0 comments on commit 6680828

Please sign in to comment.