tickets_full: 3355

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
3355 2007-01-23 16:19:20 2007-07-16 17:26:42 2019-06-24 00:50:59.248159 Accepted closed Database layer (models, ORM)     master invalid filter() with related table stomps on extra(tables) I started a discussion here with no responses so I thought I'd file a bug so this doesn't get lost... Summary: If you're using extra() to specify extra tables to add to your query AND you're using filter() with a related table, the extra() table gets lost. Example (also found in the above message): This correctly adds "page_item" to the FROM clause by using extra(). Notice I'm not yet referencing a related table in the filter() clause since template_id is contained in the Page object. {{{ In [29]: Page.objects.extra( tables=['page_item'], where=['']) .filter(template__id='1')._get_sql_clause() Out[29]: (['`page_page`.`id`', '`page_page`.`number`', '`page_page`.`title`', '`page_page`.`template_id`', '`page_page`.`description`'], ' FROM `page_page` , `page_item` WHERE AND (`page_page`.`template_id` = %s)', ['1']) }}} But adding the related table lookup for the 'name' column in the filter() clause breaks the extra() tables and "page_item" disappears... {{{ In [30]: Page.objects.extra( tables=['page_item'], where=['']) .filter(template__name='Default Template') ._get_sql_clause() Out[30]: (['`page_page`.`id`', '`page_page`.`number`', '`page_page`.`title`', '`page_page`.`template_id`', '`page_page`.`description`'], ' FROM `page_page` INNER JOIN `page_template` AS `page_page__template` ON `page_page`.`template_id` = `page_page__template`.`id` , `page_item` WHERE AND (`page_page__template`.`name` = %s)', ['Default Template']) }}} adrian Rob Hudson <>   0 0 0 0 0 0
Powered by Datasette · Query took 2.532ms