Closed Bug 302599 Opened 19 years ago Closed 19 years ago

Saved searches using "days since bug changed" fail with "Can't use (to_days(now()) - to_days(bugs.delta_ts)) as a field name" error

Categories

(Bugzilla :: Query/Bug List, defect)

2.20
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: Wurblzap, Assigned: LpSolit)

References

Details

(Keywords: regression)

Attachments

(1 file, 2 obsolete files)

This is a regression of bug 280499 (based on bug 237862).

Steps to reproduce:
1. On a pre-280499 install, create a saved search which contains a boolean
   chart referring to the "Days since bug changed" field.
2. Upgrade to a post-280499 version.
3. Run the saved search.

This fails because the "Days since bug changed" field has changed from
"(to_days(now()) - to_days(bugs.delta_ts))" to
"(TO_DAYS(NOW()) - TO_DAYS(bugs.delta_ts))" in the meantime, so that Search.pm
cannot find it any more.
*** Bug 302651 has been marked as a duplicate of this bug. ***
*** Bug 313487 has been marked as a duplicate of this bug. ***
Flags: blocking2.20.1+
Target Milestone: --- → Bugzilla 2.20
Attached patch possible fix, v1 (obsolete) β€” β€” Splinter Review
Marc, does it fix the problem for you? I hacked the URL to test it and it seems to work correctly. But maybe this introduces other regressions?
Attachment #200605 - Flags: review?(wurblzap)
Comment on attachment 200605 [details] [diff] [review]
possible fix, v1

joel, could you have a look at this fix as well? Maybe it introduces other regressions?
Attachment #200605 - Flags: review?(bugreport)
Comment on attachment 200605 [details] [diff] [review]
possible fix, v1

I think this is the right way to do it. I'll need to look into it in detail, though.
Comment on attachment 200605 [details] [diff] [review]
possible fix, v1

This should be pretty safe
Attachment #200605 - Flags: review?(bugreport) → review+
Attachment #200605 - Flags: review?(wurblzap)
Assignee: query-and-buglist → LpSolit
Flags: approval?
Flags: approval2.20?
Comment on attachment 200605 [details] [diff] [review]
possible fix, v1

I disagree with this change -- I think that we can just manually fix the old Saved Searches in checksetup.pl.

I don't want to have to remember to "lc" the field names forever.
WTF are we using SQL for a field name anyway?  That sucks.

We should get it over with and give it a real field name, and do the SQL conversion on the back end after decoding the URL params/saved query params.

Although we probably need to do something stupid like the lc() test for 2.20
Flags: approval?
Flags: approval2.20?
I'm not going to play with field names or with Search.pm. Reassigning to default owner.
Assignee: LpSolit → query-and-buglist
It seems to me comment 8 makes this to be related to bug 289602. What do you think?
Blocks: 301141
Another good reason to fix this bug quickly is that it blocks bug 301141, a PostgreSQL-specific one, when my patch v2 is applied (this doesn't mean my patch is wrong, this means we are inserting a stupid column name):

checksetup.pl: DBD::Pg::db do failed: ERREUR:  Value too long for type character varying(64)
checksetup.pl:  [for Statement "INSERT INTO fielddefs
checksetup.pl:                                (name, description, mailhead, sortkey)
checksetup.pl:                    VALUES (?, ?, ?, ?)"] at ./checksetup.pl line 1664
checksetup.pl:       main::AddFDef('(TO_CHAR(NOW()::date, \'J\')::int - TO_CHAR(bugs.delta_ts::da...', 'Days since bug changed', 0) called at ./checksetup.pl line 1715
Severity: minor → normal
Flags: blocking2.22?
No longer blocks: 301141
It's true that comment 8 is the right way to fix this, but I doubt we will be doing that for 2.20 or 2.22. It actually could be a significant architectural change. For now there is a much simpler workaround to fix this, which is simply to fix the saved queries.
Attached patch patch, v2 (obsolete) β€” β€” Splinter Review
it wasn't that difficult after all. ;)

Tested on both MySQL and PostgreSQL. Saved searches are correctly fixed, even when the case is different from the one expected. After running checksetup.pl, I can still run and edit saved searches correctly. The field name in the 'fielddefs' table has been renamed to 'days_elapsed'.
Assignee: query-and-buglist → LpSolit
Attachment #200605 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #202609 - Flags: review?(mkanat)
Comment on attachment 202609 [details] [diff] [review]
patch, v2

my patch affects Search.pm, so asking joel too.
Attachment #202609 - Flags: review?(bugreport)
Comment on attachment 202609 [details] [diff] [review]
patch, v2

OH yeah, you're right.

My only thought is -- shouldn't the $old_field_name be surrounded by \Q \E in the regex?
Attachment #202609 - Flags: review?(mkanat) → review+
Comment on attachment 202609 [details] [diff] [review]
patch, v2

Yes, it should, and I'm going to go ahead and deny review on this instead of saying "fix it on checkin" because that's a fairly big deal.  *never* use unescaped variables in a regexp unless you expect the contents of the variable to actually contain a regexp that you plan to use.
Attachment #202609 - Flags: review?(bugreport) → review-
ok, another stupid (or maybe not?) question...  what about saved chart series?
Blocks: 301141
Attached patch patch, v3 β€” β€” Splinter Review
justdave is right, saved chart series have to be fixed too.
Attachment #202609 - Attachment is obsolete: true
Attachment #202920 - Flags: review?(justdave)
Attachment #202920 - Flags: review?(mkanat)
Comment on attachment 202920 [details] [diff] [review]
patch, v3

r=mkanat by inspection of interdiff.
Attachment #202920 - Flags: review?(mkanat) → review+
Attachment #202920 - Flags: review?(justdave)
Flags: approval?
Flags: approval2.20?
Flags: blocking2.22?
Flags: blocking2.22+
Flags: approval?
Flags: approval2.20?
Flags: approval2.20+
Flags: approval+
tip:

Checking in checksetup.pl;
/cvsroot/mozilla/webtools/bugzilla/checksetup.pl,v  <--  checksetup.pl
new revision: 1.450; previous revision: 1.449
done
Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.118; previous revision: 1.117
done


2.20:

Checking in checksetup.pl;
/cvsroot/mozilla/webtools/bugzilla/checksetup.pl,v  <--  checksetup.pl
new revision: 1.412.2.10; previous revision: 1.412.2.9
done
Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.99.2.8; previous revision: 1.99.2.7
done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: