-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/report/15 Add fix and tests for contact subtype report filter #14764
Conversation
(Standard links)
|
So as a test this worked for me in terms of hitting the right places in the code (it didn't actually pass but that was because it's not handling NULL in contact_sub_type)
Captured query
|
Just a note that we need to drop 5.15.1 - if this is ready in time it should be included - I don't know exactly when it will drop - need to fit around @totten |
@eileenmcnaughton maybe i'm just being dense but what i'm having trouble with is that the tests for the null and not null filters (the ones that were causing db errors so we'd want to test that they're working) don't seem to line up with what i'm seeing in the GUI i.e. when I put "IS NOT NULL" to simulate someone using that filter, for example
The query generated by 'contact_sub_type_op' => 'IS NOT NULL', 'contact_sub_type_value' => TRUE looks like this when generated by the API (I copied this from an sql error log):
Any other "IS NOT NULL" query i've tried seems to bring back all contacts as result rows whether subtype actually is null or not. However when I use the "IS NOT NULL" filter from the actual report screen, I get the correct results from the report and the generated query looks like:
Which is what I would expect from either method. |
@elisseck I think you want 'nnll' don't you? civicrm-core/CRM/Report/Form.php Line 1782 in 306f077
FWIW the way I normally do this is I submit the form through the UI & capture the values in $this->_params from there (I use a breakpoint in phpstorm & the copy as var_dump function but at a pinch you could var_dump + die) |
@eileenmcnaughton Thank you!! That was the piece I was missing. I just pushed with tests for the null and not null filters that should be passing on top of Jon's commit. |
@elisseck can you rebase this onto the 5.16 branch so it can go into the rc since it was a regression |
That can't be right... |
@eileenmcnaughton I am unsure if this is correct or not since I haven't done it before. I rebased my changes on upstream/5.16. Do I also change where this pull request merges to I guess? |
I changed the base & it still just shows 2 commits - so that is good |
unrelated test fail @MegaphoneJon @elisseck I feel like your collaboration on this constitutes review - if you both confirm you are happy with this PR as it stands I will merge |
@eileenmcnaughton I'm happy with Jon's changes and we've gotten rid of the db error that was happening with the "empty" and "not empty" filters on contact sub type. I think your non-passing test above for "not in" alludes to the fact that "not in" is still not quite working the way you'd expect with contacts that don't have a subtype at all - but there isn't a db error so that might warrant it's own issue for a different set of changes and a test at a later time? |
OK, I'm going to merge this now then - since you are the reviewer for @MegaphoneJon's change |
Overview
Adding a PR for the fix by @MegaphoneJon along with some tests for the filter options that are now available.
Before
On the contact summary report (or other reports), using the 'IS NULL' or 'IS NOT NULL' filters for "Contact Subtype" would result in a DB error.
After
Filters are working as expected and tests have been added to keep it that way.
Technical Details
This is a WIP because i've written the tests how I believe they're supposed to go (I've also tried the /api/v3/ReportTemplateTest.php style tests) ... I cannot seem to get them to pass. I've tried adding the null and not null filters a bunch of ways but the rows returned are always 2 (all) instead of the expected 1.
The functionality from Jon's commit, however, is working exactly as it should if I actually go run the report through the GUI and use the filters... so this is just a problem with the tests i've written.