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

Filter on old_record during deletes #76

Merged
merged 11 commits into from
Aug 27, 2024
Merged

Filter on old_record during deletes #76

merged 11 commits into from
Aug 27, 2024

Conversation

olirice
Copy link
Collaborator

@olirice olirice commented Jul 19, 2024

What kind of change does this PR introduce?

Adds support for filters on delete events

  • when I want to filter by a column that is not available in old_columns, then the subscriber is ignored.
  • when replica identity is not full, only filters referencing the pk column(s) are respected.
  • when replica identity is full, filters referencing any column in the table are respected.

What is the current behavior?

  • all delete events are emitted

Please link any relevant issues here.
resolves #53

Comment on lines +259 to +262
or (
action = 'DELETE'
and realtime.is_visible_through_filters(old_columns, subs.filters)
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the change

walrus;
rec | is_rls_enabled | subscription_ids | errors
----------------------------------------------------+----------------+----------------------------------------+--------
{ +| f | {} | {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no subscription_ids present because there is a filter on body which is not part of the replica identity / not part of the primary key

}, +| | |
"commit_timestamp": "2000-01-01T08:01:01.000Z"+| | |
} | | |
{ +| f | {5211e8ec-8c25-5c7f-9b03-6ff1eac0159e} | {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

subscription_ids exists because the filter is on a primary key column

walrus;
rec | is_rls_enabled | subscription_ids | errors
----------------------------------------------------+----------------+----------------------------------------+--------
{ +| f | {f4539ebe-c779-5788-bbc1-2421ffaa8954} | {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

after setting replica identity full the filter on body = 'bbb' works, so we get subscription_id

}, +| | |
"commit_timestamp": "2000-01-01T08:01:01.000Z"+| | |
} | | |
{ +| f | {5211e8ec-8c25-5c7f-9b03-6ff1eac0159e} | {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

continues to work

], +| | |
"commit_timestamp": "2000-01-01T08:01:01.000Z"+| | |
} | | |
{ +| f | {f4539ebe-c779-5788-bbc1-2421ffaa8954} | {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note that this part of the output changed

], +| | |
"commit_timestamp": "2000-01-01T08:01:01.000Z"+| | |
} | | |
{ +| f | {f4539ebe-c779-5788-bbc1-2421ffaa8954} | {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note that this part of the output changed

@olirice olirice changed the title Or/delete filters Filter on old_record during deletes Jul 19, 2024
@w3b6x9
Copy link
Member

w3b6x9 commented Jul 24, 2024

@olirice what happens when RLS is enabled on table and there's a delete filter? If client passes RLS they will get the change otherwise they will not. Is that correct?

@olirice
Copy link
Collaborator Author

olirice commented Jul 29, 2024

@olirice what happens when RLS is enabled on table and there's a delete filter? If client passes RLS they will get the change otherwise they will not. Is that correct?

this change does not impact RLS, its just about filtering

Unfortunately, it is still the case that we can't test RLS for delete

@olirice olirice merged commit ef516d6 into master Aug 27, 2024
1 check passed
@olirice olirice deleted the or/delete_filters branch August 27, 2024 16:14
@ConProgramming
Copy link

@olirice
Copy link
Collaborator Author

olirice commented Oct 10, 2024

cc @filipecabaco
#76 (comment)

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

Successfully merging this pull request may close these issues.

Enable filters for delete events
4 participants