Edgewall Software

Opened 11 years ago

Last modified 2 years ago

#10286 new enhancement

Way to query all tickets with attachments

Reported by: Mitar Owned by:
Priority: normal Milestone: next-major-releases
Component: query system Version: 0.12.1
Severity: normal Keywords:
Cc: mmitar@… Branch:
Release Notes:
API Changes:
Internal Changes:


Trac should provide a way to query all tickets with attachments, or even better, with a given name/description in an attachment. Or maybe even attachment size(s) (individual or combined).

Attachments (0)

Change History (9)

comment:1 by Remy Blank, 11 years ago

Milestone: next-major-0.1X

Sounds like a good addition to the ticket query system. Note that you can probably already do that with reports.

comment:2 by anonymous, 10 years ago

How do you do it with reports? will you give an example please?

thanks Harel

comment:3 by Mitar, 10 years ago

You write an SQL query. ;-)

Reports = old system, using SQL queries. Query system = new inteface, generating SQL queries internally.

comment:4 by anonymous, 10 years ago

As far as I see, The attachments are not stored inside the DB, but in a separated directory. Therefore, I don;t know How to write such query / report. Whould you please give ne an example?

Thanks Harel

comment:5 by Peter Suter, 10 years ago

The attachments themselves are not stored in the DB, but there is some metadata.

SELECT id, description, filename, size
FROM attachment
WHERE type=="ticket"
Version 0, edited 10 years ago by Peter Suter (next)

comment:6 by anonymous, 10 years ago

thanks, It works! If I may, another question: The query above displays each attachment as a separated result. How can I make it displaying by tickets, i.e. display all files that are related to the same ticket as one result (one row in the results table) Thanks again Harel

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:7 by Peter Suter, 10 years ago

Something like this maybe:

SELECT t.id as id,
       t.summary as summary,
       group_concat(a.description,", ") as "file descriptions",
       group_concat(a.filename,", ") as files
FROM attachment a
INNER JOIN ticket t
ON a.id == t.id
WHERE a.type=="ticket"

Or to get one table per ticket with one row per attachment:

SELECT a.filename AS id, "attachment" AS _realm,
       "ticket" AS _parent_realm, t.id AS _parent_id,
       a.description as description,
       a.size as size,
       "#" || t.id || " " || t.summary as  __group__,
       '../ticket/' || t.id as __grouplink__
FROM attachment a
INNER JOIN ticket t
ON a.id == t.id
WHERE a.type=="ticket"

in reply to:  7 comment:8 by anonymous, 10 years ago

Replying to psuter:

Something like this maybe: […]

It works! many thanks

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:9 by Peter Suter, 7 years ago

Possibly this could be provided after #10983.

Modify Ticket

Change Properties
Set your email in Preferences
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.