#11140 closed defect (fixed)
`Query` with many custom fields doesn't work — at Version 3
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.6 |
Component: | query system | Version: | 0.12-stable |
Severity: | normal | Keywords: | sqlite mysql custom fields |
Cc: | Ryan J Ollos | Branch: | |
Release Notes: |
Avoid limitation of joins with many custom fields for ticket query |
||
API Changes: | |||
Internal Changes: |
Description
The following error occurs when selecting many custom fields in query page. Also the same has occured with th:ExcelDownloadPlugin which internally adds all custom fields to query.
- SQLite
-
OperationalError: at most 32 tables in a join
- MySQL
-
OperationalError: (1116, 'Too many tables; MySQL can only use 61 tables in a join')
This error is caused by the limitation of joins. PostgreSQL has no limitation of joins.
Workaround, using sub queries instead of JOIN
s to retrieve custom fields to avoid it.
SELECT id,summary,....,`field_1`,`field_2` FROM ticket AS t LEFT JOIN (SELECT id, (SELECT value FROM ticket_custom c WHERE c.ticket=t.id AND c.name='field_1') AS `field_1`, (SELECT value FROM ticket_custom c WHERE c.ticket=t.id AND c.name='field_2') AS `field_2` FROM ticket) AS c WHERE ...
Change History (3)
comment:1 by , 11 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 11 years ago
Ingenious!
Looks good to me. Tests pass on my side (1.0 + sqlite, 0.12 + mysql), plus a few direct testing with my own custom fields.
comment:3 by , 11 years ago
Keywords: | custom fields added |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | assigned → closed |
Thanks, Christian!
All unit and functional tests pass with SQLite 3.3.6, MySQL 5.0.95 and PostgreSQL 8.1.23. Committed in [11753].
Worked in jomae.git:ticket11140/0.12, jomae.git:ticket11140/1.0.