typo/doc updates, destructure namedtuple manually

may lead to less problems in the future,
in case the order of the rangetuple
chagnes
This commit is contained in:
seanbreckenridge 2021-04-05 17:55:28 -07:00
parent 4af2b8e4df
commit 28fd9e4441

View file

@ -203,7 +203,7 @@ def _create_range_filter(
the value to compare the range boundaries to. typically generated by _generate_order_by_func the value to compare the range boundaries to. typically generated by _generate_order_by_func
To force the values you're sorting by to be in some specified type, To force the values you're sorting by to be in some specified type,
this allows a 'conversion_func, which optionally converts the value this allows a 'value_coercion_func', which optionally converts the value
returned by attr_func to some shared type (see _datelike_to_float for an example) returned by attr_func to some shared type (see _datelike_to_float for an example)
""" """
@ -217,8 +217,9 @@ def _create_range_filter(
if rn is None: if rn is None:
return None return None
# destructure namedtuple after = rn.after
(after, before, within) = rn before = rn.before
within = rn.within
# hmm... not sure how to correctly manage # hmm... not sure how to correctly manage
# inclusivity here? Is [after, before) currently, # inclusivity here? Is [after, before) currently,
@ -351,15 +352,17 @@ Specify a type or a key to order the value by""")
# (seems like a lot?) # (seems like a lot?)
raise QueryException("Sorting by custom types is currently unsupported") raise QueryException("Sorting by custom types is currently unsupported")
# use the created filter function in select (could be None if the user specified a RangeTuple # use the created filter function
# like (None, None, None) somehow, but select handles that case
# apply leftover arguments from the user (limit, reverse)
# we've already applied drop_exceptions and kwargs related to unsortable values above # we've already applied drop_exceptions and kwargs related to unsortable values above
itr = select(itr, where=filter_func, limit=limit, reverse=reverse) itr = select(itr, where=filter_func, limit=limit, reverse=reverse)
else: else:
# wrap_unsorted may be used here if the user is just specifying an order_key # wrap_unsorted may be used here if the user specified an order_key,
# and nothing else to order or filter range by # or manually passed a order_value function
# i.e. none of the range-related code ran, this is just a select with a key #
# this select is also run if the user didn't specify anything to
# order by, and is just returning the data in the same order as
# as the srouce iterable
# i.e. none of the range-related filtering code ran, this is just a select
itr = select(itr, itr = select(itr,
order_by=order_by_chosen, order_by=order_by_chosen,
wrap_unsorted=wrap_unsorted, wrap_unsorted=wrap_unsorted,