Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for None in mockgun when using order #364

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MHendricks
Copy link

When using mockgun if you try to use order and any of your results contain None in the ordered fields it will raise a error like this.

_mockgun.find("Shot", [], ["code"], order=[{"field_name": "description", "direction": "asc"}])

Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\unittest\case.py", line 59, in testPartExecutor
    yield
  File "C:\Program Files\Python39\lib\unittest\case.py", line 592, in run
    self._callTestMethod(testMethod)
  File "C:\Program Files\Python39\lib\unittest\case.py", line 550, in _callTestMethod
    method()
  File "C:\blur\dev\shotgun_api3\tests\test_mockgun.py", line 476, in test_ordered_filter_operator
    shots = self._mockgun.find(
  File "C:\blur\dev\shotgun_api3\shotgun_api3\lib\mockgun\mockgun.py", line 308, in find
    results = sorted(results, key=lambda k: k[order_field], reverse=desc_order)
TypeError: '<' not supported between instances of 'NoneType' and 'str'

This pull request converts most of the data types to a empty value for the data type. I wasn't sure what to use for the bool and dict datatypes so it currently doesn't handle those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant