Skip to content

Commit

Permalink
Выдавать предупреждение, когда в фильтрах используют None
Browse files Browse the repository at this point in the history
Поправить использование warinings.warn

Fixes #223
  • Loading branch information
leshchenko1979 committed Mar 20, 2024
1 parent 88985ad commit c811d60
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions fast_bitrix24/user_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def standardized_params(self, p):
p = {key.upper().strip(): value for key, value in p.items()}
self.check_expected_clause_types(p)

if "FILTER" in p and None in p["FILTER"].values():
warnings.warn(
"Using None as filter value confuses Bitrix. "
"Try using an empty string, 'null' or 'false'.",
UserWarning,
stacklevel=2,
)

return p

def check_expected_clause_types(self, p):
Expand Down Expand Up @@ -176,6 +184,7 @@ def dedup_results(self):
f"Number of results returned ({len(self.results)}) "
f"doesn't equal 'total' from the server reply ({self.total})",
RuntimeWarning,
stacklevel=4,
)


Expand Down Expand Up @@ -305,8 +314,12 @@ def __init__(self, bitrix, method_branch: str, ID_field_name: str = "ID"):
self.method_branch = method_branch
self.ID_field_name = ID_field_name

logger.warning(
"list_and_get(): 'ListAndGetUserRequest' is deprecated. Use 'get_all()' instead."
warnings.warn(
"list_and_get() is deprecated. It's not efficient to use it "
"now that exceeding Bitrix request rate limitations gets users "
"heavily penalised. Use 'get_all()' instead.",
DeprecationWarning,
stacklevel=2,
)

@icontract.require(
Expand Down

0 comments on commit c811d60

Please sign in to comment.