{"action":"opened","number":6943,"pull_request":{"url":"https://api.github.com/repos/Automattic/mongoose/pulls/6943","id":211897085,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExODk3MDg1","html_url":"https://github.com/Automattic/mongoose/pull/6943","diff_url":"https://github.com/Automattic/mongoose/pull/6943.diff","patch_url":"https://github.com/Automattic/mongoose/pull/6943.patch","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/6943","number":6943,"state":"open","locked":false,"title":"Fixes #6927 making number.castForQuery return a CastError","user":{"login":"lineus","id":6015453,"node_id":"MDQ6VXNlcjYwMTU0NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/6015453?v=4","gravatar_id":"","url":"https://api.github.com/users/lineus","html_url":"https://github.com/lineus","followers_url":"https://api.github.com/users/lineus/followers","following_url":"https://api.github.com/users/lineus/following{/other_user}","gists_url":"https://api.github.com/users/lineus/gists{/gist_id}","starred_url":"https://api.github.com/users/lineus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lineus/subscriptions","organizations_url":"https://api.github.com/users/lineus/orgs","repos_url":"https://api.github.com/users/lineus/repos","events_url":"https://api.github.com/users/lineus/events{/privacy}","received_events_url":"https://api.github.com/users/lineus/received_events","type":"User","site_admin":false},"body":"<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->\r\n\r\nAs demonstrated in #6927, when a conditional operator is used that doesn't exist in mongodb a regular error is thrown. This change throws a cast error instead.\r\n\r\n<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->\r\n\r\nadded a failing test, made it pass, all current tests pass:\r\n```\r\nmongoose>: npm test -- -g gh-6927\r\n\r\n> mongoose@5.2.11-pre test /Users/lineus/dev/opc/mongoose\r\n> mocha --exit test/*.test.js test/**/*.test.js \"-g\" \"gh-6927\"\r\n\r\n\r\n You're not testing shards!\r\n Please set the MONGOOSE_SHARD_TEST_URI env variable.\r\n e.g: `mongodb://localhost:27017/database\r\n Sharding must already be enabled on your database\r\n\r\n\r\n  !\r\n\r\n  0 passing (101ms)\r\n  1 failing\r\n\r\n  1) types.number\r\n       throws a CastError with a bad conditional (gh-6927):\r\n\r\n      AssertionError [ERR_ASSERTION]: false == true\r\n      + expected - actual\r\n\r\n      -false\r\n      +true\r\n\r\n      at Context.<anonymous> (test/types.number.test.js:122:12)\r\n\r\n\r\n\r\nnpm ERR! Test failed.  See above for more details.\r\nmongoose>: npm test -- -g gh-6927\r\n\r\n> mongoose@5.2.11-pre test /Users/lineus/dev/opc/mongoose\r\n> mocha --exit test/*.test.js test/**/*.test.js \"-g\" \"gh-6927\"\r\n\r\n\r\n You're not testing shards!\r\n Please set the MONGOOSE_SHARD_TEST_URI env variable.\r\n e.g: `mongodb://localhost:27017/database\r\n Sharding must already be enabled on your database\r\n\r\n\r\n  ․\r\n\r\n  1 passing (110ms)\r\n\r\nmongoose>: npm test\r\n\r\n> mongoose@5.2.11-pre test /Users/lineus/dev/opc/mongoose\r\n> mocha --exit test/*.test.js test/**/*.test.js\r\n\r\n\r\n You're not testing shards!\r\n Please set the MONGOOSE_SHARD_TEST_URI env variable.\r\n e.g: `mongodb://localhost:27017/database\r\n Sharding must already be enabled on your database\r\n\r\n\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․,,․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․,,,․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․,,,․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․,,,,,,,,․․․․․․․․․․․․․․․․․․․․․․․․․․․․,․․,․․,․,,․․,․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․,,․․․․․․․․․․․․,,․․․․․․,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n  ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․,․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․,,․․․․․․․․․․․․․․․․․․\r\n  ․․․․․,,․․․․․․․․․․․․․․․․․․․․․․․,․․․․․․․․,․,․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․,․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․\r\n  ․․․․․․․․․․․․․․․․․․,,,,,,,,,․․․․․․․․․․․․․․․․․․․․․․\r\n\r\n  1878 passing (49s)\r\n  163 pending\r\n\r\nmongoose>:\r\n```\r\n\r\n<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->\r\n","created_at":"2018-08-29T21:47:16Z","updated_at":"2018-08-29T21:47:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/mongoose/pulls/6943/commits","review_comments_url":"https://api.github.com/repos/Automattic/mongoose/pulls/6943/comments","review_comment_url":"https://api.github.com/repos/Automattic/mongoose/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/6943/comments","statuses_url":"https://api.github.com/repos/Automattic/mongoose/statuses/ab6fff48ff5da7de4c8fa8670a754c1475594091","head":{"label":"lineus:fix-6927","ref":"fix-6927","sha":"ab6fff48ff5da7de4c8fa8670a754c1475594091","user":{"login":"lineus","id":6015453,"node_id":"MDQ6VXNlcjYwMTU0NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/6015453?v=4","gravatar_id":"","url":"https://api.github.com/users/lineus","html_url":"https://github.com/lineus","followers_url":"https://api.github.com/users/lineus/followers","following_url":"https://api.github.com/users/lineus/following{/other_user}","gists_url":"https://api.github.com/users/lineus/gists{/gist_id}","starred_url":"https://api.github.com/users/lineus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lineus/subscriptions","organizations_url":"https://api.github.com/users/lineus/orgs","repos_url":"https://api.github.com/users/lineus/repos","events_url":"https://api.github.com/users/lineus/events{/privacy}","received_events_url":"https://api.github.com/users/lineus/received_events","type":"User","site_admin":false},"repo":{"id":121454633,"node_id":"MDEwOlJlcG9zaXRvcnkxMjE0NTQ2MzM=","name":"mongoose","full_name":"lineus/mongoose","owner":{"login":"lineus","id":6015453,"node_id":"MDQ6VXNlcjYwMTU0NTM=","avatar_url":"https://avatars3.githubusercontent.com/u/6015453?v=4","gravatar_id":"","url":"https://api.github.com/users/lineus","html_url":"https://github.com/lineus","followers_url":"https://api.github.com/users/lineus/followers","following_url":"https://api.github.com/users/lineus/following{/other_user}","gists_url":"https://api.github.com/users/lineus/gists{/gist_id}","starred_url":"https://api.github.com/users/lineus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lineus/subscriptions","organizations_url":"https://api.github.com/users/lineus/orgs","repos_url":"https://api.github.com/users/lineus/repos","events_url":"https://api.github.com/users/lineus/events{/privacy}","received_events_url":"https://api.github.com/users/lineus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lineus/mongoose","description":"MongoDB object modeling designed to work in an asynchronous environment.","fork":true,"url":"https://api.github.com/repos/lineus/mongoose","forks_url":"https://api.github.com/repos/lineus/mongoose/forks","keys_url":"https://api.github.com/repos/lineus/mongoose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lineus/mongoose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lineus/mongoose/teams","hooks_url":"https://api.github.com/repos/lineus/mongoose/hooks","issue_events_url":"https://api.github.com/repos/lineus/mongoose/issues/events{/number}","events_url":"https://api.github.com/repos/lineus/mongoose/events","assignees_url":"https://api.github.com/repos/lineus/mongoose/assignees{/user}","branches_url":"https://api.github.com/repos/lineus/mongoose/branches{/branch}","tags_url":"https://api.github.com/repos/lineus/mongoose/tags","blobs_url":"https://api.github.com/repos/lineus/mongoose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lineus/mongoose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lineus/mongoose/git/refs{/sha}","trees_url":"https://api.github.com/repos/lineus/mongoose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lineus/mongoose/statuses/{sha}","languages_url":"https://api.github.com/repos/lineus/mongoose/languages","stargazers_url":"https://api.github.com/repos/lineus/mongoose/stargazers","contributors_url":"https://api.github.com/repos/lineus/mongoose/contributors","subscribers_url":"https://api.github.com/repos/lineus/mongoose/subscribers","subscription_url":"https://api.github.com/repos/lineus/mongoose/subscription","commits_url":"https://api.github.com/repos/lineus/mongoose/commits{/sha}","git_commits_url":"https://api.github.com/repos/lineus/mongoose/git/commits{/sha}","comments_url":"https://api.github.com/repos/lineus/mongoose/comments{/number}","issue_comment_url":"https://api.github.com/repos/lineus/mongoose/issues/comments{/number}","contents_url":"https://api.github.com/repos/lineus/mongoose/contents/{+path}","compare_url":"https://api.github.com/repos/lineus/mongoose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lineus/mongoose/merges","archive_url":"https://api.github.com/repos/lineus/mongoose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lineus/mongoose/downloads","issues_url":"https://api.github.com/repos/lineus/mongoose/issues{/number}","pulls_url":"https://api.github.com/repos/lineus/mongoose/pulls{/number}","milestones_url":"https://api.github.com/repos/lineus/mongoose/milestones{/number}","notifications_url":"https://api.github.com/repos/lineus/mongoose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lineus/mongoose/labels{/name}","releases_url":"https://api.github.com/repos/lineus/mongoose/releases{/id}","deployments_url":"https://api.github.com/repos/lineus/mongoose/deployments","created_at":"2018-02-14T00:46:55Z","updated_at":"2018-08-24T18:14:29Z","pushed_at":"2018-08-29T21:45:17Z","git_url":"git://github.com/lineus/mongoose.git","ssh_url":"git@github.com:lineus/mongoose.git","clone_url":"https://github.com/lineus/mongoose.git","svn_url":"https://github.com/lineus/mongoose","homepage":"http://mongoosejs.com","size":41773,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"62f9d6fac95abfb82b760414cf386185d2b25398","user":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":597879,"node_id":"MDEwOlJlcG9zaXRvcnk1OTc4Nzk=","name":"mongoose","full_name":"Automattic/mongoose","owner":{"login":"Automattic","id":887802,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg4NzgwMg==","avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/mongoose","description":"MongoDB object modeling designed to work in an asynchronous environment.","fork":false,"url":"https://api.github.com/repos/Automattic/mongoose","forks_url":"https://api.github.com/repos/Automattic/mongoose/forks","keys_url":"https://api.github.com/repos/Automattic/mongoose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/mongoose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/mongoose/teams","hooks_url":"https://api.github.com/repos/Automattic/mongoose/hooks","issue_events_url":"https://api.github.com/repos/Automattic/mongoose/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/mongoose/events","assignees_url":"https://api.github.com/repos/Automattic/mongoose/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/mongoose/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/mongoose/tags","blobs_url":"https://api.github.com/repos/Automattic/mongoose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/mongoose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/mongoose/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/mongoose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/mongoose/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/mongoose/languages","stargazers_url":"https://api.github.com/repos/Automattic/mongoose/stargazers","contributors_url":"https://api.github.com/repos/Automattic/mongoose/contributors","subscribers_url":"https://api.github.com/repos/Automattic/mongoose/subscribers","subscription_url":"https://api.github.com/repos/Automattic/mongoose/subscription","commits_url":"https://api.github.com/repos/Automattic/mongoose/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/mongoose/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/mongoose/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/mongoose/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/mongoose/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/mongoose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/mongoose/merges","archive_url":"https://api.github.com/repos/Automattic/mongoose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/mongoose/downloads","issues_url":"https://api.github.com/repos/Automattic/mongoose/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/mongoose/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/mongoose/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/mongoose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/mongoose/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/mongoose/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/mongoose/deployments","created_at":"2010-04-06T21:39:05Z","updated_at":"2018-08-29T19:54:30Z","pushed_at":"2018-08-29T21:32:06Z","git_url":"git://github.com/Automattic/mongoose.git","ssh_url":"git@github.com:Automattic/mongoose.git","clone_url":"https://github.com/Automattic/mongoose.git","svn_url":"https://github.com/Automattic/mongoose","homepage":"http://mongoosejs.com","size":43188,"stargazers_count":16708,"watchers_count":16708,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2431,"mirror_url":null,"archived":false,"open_issues_count":318,"license":null,"forks":2431,"open_issues":318,"watchers":16708,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/mongoose/pulls/6943"},"html":{"href":"https://github.com/Automattic/mongoose/pull/6943"},"issue":{"href":"https://api.github.com/repos/Automattic/mongoose/issues/6943"},"comments":{"href":"https://api.github.com/repos/Automattic/mongoose/issues/6943/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/mongoose/pulls/6943/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/mongoose/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/mongoose/pulls/6943/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/mongoose/statuses/ab6fff48ff5da7de4c8fa8670a754c1475594091"}},"author_association":"COLLABORATOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":12,"deletions":1,"changed_files":2}}
{"actor":{"display_login":"lineus"}}