Project

General

Profile

Actions

Defect #39991

closed

Fix "any" operator for text filters to exclude empty text values

Added by Yasu Saku 4 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Filters
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

For example, filtering issues with any notes filter will include issues with blank notes.
Is this a specification?
I don't think the SQL journals.notes IS NOT NULL is appropriate. A journal without notes has an empty string, not NULL.

Steps to reproduce:

  1. Load fixtures with rake db:fixtures:load.
  2. Update some parameters of an issue without any notes, like issue #3 in fixtures.
  3. Filter issues with any string in the notes.
  4. The issue #3 is extracted, but it does not have notes containing a string.

Journal table in this example
mysql> select id,journalized_id,created_on,notes from journals;
+----+----------------+---------------------+--------------------------------------------------------------------------+
| id | journalized_id | created_on          | notes                                                                    |
+----+----------------+---------------------+--------------------------------------------------------------------------+
|  1 |              1 | 2023-12-28 00:00:00 | Journal notes                                                            |
|  2 |              1 | 2023-12-29 00:00:00 | Some notes with Redmine links: #2, r2.                                   |
|  3 |              2 | 2023-12-29 00:00:00 | A comment with inline image: !picture.jpg! and a reference to #1 and r2. |
|  4 |              6 | 2023-12-29 00:00:00 | A comment with a private version.                                        |
|  5 |             14 | 2023-12-29 00:00:00 | A comment on a private issue.                                            |
| 10 |              3 | 2023-12-30 11:59:40 |                                                                          |
+----+----------------+---------------------+--------------------------------------------------------------------------+
6 rows in set (0.01 sec)

Actual SQL generated by ‎IssueQuery::sql_for_notes_field
EXISTS (SELECT 1 FROM journals WHERE journals.journalized_type='Issue' AND journals.journalized_id=issues.id AND (journals.notes IS NOT NULL) AND ((journals.private_notes = FALSE OR journals.user_id = 1 OR (projects.status <> 9 AND projects.status <> 10))))

Environment:

  Redmine version                5.1.1.stable
  Ruby version                   3.2.2-p53 (2023-03-30) [x86_64-linux]
  Rails version                  6.1.7.6
  Environment                    development / productioin
  Database adapter               Mysql2 / PostgreSQL

Files

clipboard-202312302147-586r1.png (71 KB) clipboard-202312302147-586r1.png Yasu Saku, 2023-12-30 13:47
39991.patch (1.91 KB) 39991.patch Go MAEDA, 2024-01-01 06:08

Related issues

Related to Redmine - Defect #25077: Issue description filter's 'none' operator does not match issues with blank descriptionsClosedJean-Philippe Lang

Actions
Actions #1

Updated by Go MAEDA 4 months ago

  • Related to Defect #25077: Issue description filter's 'none' operator does not match issues with blank descriptions added
Actions #2

Updated by Go MAEDA 4 months ago

  • File 39991.patch 39991.patch added
  • Subject changed from Incorrect results when using "none" and "any" parameters in notes filter to Fix "any" operator for text filters to exclude empty text values
  • Status changed from New to Confirmed
  • Target version set to 5.0.8

The attached patch fixes the issue.

This bug affects not only with "notes" but also with other text fields.

Actions #3

Updated by Go MAEDA 4 months ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix in r22583.

Actions #4

Updated by Go MAEDA 4 months ago

  • Status changed from Resolved to Closed

Merged the change to stable branches.

Actions #5

Updated by Yasu Saku 4 months ago

Mr. Go MAEDA, Thank you!

Actions

Also available in: Atom PDF