diff --git a/ftrack_query/__init__.py b/ftrack_query/__init__.py index ae724a0..88c04e4 100644 --- a/ftrack_query/__init__.py +++ b/ftrack_query/__init__.py @@ -8,7 +8,7 @@ __all__ = ['FTrackQuery', 'entity', 'and_', 'or_', 'not_', 'event'] -__version__ = '1.6.2' +__version__ = '1.6.3' import ftrack_api diff --git a/ftrack_query/query.py b/ftrack_query/query.py index a94e5c7..e040b91 100644 --- a/ftrack_query/query.py +++ b/ftrack_query/query.py @@ -229,12 +229,22 @@ def __call__(self, *args, **kwargs): In rare cases, it can be valid to pass in a single argument, such as User('username'). The inspiration for this was taken from the old API. + As the FTrack database is case insensitive, in the case of + multiple results, use Python to find the exact match. """ if self._entity in self._PrimaryKeys and len(args) == 1 and not kwargs: + key = self._PrimaryKeys[self._entity] + value = args[0] try: - return self.where(**{self._PrimaryKeys[self._entity]: args[0]}).one() + return self.where(**{key: value}).one() except ftrack_api.exception.NoResultFoundError: return None + except ftrack_api.exception.MultipleResultsFoundError: + for result in self.where(**{key: value}): + if result[key] == value: + return result + raise + raise TypeError("'Query' object is not callable, " "perhaps you meant to use 'Query.where()'?")