I have some existing code that calls values_list to query I need to use something extra to this query If I make additional calls before values_list, then additional items have gone from query after values_list, if I make an additional call after calling value_list, then it has to be affected - additional goods are not in the query.
Here are some debugger outputs before Values_list - additional - then there is:
-> Queryset = queryset.extra (select = {Field ['name']: field ['name']}) (pdb) n - & gt; Queryset = queryset.values_list (* self.get_search_columns ()) (pdb) print queries. Select some (top to bottom) as `top-bottom`, .... (pdb) n - & gt; Data = List (QuerySet) (PDB) Print queries. Select the query `data_cst`.image_measurer_id`,` data_cst` .`image_pr_top_id`, `data_target``name`,` data_recipe``` name`, `data_cst`. `AP`,` data_lot````````````````````````````````````````````````````````````````````````````` Insert `` data_strip`` `data_strip``` from` data_stat```` to `data_recipe` (include` data_cst``recipe_id` = `data_recipe`.`id`) and join` `data_lot`` (` Data_cst`.`lot_id` = `data_lot`.`id`) WHERE (` data_cst`.`date_time` & lt; = 2013-03-26 23:59:59 and `data_cst`.`date_time` & gt; 2010-03-26 00:00:00) Order `date_time` DESC by` data_ cst` But if I cancel the order, then there is absolutely no additional query:
-> Queryset = queryset.values_list (* self.get_search_columns ()) (pdb) n - & gt; Queryset = queryset.extra (select = {field ['name']: field ['name']}) (pdb) print queries Select the query `data_cst`.image_measurer_id`,` data_cst` .`image_pr_top_id`, `data_target` .`name`, `data_recipe`.`name`,` data_cst`.ep`, `data_lot`.`name`, Join `data_cst` inside` data_cst`.`tate_time`, `data_cst`.`bottom` (` data_cst` .`target_name_id` = `data_target``id`) join` data_reip` at INNER ( `Data_cst` .`RIPI_ID` =` data_press_``````````) join inner 'data_lot` on current (`data_cst`.` Lot_id` = `data_lot````````````) WHERE (`Data_cst` .`date_time` & lt; = 2013-03-26 23:59:59 and` data_cst`.`date_time`> = 2010-03-26 00:00:00) `data_cst` .date_time Order-n - & gt; by DESC (PDB) Data = List (QuerySet) (PDB) Print queries. Select the query `data_cst`.image_measurer_id`,` data_cst` .`image_pr_top_id`, `data_target``name`,` data_recipe``` name`, `data_cst`. `AP`,` data_lot````````````````````````````````````````````````````````````````````````````` Insert `` data_strip`` `data_strip``` from` data_stat```` to `data_recipe` (include` data_cst``recipe_id` = `data_recipe`.`id`) and join` `data_lot`` (` Data_cst`.`lot_id` = `data_lot`.`id`) WHERE (` data_cst`.`date_time` & lt; = 2013-03-26 23:59:59 and `data_cst`.`date_time` & gt; 2010-03-26 00:00:00) Order `date_time` DESC by` data_ cst` Is there a way to use both values_list and additional on the same query?
Here is a very simple example showing that this is not working: .
(PDB) CST.objects.all () additional (selection = {'EP': 1}). Values_list ('image_measurer_id') [(86456L), (86454L), (86452L), (86450L), (86448L), (86446L), (86444L), (86442L,), (86440L, ), (86438L), (86436L), (86434L), (86432L), (86430L), (86428L), (86426L), (86424L), (86422L), (86420L, ), (86418L,), '... (decreased remaining element) ...'] It should return 2 columns per line.
You must include your additional selection in values_list.
Example
CST.objects.extra (select = {'ep': 1}) values_list ('image_measurer_id', 'ep')
No comments:
Post a Comment