Skip to content

SG-37203 Support for None in mockgun when using order#364

Closed
MHendricks wants to merge 1 commit into
shotgunsoftware:masterfrom
blurstudio-forks:MHendricks-mockgun_fixes
Closed

SG-37203 Support for None in mockgun when using order#364
MHendricks wants to merge 1 commit into
shotgunsoftware:masterfrom
blurstudio-forks:MHendricks-mockgun_fixes

Conversation

@MHendricks
Copy link
Copy Markdown

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.

@carlos-villavicencio-adsk carlos-villavicencio-adsk changed the title Support for None in mockgun when using order SG-37203 Support for None in mockgun when using order Apr 11, 2025
carlos-villavicencio-adsk added a commit that referenced this pull request Apr 11, 2025
carlos-villavicencio-adsk added a commit that referenced this pull request Apr 14, 2025
* Apply #217

* Fix dict

* Apply #376

* Apply #364
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