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

Respect doesColumnSupportEmptyValue when building empty/notEmpty filtered queries #14078

Open
wants to merge 3 commits into
base: 5.1
Choose a base branch
from

Conversation

cjavad
Copy link

@cjavad cjavad commented Aug 25, 2024

Q A
Bug fix? (use the a.b branch) 🟢
New feature/enhancement? (use the a.x branch) 🔴
Deprecations? 🔴
BC breaks? (use the c.x branch) 🔴
Automated tests included? 🔴
Related user documentation PR URL None
Related developer documentation PR URL None
Issue(s) addressed None

Description

Having segments being built with a filter that asserts "date is not empty" or "date is empty" throws a SQL Exception when performing a comparison between a date and an empty string.

This only applies to this ComplexRelationValueFilterQueryBuilder.php not the newer BaseFilterQueryBuilder.php that invokes SegmentOperatorQuerySubscriber.php leading to inconsistent results between the two.

This has only been identified and tested on 5.1, might apply to versions as low as 5.0.


📋 Steps to test this PR:

  1. Create a custom field using the "date" type on a contact
  2. Create a segment that is built based on that field being empty
  3. Run the "mautic:segments:update" command

Without this it errors out.

@RCheesley RCheesley added T1 Low difficulty to fix (issue) or test (PR) regression A bug that broke something in the last release segments Anything related to segments code-review-needed PR's that require a code review before merging ready-to-test PR's that are ready to test labels Aug 27, 2024
@RCheesley
Copy link
Member

Thanks so much for the PR @cjavad and welcome to the community!

I think the failed test was due to Codecov not being able to receive the uploaded report so I've just set that running again.

Would you mind rebasing this onto the 5.1 branch please? As we released 5.1 recently, the next patch release will come from that branch. Let us know if you need any help with doing that.

@RCheesley
Copy link
Member

@all-contributors please add @cjavad for code

Copy link
Contributor

@RCheesley

I've put up a pull request to add @cjavad! 🎉

@cjavad
Copy link
Author

cjavad commented Aug 27, 2024

Thank you @RCheesley. It should be correctly rebased to 5.1 now with some git magic. No additional checks or tests has been run yet though.

@RCheesley
Copy link
Member

Thanks for getting that done so quickly @cjavad 🚀

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 62.18%. Comparing base (3c9824e) to head (bd4b2e1).

Files with missing lines Patch % Lines
.../Filter/ComplexRelationValueFilterQueryBuilder.php 0.00% 10 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                5.1   #14078      +/-   ##
============================================
- Coverage     62.18%   62.18%   -0.01%     
- Complexity    34220    34222       +2     
============================================
  Files          2252     2252              
  Lines        102330   102338       +8     
============================================
  Hits          63635    63635              
- Misses        38695    38703       +8     
Files with missing lines Coverage Δ
.../Filter/ComplexRelationValueFilterQueryBuilder.php 48.05% <0.00%> (-5.58%) ⬇️

@cjavad
Copy link
Author

cjavad commented Aug 27, 2024

Digging deeper it seems this is a duplicate of #12862 opened almost a year ago 😮

Although i prefer my own fix (hehe) there might be a reason for it not being merged earlier?

@RCheesley
Copy link
Member

@cjavad most likely a lack of testers (it's a huge challenge for us to find enough people to test and review, if you ever fancy helping check out https://mau.tc/tester), and because at this time it has unresolved conflicts, however that PR does have automated test coverage which would be preferable. Could you write tests to cover this PR if we took it forward?

@escopecz @kuzmany any thoughts on which approach would be preferable?

@cjavad
Copy link
Author

cjavad commented Aug 28, 2024

I'll be more than happy to add some tests once applicable.

Copy link
Contributor

@shinde-rahul shinde-rahul left a comment

Choose a reason for hiding this comment

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

@cjavad, Please add test cases which will help us with the example and help improve the code coverage.

@andersonjeccel andersonjeccel added T2 Medium difficulty to fix (issue) or test (PR) and removed T1 Low difficulty to fix (issue) or test (PR) labels Sep 12, 2024
@andersonjeccel andersonjeccel added this to the 5.1.1 milestone Sep 12, 2024
@escopecz escopecz removed this from the 5.1.1 milestone Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-review-needed PR's that require a code review before merging ready-to-test PR's that are ready to test regression A bug that broke something in the last release segments Anything related to segments T2 Medium difficulty to fix (issue) or test (PR)
Projects
Status: 🚨 Developer revision needed
Development

Successfully merging this pull request may close these issues.

5 participants