Skip to content

Add session filter support for DML statement #1931

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

Merged
merged 12 commits into from
Dec 14, 2018

Conversation

maca88
Copy link
Contributor

@maca88 maca88 commented Dec 8, 2018

Fixes #1921
Fixes #803

Possible breaking change: update and delete statements will now take into account any enabled filter on the entities they update or delete, while previously they were ignoring them. (insert statements will also take them into account, but previously they were failing instead of ignoring enabled filters.)

@fredericDelaporte fredericDelaporte added this to the 5.3 milestone Dec 8, 2018
@fredericDelaporte
Copy link
Member

I have fixed the .g formatting issue, obsoleted some methods (and switch to public their replacements, otherwise the obsolete message would have told to use an unreachable method), and I have removed the query copy.

I have also added some multi-table filtered DML tests: they fail.

The insert case is failing only in the case of a filter on the joined table. That is maybe a DML insert limitation, and maybe that case should be just ignored.

The update and delete case suffer the same trouble than #1921: filter parameters are not processed and stay in the SQL. This happens for the SQL used for populating the temporary tables used for multi-table update/delete.

@@ -102,7 +102,7 @@ public async Task DmlDeleteAsync(bool filtered)

[TestCase(null)]
[TestCase("NameFilter")]
[TestCase("OtherNameFilter")]
[TestCase("OtherNameFilter", IgnoreReason = "Not supported")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently the insert statement does not have a multi table executer as update/delete have.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but the filter does not require a multi-table handling (which is meant to insert/update/delete many tables). It requires a join instead in the select clause.
Having the filter on the joined table silently ignored while it seems correctly taken into account for updates/deletes is a bit troublesome. (Granted, the test only check the count of entities considered updated by the statement. It does not check in the database that only expected entities have been updated. It should likely be checked too.)

Copy link
Member

Choose a reason for hiding this comment

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

And in fact, it is supported, and it works. That is the test which is bugged...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for correcting me, I overlooked the query and mistakenly assumed that the issue was with the lack of the multi executor.

Copy link
Member

Choose a reason for hiding this comment

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

That's me who wrote the bugged test in the first place, it was my mistake indeed.

@@ -82,6 +82,7 @@ public whereClause
;

whereClauseExpr
// 6.0 TODO: Remove "(SQL_TOKEN) => conditionList"
: (SQL_TOKEN) => conditionList
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is not used anymore as AddDiscriminatorWhereFragment is now deprecated.

@fredericDelaporte fredericDelaporte changed the title Add session filter support for DML statements Add session filter support for DML statement Dec 13, 2018
hazzik
hazzik previously approved these changes Dec 13, 2018
@hazzik hazzik dismissed stale reviews from fredericDelaporte and themself via daddf1a December 13, 2018 12:06
@hazzik
Copy link
Member

hazzik commented Dec 13, 2018

Is it possible breaking change?

@fredericDelaporte
Copy link
Member

Yes, it is a possible breaking change for update and delete. (insert was anyway failing with enabled filters.) I have added it to the PR description.

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.

3 participants