예제 #1
0
    def to_sql_filter(self):
        if self.show_all:
            return None
        if self.is_null:
            return ISNULLFilter(self.filter['field'])

        in_filter = INFilter(
            self.filter['field'],
            get_INFilter_bindparams(self.filter['slug'], self.value))
        if self._ancestor_filter:
            return ANDFilter([self._ancestor_filter.sql_filter(), in_filter])
        else:
            return in_filter
예제 #2
0
    def to_sql_filter(self):
        if self.show_all:
            return None

        in_filter = INFilter(
            self.filter['field'],
            get_INFilter_bindparams(self.filter['slug'],
                                    [None] if self.show_none else self.value))

        if self._ancestor_filter:
            return ANDFilter([self._ancestor_filter.sql_filter(), in_filter])
        else:
            return in_filter
예제 #3
0
    def to_sql_filter(self):
        if self.show_all:
            return None

        sql_filters = []

        non_null_values = self._get_value_without_nulls()
        if non_null_values:
            in_filter = INFilter(
                self.filter['field'],
                get_INFilter_bindparams(self.filter['slug'], non_null_values)
            )
            if self._ancestor_filter:
                sql_filters.append(ANDFilter([
                    self._ancestor_filter.sql_filter(),
                    in_filter,
                ]))
            else:
                sql_filters.append(in_filter)
        elif self._ancestor_filter:
            sql_filters.append(self._ancestor_filter.sql_filter())

        if self.is_null:
            # combine null and blank fields into a single filter
            sql_filters.append(
                ORFilter([
                    ISNULLFilter(self.filter['field']),
                    EQFilter(self.filter['field'], get_null_empty_value_bindparam(self.filter['slug'])),
                ])
            )

        if len(sql_filters) > 1:
            return ORFilter(
                sql_filters
            )
        else:
            return sql_filters[0]
예제 #4
0
 def to_sql_filter(self):
     return ANDFilter([
         GTEFilter(self.filter.field, self.startdate_slug),
         LTFilter(self.filter.field, self.enddate_slug)
     ])