#7821 closed defect (fixed)
grouping doesn't work in default_query
| Reported by: | Owned by: | Jun Omae | |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.12.3 |
| Component: | query system | Version: | 0.11.2 |
| Severity: | normal | Keywords: | USER |
| Cc: | osimons | Branch: | |
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description (last modified by )
I have set this in my "trac.ini":
[query] default_query = status!=closed&group=milestone&owner=$USER
but when I click on the "View Tickets" button, the "Group results by" box is empty. This is from my "trac.log" file:
2008-11-14 18:45:16,326 Trac[main] DEBUG: Dispatching <Request "GET u'/query'"> 2008-11-14 18:45:16,326 Trac[query] DEBUG: QueryModule: Using default query: status!=closed&group=milestone&owner=$USER 2008-11-14 18:45:16,326 Trac[chrome] DEBUG: Prepare chrome data for request 2008-11-14 18:45:16,342 Trac[session] DEBUG: Retrieving session for ID u'galante' 2008-11-14 18:45:16,342 Trac[query] DEBUG: Count results in Query: 131 2008-11-14 18:45:16,342 Trac[query] DEBUG: Query SQL: SELECT t.id AS id,t.summary AS summary,t.status AS status,t.type AS type,t.priority AS priority,t.milestone AS milestone,t.component AS component,t.time AS time,t.changetime AS changetime,t.owner AS owner,priority.value AS priority_value FROM ticket AS t LEFT OUTER JOIN enum AS priority ON (priority.type='priority' AND priority.name=priority) WHERE COALESCE(t.status,'')!=u'closed' AND COALESCE(t.owner,'')=u'galante' ORDER BY COALESCE(priority.value,'')='',CAST(priority.value AS int),t.id LIMIT 100 OFFSET 0 2008-11-14 18:45:16,358 Trac[perm] DEBUG: No policy allowed galante performing REPORT_VIEW on None 2008-11-14 18:45:16,983 Trac[perm] DEBUG: No policy allowed galante performing REPORT_CREATE on None 2008-11-14 18:45:17,187 Trac[main] DEBUG: 388 unreachable objects found.
I understand from #5998 that this should work on Trac 0.11.2, but it doesn't for me. I have tried with tracd on Windows and trac+apache on Linux, the client is Internet Explorer.
Attachments (1)
Change History (23)
comment:1 by , 17 years ago
| Description: | modified (diff) |
|---|---|
| Resolution: | → worksforme |
| Status: | new → closed |
comment:2 by , 17 years ago
| Description: | modified (diff) |
|---|
Oops, changed the description inadvertently.
comment:3 by , 17 years ago
Using the URL syntax works, but I still see one problem. The Custom Query page shows the tickets filtered and grouped as requested, but the Owner field is empty. So if I click on the Update button I get no tickets found.
I think this is similar to the problem described in #7140.
comment:4 by , 17 years ago
So you're probably using restrict_owner = true. This problem will be fixed in #7258.
comment:5 by , 15 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → reopened |
It is happening to me on Trac 0.12.1. I tried various workarounds, like moving the group parameter inside the URL, but they did not help. It seems to affect only the grouping, but it prevents us from getting the optimal query be default.
(I'm also not sure that the "general" is the best component selection for this ticket.)
comment:6 by , 15 years ago
One more information on this: If I paste the URL of the right query into the browser, it can load the "group by" selector on the UI. So the problem might be in the code executed when the user clicks on the "View Tickets" link. That does not seem to be able to pass the group URL parameter in this case.
(Maybe it would be better to just navigate the URL with the query in it instead of trying to pass the whole thing internally, as it does, currently. Just an idea.)
comment:7 by , 15 years ago
For completeness, here is my query configuration from trac.ini:
[query] default_anonymous_query = status!=closed&cc~=$USER default_query = status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1 items_per_page = 100 ticketlink_query = status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1
comment:8 by , 15 years ago
I have restrict_owner set to true, but it should not affect the above behavior, I think.
comment:9 by , 15 years ago
Try using URL syntax (which is not the same as the query syntax, see comment:1):
[query] default_anonymous_query = ?status=!closed&cc=~$USER default_query = ?status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1 items_per_page = 100 ticketlink_query = ?status=accepted&status=assigned&status=new&status=reopened&group=owner&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority&desc=1
comment:10 by , 15 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | reopened → closed |
No reply, assuming URL syntax did the trick.
comment:11 by , 14 years ago
| Component: | general → query system |
|---|---|
| Resolution: | worksforme |
| Status: | closed → reopened |
| Version: | 0.11.2 → 0.12.2 |
- The original problem is still present in 0.12.2.
- It is not solved by using the URL syntax:
Using the URL syntax enables grouping okay, but the user field is then set to (litarally) "$User", i.e., the variable is not substituted.
Hence there is still no way of having the default query display all active tickets of the current user, grouped by status.
Strangely, doing the same thing for default_anonymous_query works okay:
- This works
-
default_anonymous_query = status!=closed&cc~=$USER&group=status
- This works not
-
default_query = ?status=!closed&owner=$USER&group=status
comment:12 by , 14 years ago
| Summary: | group=milestone doesn't work in default_query → grouping doesn't work in default_query |
|---|
comment:13 by , 14 years ago
| Keywords: | USER added |
|---|---|
| Milestone: | → next-minor-0.12.x |
Thanks for the test case, we'll check this.
comment:14 by , 14 years ago
| Owner: | set to |
|---|---|
| Status: | reopened → new |
I'm working for the issue. The original issue is fixed in changeset:7824/jomae. The 2nd issue, $USER variable is still not substituted. query:owner=$USER has the same issue.
comment:15 by , 14 years ago
My work is finished in diff:jomae@7823:7825. The $USER variable is always substituted (e.g. default_query in trac.ini and query:owner=$USER).
comment:17 by , 14 years ago
| Milestone: | next-minor-0.12.x → 0.12.3 |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
The patch has been applied in [10852].
follow-up: 19 comment:18 by , 14 years ago
| Cc: | added |
|---|---|
| Resolution: | fixed |
| Status: | closed → reopened |
Sorry, but this change breaks as it seems that the query module passes a valid req whereas the [[TicketQuery]] passes None. Or something similar.
This on a wiki page:
[[TicketQuery(status=new|assigned|reopened,format=table)]]
Results in:
[] formatter.py:720 ERROR: Macro TicketQuery(status=new|assigned|reopened,format=table) failed:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/wiki/formatter.py", line 717, in _macro_formatter
return macro.process(args, in_paragraph=True)
File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/wiki/formatter.py", line 304, in process
text = self.processor(text)
File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/wiki/formatter.py", line 291, in _macro_processor
text)
File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/ticket/query.py", line 1297, in expand_macro
data = query.template_data(formatter.context, tickets)
File "/usr/local/lib/python2.7/site-packages/Trac-0.12.3dev_r10853-py2.7.egg/trac/ticket/query.py", line 707, in template_data
val = val.replace('$USER', req.authname)
AttributeError: 'NoneType' object has no attribute 'authname'
by , 14 years ago
| Attachment: | t7821-template-data-r10855.diff added |
|---|
follow-up: 20 comment:19 by , 14 years ago
Replying to osimons:
Sorry, but this change breaks as it seems that the query module passes a valid
reqwhereas the[[TicketQuery]]passesNone. Or something similar.
Oops…. Sorry, I'm wrong.
Could you please try the patch, t7821-template-data-r10855.diff? All unit and functional tests pass in my environment.
comment:20 by , 14 years ago
Replying to jomae:
Could you please try the patch, t7821-template-data-r10855.diff?
Looks & works correct. Thanks.
comment:21 by , 14 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Thanks. Applied in [10861].
comment:22 by , 14 years ago
| Version: | 0.12.2 → 0.11.2 |
|---|
Issue had been present since 0.11.2 (not only since 0.12.2).



Replying to m.galante@…:
#5998 allowed using the URL syntax for
default_query, which is not quite the same as the query syntax. In your case, you should use the following:Note the leading
?and the modifier after the=.I am trying to make both syntaxes converge in #7699, so this should get less confusing in the future.