{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/29160351","id":29160351,"diff_hunk":"@@ -49,31 +85,38 @@ def get_query_from_request(self):\n \n     def query_params_to_odm_query(self, query_params):\n         \"\"\"Convert query params to a modularodm Query object.\"\"\"\n+\n         fields_dict = query_params_to_fields(query_params)\n         if fields_dict:\n             query_parts = [\n-                Q(self.convert_key(key, value), 'eq', self.convert_value(key, value)) for key, value in fields_dict.items()\n+                Q(self.convert_key(key, value), self.get_comparison_operator(key, value), self.convert_value(key, value))\n+                for key, value in fields_dict.items() if self.is_filterable_field(key, value)\n             ]\n-            query = functools.reduce(intersect, query_parts)\n+            # TODO Ensure that if you try to filter on an invalid field, it returns a useful error.\n+            try:\n+                query = functools.reduce(intersect, query_parts)\n+            except TypeError:\n+                query = None\n         else:\n             query = None\n         return query\n \n     # Used so that that queries by _id will work\n     def convert_key(self, key, value):\n-        if key.strip() == 'id':\n-            return '_id'\n+        key = key.strip()\n+        if self.serializer_class._declared_fields[key].source:","path":"api/base/filters.py","position":93,"original_position":93,"commit_id":"3193ddf32435733b3523554a9e93c9a3c29e969d","original_commit_id":"3193ddf32435733b3523554a9e93c9a3c29e969d","user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2015-04-27T16:00:08Z","updated_at":"2015-04-27T16:00:08Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/2587#discussion_r29160351","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/29160351"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/2587#discussion_r29160351"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587","id":34071220,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/2587","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/2587.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/2587.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/2587","number":2587,"state":"open","locked":false,"title":"Feature/api v2 drf","user":{"login":"brianjgeiger","id":6599111,"avatar_url":"https://avatars.githubusercontent.com/u/6599111?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjgeiger","html_url":"https://github.com/brianjgeiger","followers_url":"https://api.github.com/users/brianjgeiger/followers","following_url":"https://api.github.com/users/brianjgeiger/following{/other_user}","gists_url":"https://api.github.com/users/brianjgeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjgeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjgeiger/subscriptions","organizations_url":"https://api.github.com/users/brianjgeiger/orgs","repos_url":"https://api.github.com/users/brianjgeiger/repos","events_url":"https://api.github.com/users/brianjgeiger/events{/privacy}","received_events_url":"https://api.github.com/users/brianjgeiger/received_events","type":"User","site_admin":false},"body":"Purpose\r\n-----------\r\nMake field-based filtering more robust and controllable.\r\n\r\nMake pointers a thing. Also: tags.\r\n\r\nChanges\r\n------------\r\n1. Added in a link for gathering the pointers from a project.\r\n2. Added in a field for tags.\r\n3. Check the field type vs. a list of known field types If the field type is on that list, then perform the type of query that makes the most sense for that field type. For example, Char fields would do 'icontains', while number-style fields and booleans would do 'eq', lists would handle list containing, and so on.  \r\n4. If it's a built-in field type, then grab the source. If the source isn't blank, use that for the field name in the query, otherwise use the name that was sent in.\r\n5. Verify that the field is available for filtering by checking self.serializer_class.filterable_fields and seeing if that field is in there. If the property doesn't exist, all fields are valid.\r\n6. Update python dateutil to current version.\r\n\r\nSide effects\r\n----------------\r\nI don't know of any side effects, but we've disabled actively setting the timezone to UTC in the Django setup, which may cause some kind of problem down the line. Or it may not.","created_at":"2015-04-24T17:56:29Z","updated_at":"2015-04-27T16:00:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c2de422bd4eae8b88f7ba4785a5bdd5b5afc2be","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/2587/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/3193ddf32435733b3523554a9e93c9a3c29e969d","head":{"label":"brianjgeiger:feature/api-v2-drf","ref":"feature/api-v2-drf","sha":"3193ddf32435733b3523554a9e93c9a3c29e969d","user":{"login":"brianjgeiger","id":6599111,"avatar_url":"https://avatars.githubusercontent.com/u/6599111?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjgeiger","html_url":"https://github.com/brianjgeiger","followers_url":"https://api.github.com/users/brianjgeiger/followers","following_url":"https://api.github.com/users/brianjgeiger/following{/other_user}","gists_url":"https://api.github.com/users/brianjgeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjgeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjgeiger/subscriptions","organizations_url":"https://api.github.com/users/brianjgeiger/orgs","repos_url":"https://api.github.com/users/brianjgeiger/repos","events_url":"https://api.github.com/users/brianjgeiger/events{/privacy}","received_events_url":"https://api.github.com/users/brianjgeiger/received_events","type":"User","site_admin":false},"repo":{"id":26919852,"name":"osf.io","full_name":"brianjgeiger/osf.io","owner":{"login":"brianjgeiger","id":6599111,"avatar_url":"https://avatars.githubusercontent.com/u/6599111?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjgeiger","html_url":"https://github.com/brianjgeiger","followers_url":"https://api.github.com/users/brianjgeiger/followers","following_url":"https://api.github.com/users/brianjgeiger/following{/other_user}","gists_url":"https://api.github.com/users/brianjgeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjgeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjgeiger/subscriptions","organizations_url":"https://api.github.com/users/brianjgeiger/orgs","repos_url":"https://api.github.com/users/brianjgeiger/repos","events_url":"https://api.github.com/users/brianjgeiger/events{/privacy}","received_events_url":"https://api.github.com/users/brianjgeiger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brianjgeiger/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/brianjgeiger/osf.io","forks_url":"https://api.github.com/repos/brianjgeiger/osf.io/forks","keys_url":"https://api.github.com/repos/brianjgeiger/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brianjgeiger/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brianjgeiger/osf.io/teams","hooks_url":"https://api.github.com/repos/brianjgeiger/osf.io/hooks","issue_events_url":"https://api.github.com/repos/brianjgeiger/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/brianjgeiger/osf.io/events","assignees_url":"https://api.github.com/repos/brianjgeiger/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/brianjgeiger/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/brianjgeiger/osf.io/tags","blobs_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brianjgeiger/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/brianjgeiger/osf.io/languages","stargazers_url":"https://api.github.com/repos/brianjgeiger/osf.io/stargazers","contributors_url":"https://api.github.com/repos/brianjgeiger/osf.io/contributors","subscribers_url":"https://api.github.com/repos/brianjgeiger/osf.io/subscribers","subscription_url":"https://api.github.com/repos/brianjgeiger/osf.io/subscription","commits_url":"https://api.github.com/repos/brianjgeiger/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/brianjgeiger/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/brianjgeiger/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/brianjgeiger/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/brianjgeiger/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brianjgeiger/osf.io/merges","archive_url":"https://api.github.com/repos/brianjgeiger/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brianjgeiger/osf.io/downloads","issues_url":"https://api.github.com/repos/brianjgeiger/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/brianjgeiger/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/brianjgeiger/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/brianjgeiger/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brianjgeiger/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/brianjgeiger/osf.io/releases{/id}","created_at":"2014-11-20T15:59:16Z","updated_at":"2015-03-04T15:27:15Z","pushed_at":"2015-04-27T15:32:40Z","git_url":"git://github.com/brianjgeiger/osf.io.git","ssh_url":"git@github.com:brianjgeiger/osf.io.git","clone_url":"https://github.com/brianjgeiger/osf.io.git","svn_url":"https://github.com/brianjgeiger/osf.io","homepage":"http://osf.io","size":85032,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:feature/api-v2-drf","ref":"feature/api-v2-drf","sha":"06844c71d694f4b479563f2ac33c3ca57db718a1","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","created_at":"2013-05-21T15:53:37Z","updated_at":"2015-04-27T14:48:22Z","pushed_at":"2015-04-27T15:32:42Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"http://osf.io","size":194846,"stargazers_count":97,"watchers_count":97,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":390,"forks":75,"open_issues":390,"watchers":97,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/2587"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/2587"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/2587/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/2587/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/3193ddf32435733b3523554a9e93c9a3c29e969d"}}}}