2368
2368
"BugTask.datecreated > %s" % (
2369
2369
sqlvalues(params.created_since,)))
2371
orderby_arg, extra_joins = self._processOrderBy(params)
2372
join_tables.extend(extra_joins)
2371
2374
query = " AND ".join(extra_clauses)
2373
2376
if not decorators:
2384
2387
with_clause = None
2386
query, clauseTables, decorator, join_tables,
2389
query, clauseTables, orderby_arg, decorator, join_tables,
2387
2390
has_duplicate_results, with_clause)
2389
2392
def buildUpstreamClause(self, params):
2641
2644
SpecificationBug.specification %s)
2642
2645
""" % search_value_to_where_condition(linked_blueprints)
2644
def buildOrigin(self, join_tables, prejoin_tables, clauseTables,
2645
start_with=BugTask):
2647
def buildOrigin(self, join_tables, prejoin_tables, clauseTables):
2646
2648
"""Build the parameter list for Store.using().
2648
2650
:param join_tables: A sequence of tables that should be joined
2661
2663
and in clauseTables. This method ensures that each table
2662
2664
appears exactly once in the returned sequence.
2664
origin = [start_with]
2665
2667
already_joined = set(origin)
2666
2668
for table, join in join_tables:
2667
2669
if table is None or table not in already_joined:
2689
2691
:param args: optional additional BugTaskSearchParams instances,
2691
2693
orig_store = store = IStore(BugTask)
2692
[query, clauseTables, bugtask_decorator, join_tables,
2694
[query, clauseTables, orderby, bugtask_decorator, join_tables,
2693
2695
has_duplicate_results, with_clause] = self.buildQuery(params)
2694
2696
if with_clause:
2695
2697
store = store.with_(with_clause)
2696
orderby_expression, orderby_joins = self._processOrderBy(params)
2697
2698
if len(args) == 0:
2698
2699
if has_duplicate_results:
2699
2700
origin = self.buildOrigin(join_tables, [], clauseTables)
2700
outer_origin = self.buildOrigin(
2701
orderby_joins, prejoins, [])
2701
outer_origin = self.buildOrigin([], prejoins, [])
2702
2702
subquery = Select(BugTask.id, where=SQL(query), tables=origin)
2703
2703
resultset = store.using(*outer_origin).find(
2704
2704
resultrow, In(BugTask.id, subquery))
2706
origin = self.buildOrigin(
2707
join_tables + orderby_joins, prejoins, clauseTables)
2706
origin = self.buildOrigin(join_tables, prejoins, clauseTables)
2708
2707
resultset = store.using(*origin).find(resultrow, query)
2710
2709
decorator = lambda row: bugtask_decorator(row[0])
2712
2711
decorator = bugtask_decorator
2714
resultset.order_by(orderby_expression)
2713
resultset.order_by(orderby)
2715
2714
return DecoratedResultSet(resultset, result_decorator=decorator,
2716
2715
pre_iter_hook=pre_iter_hook)
2722
2721
decorators = [bugtask_decorator]
2723
2722
for arg in args:
2724
[query, clauseTables, decorator, join_tables,
2723
[query, clauseTables, ignore, decorator, join_tables,
2725
2724
has_duplicate_results, with_clause] = self.buildQuery(arg)
2726
2725
origin = self.buildOrigin(join_tables, [], clauseTables)
2727
2726
localstore = store
2746
2745
bugtask = decorator(bugtask)
2749
origin = self.buildOrigin(
2750
orderby_joins, prejoins, [],
2751
start_with=Alias(resultset._get_select(), "BugTask"))
2748
origin = [Alias(resultset._get_select(), "BugTask")]
2750
origin += [join for table, join in prejoins]
2753
2751
decorator = prejoin_decorator
2755
2753
decorator = simple_decorator
2757
2755
result = store.using(*origin).find(resultrow)
2758
result.order_by(orderby_expression)
2756
result.order_by(orderby)
2759
2757
return DecoratedResultSet(result, result_decorator=decorator,
2760
2758
pre_iter_hook=pre_iter_hook)