Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hypercore chunk tests for triggers #7483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkindahl
Copy link
Contributor

@mkindahl mkindahl commented Nov 22, 2024

Add tests for statement and row triggers on hypercore chunks. We test INSERT, UPDATE, DELETE, and TRUNCATE triggers, where applicable. We check that the OLD and NEW values are correct as well as that the statement and row triggers are executed the correct number of times.

Disable-check: force-changelog-file

@mkindahl mkindahl self-assigned this Nov 22, 2024
Add tests for statement and row triggers on hypercore chunks. We test
`INSERT`, `UPDATE`, `DELETE`, and `TRUNCATE` triggers, where
applicable. We check that the `OLD` and `NEW` values are correct as
well as that the statement and row triggers are executed the correct
number of times.
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.12%. Comparing base (59f50f2) to head (1510ded).
Report is 619 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7483      +/-   ##
==========================================
+ Coverage   80.06%   82.12%   +2.06%     
==========================================
  Files         190      230      +40     
  Lines       37181    43129    +5948     
  Branches     9450    10846    +1396     
==========================================
+ Hits        29770    35421    +5651     
- Misses       2997     3388     +391     
+ Partials     4414     4320      -94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link

@gayyappan, @erimatnor: please review this pull request.

Powered by pull-review

Comment on lines +10 to +30
create function save_insert_row() returns trigger as $$
begin
insert into saved_rows select new.*, true, 'insert';
return new;
end;
$$ language plpgsql;

create function save_update_row() returns trigger as $$
begin
insert into saved_rows select new.*, true, 'update';
insert into saved_rows select old.*, false, 'update';
return new;
end;
$$ language plpgsql;

create function save_delete_row() returns trigger as $$
begin
insert into saved_rows select old.*, false, 'delete';
return new;
end;
$$ language plpgsql;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be simplified in only one trigger function and also track TG_WHEN and use TG_OP to save the proper operation on the saved_rows table.

Another thing is that you're testing only BEFORE triggers and what about AFTER and INSTEAD OF ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants