{"action":"created","comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/80370110","id":80370110,"diff_hunk":"@@ -484,3 +485,59 @@ def lock_wait():\n         updated_person = Person.objects.get(first_name='John')\n         self.assertGreater(after_update - before_start, timedelta(seconds=0.5))\n         self.assertEqual(updated_person.last_name, 'NotLennon')\n+\n+\n+class InvalidCreateArgumentsTests(SimpleTestCase):\n+    msg = \"Invalid field name(s) for model Thing: 'nonexistent'.\"\n+\n+    def test_get_or_create_with_invalid_defaults(self):\n+        with self.assertRaisesMessage(FieldError, self.msg):\n+            Thing.objects.get_or_create(name='a', defaults={'nonexistent': 'b'})\n+\n+    def test_get_or_create_with_invalid_kwargs(self):\n+        with self.assertRaisesMessage(FieldError, self.msg):\n+            Thing.objects.get_or_create(name='a', nonexistent='b')\n+\n+    def test_update_or_create_with_invalid_defaults(self):\n+        with self.assertRaisesMessage(FieldError, self.msg):\n+            Thing.objects.update_or_create(name='a', defaults={'nonexistent': 'b'})\n+\n+    def test_update_or_create_with_invalid_kwargs(self):\n+        with self.assertRaisesMessage(FieldError, self.msg):\n+            Thing.objects.update_or_create(name='a', nonexistent='b')\n+\n+    def test_update_or_create_multiple_invalid_kwargs(self):\n+        with self.assertRaisesMessage(FieldError, \"Invalid field name(s) for model Thing:\") as cm:\n+            Thing.objects.update_or_create(name='a', nonexistent='b', invalid='c')\n+        self.assertIn('nonexistent', str(cm.exception))\n+        self.assertIn('invalid', str(cm.exception))\n+\n+    def test_update_or_create_multiple_invalid_defaults(self):","path":"tests/get_or_create/tests.py","position":43,"original_position":43,"commit_id":"3d0b8ef4943bb06360ca85723c2c77ed0241ff92","original_commit_id":"3d0b8ef4943bb06360ca85723c2c77ed0241ff92","user":{"login":"timgraham","id":411869,"avatar_url":"https://avatars.githubusercontent.com/u/411869?v=3","gravatar_id":"","url":"https://api.github.com/users/timgraham","html_url":"https://github.com/timgraham","followers_url":"https://api.github.com/users/timgraham/followers","following_url":"https://api.github.com/users/timgraham/following{/other_user}","gists_url":"https://api.github.com/users/timgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/timgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timgraham/subscriptions","organizations_url":"https://api.github.com/users/timgraham/orgs","repos_url":"https://api.github.com/users/timgraham/repos","events_url":"https://api.github.com/users/timgraham/events{/privacy}","received_events_url":"https://api.github.com/users/timgraham/received_events","type":"User","site_admin":false},"body":"I don't think the test cases need to be duplicated for every case. I was actually more interested to check that the field name joining that adds the comma works fine. You can do `join(sorted(invalid_params))` to make the message deterministic. Go ahead and squash commits too. Thanks!","created_at":"2016-09-24T22:37:34Z","updated_at":"2016-09-24T22:37:34Z","html_url":"https://github.com/django/django/pull/7255#discussion_r80370110","pull_request_url":"https://api.github.com/repos/django/django/pulls/7255","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/80370110"},"html":{"href":"https://github.com/django/django/pull/7255#discussion_r80370110"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/7255"}}},"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/7255","id":85630765,"html_url":"https://github.com/django/django/pull/7255","diff_url":"https://github.com/django/django/pull/7255.diff","patch_url":"https://github.com/django/django/pull/7255.patch","issue_url":"https://api.github.com/repos/django/django/issues/7255","number":7255,"state":"open","locked":false,"title":"Fixed #27118 -- Made get_or_create()/update_or_create() error for a non-field in defaults.","user":{"login":"francoisfreitag","id":2758243,"avatar_url":"https://avatars.githubusercontent.com/u/2758243?v=3","gravatar_id":"","url":"https://api.github.com/users/francoisfreitag","html_url":"https://github.com/francoisfreitag","followers_url":"https://api.github.com/users/francoisfreitag/followers","following_url":"https://api.github.com/users/francoisfreitag/following{/other_user}","gists_url":"https://api.github.com/users/francoisfreitag/gists{/gist_id}","starred_url":"https://api.github.com/users/francoisfreitag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/francoisfreitag/subscriptions","organizations_url":"https://api.github.com/users/francoisfreitag/orgs","repos_url":"https://api.github.com/users/francoisfreitag/repos","events_url":"https://api.github.com/users/francoisfreitag/events{/privacy}","received_events_url":"https://api.github.com/users/francoisfreitag/received_events","type":"User","site_admin":false},"body":"Specifying an incorrect field in the `get_or_create` / `update_or_create` should not fail silently because it is likely a programming error.\r\n\r\nFor more details, see https://code.djangoproject.com/ticket/27118.\r\n\r\nAs Tim noted, this is a backward-incompatible change. If a smoother landing of this feature seems like a better option, we could first raise a warning then turn it into an error in a next version.\r\n\r\nThis solution covers for incorrect defaults and incorrect exact keyword arguments (without `LOOKUP_SEP`) that would be used for the model creation. It does not cover invalid non-exact lookups such as `does_not_exist__icontains`.\r\n\r\nI would not document this change outside of the changelog as I would have expected Django to tell me if my defaults / fields lookups were incorrect, but it could help some users if an error pops out during a version upgrade. What do you think?","created_at":"2016-09-16T19:56:54Z","updated_at":"2016-09-24T22:37:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"905a43f190fdccbcee097859d388c5db75303e20","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/django/django/pulls/7255/commits","review_comments_url":"https://api.github.com/repos/django/django/pulls/7255/comments","review_comment_url":"https://api.github.com/repos/django/django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/django/django/issues/7255/comments","statuses_url":"https://api.github.com/repos/django/django/statuses/3d0b8ef4943bb06360ca85723c2c77ed0241ff92","head":{"label":"francoisfreitag:27118/error_for_non_field_in_x_or_create_defaults","ref":"27118/error_for_non_field_in_x_or_create_defaults","sha":"3d0b8ef4943bb06360ca85723c2c77ed0241ff92","user":{"login":"francoisfreitag","id":2758243,"avatar_url":"https://avatars.githubusercontent.com/u/2758243?v=3","gravatar_id":"","url":"https://api.github.com/users/francoisfreitag","html_url":"https://github.com/francoisfreitag","followers_url":"https://api.github.com/users/francoisfreitag/followers","following_url":"https://api.github.com/users/francoisfreitag/following{/other_user}","gists_url":"https://api.github.com/users/francoisfreitag/gists{/gist_id}","starred_url":"https://api.github.com/users/francoisfreitag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/francoisfreitag/subscriptions","organizations_url":"https://api.github.com/users/francoisfreitag/orgs","repos_url":"https://api.github.com/users/francoisfreitag/repos","events_url":"https://api.github.com/users/francoisfreitag/events{/privacy}","received_events_url":"https://api.github.com/users/francoisfreitag/received_events","type":"User","site_admin":false},"repo":{"id":48332638,"name":"django","full_name":"francoisfreitag/django","owner":{"login":"francoisfreitag","id":2758243,"avatar_url":"https://avatars.githubusercontent.com/u/2758243?v=3","gravatar_id":"","url":"https://api.github.com/users/francoisfreitag","html_url":"https://github.com/francoisfreitag","followers_url":"https://api.github.com/users/francoisfreitag/followers","following_url":"https://api.github.com/users/francoisfreitag/following{/other_user}","gists_url":"https://api.github.com/users/francoisfreitag/gists{/gist_id}","starred_url":"https://api.github.com/users/francoisfreitag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/francoisfreitag/subscriptions","organizations_url":"https://api.github.com/users/francoisfreitag/orgs","repos_url":"https://api.github.com/users/francoisfreitag/repos","events_url":"https://api.github.com/users/francoisfreitag/events{/privacy}","received_events_url":"https://api.github.com/users/francoisfreitag/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/francoisfreitag/django","description":"The Web framework for perfectionists with deadlines.","fork":true,"url":"https://api.github.com/repos/francoisfreitag/django","forks_url":"https://api.github.com/repos/francoisfreitag/django/forks","keys_url":"https://api.github.com/repos/francoisfreitag/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/francoisfreitag/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/francoisfreitag/django/teams","hooks_url":"https://api.github.com/repos/francoisfreitag/django/hooks","issue_events_url":"https://api.github.com/repos/francoisfreitag/django/issues/events{/number}","events_url":"https://api.github.com/repos/francoisfreitag/django/events","assignees_url":"https://api.github.com/repos/francoisfreitag/django/assignees{/user}","branches_url":"https://api.github.com/repos/francoisfreitag/django/branches{/branch}","tags_url":"https://api.github.com/repos/francoisfreitag/django/tags","blobs_url":"https://api.github.com/repos/francoisfreitag/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/francoisfreitag/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/francoisfreitag/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/francoisfreitag/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/francoisfreitag/django/statuses/{sha}","languages_url":"https://api.github.com/repos/francoisfreitag/django/languages","stargazers_url":"https://api.github.com/repos/francoisfreitag/django/stargazers","contributors_url":"https://api.github.com/repos/francoisfreitag/django/contributors","subscribers_url":"https://api.github.com/repos/francoisfreitag/django/subscribers","subscription_url":"https://api.github.com/repos/francoisfreitag/django/subscription","commits_url":"https://api.github.com/repos/francoisfreitag/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/francoisfreitag/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/francoisfreitag/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/francoisfreitag/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/francoisfreitag/django/contents/{+path}","compare_url":"https://api.github.com/repos/francoisfreitag/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/francoisfreitag/django/merges","archive_url":"https://api.github.com/repos/francoisfreitag/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/francoisfreitag/django/downloads","issues_url":"https://api.github.com/repos/francoisfreitag/django/issues{/number}","pulls_url":"https://api.github.com/repos/francoisfreitag/django/pulls{/number}","milestones_url":"https://api.github.com/repos/francoisfreitag/django/milestones{/number}","notifications_url":"https://api.github.com/repos/francoisfreitag/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/francoisfreitag/django/labels{/name}","releases_url":"https://api.github.com/repos/francoisfreitag/django/releases{/id}","deployments_url":"https://api.github.com/repos/francoisfreitag/django/deployments","created_at":"2015-12-20T18:37:20Z","updated_at":"2016-09-07T01:04:46Z","pushed_at":"2016-09-24T22:28:43Z","git_url":"git://github.com/francoisfreitag/django.git","ssh_url":"git@github.com:francoisfreitag/django.git","clone_url":"https://github.com/francoisfreitag/django.git","svn_url":"https://github.com/francoisfreitag/django","homepage":"https://www.djangoproject.com/","size":140557,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"django:master","ref":"master","sha":"5d55a26019e65224569ac4edc73428a3c532d34d","user":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"repo":{"id":4164482,"name":"django","full_name":"django/django","owner":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django/django","description":"The Web framework for perfectionists with deadlines.","fork":false,"url":"https://api.github.com/repos/django/django","forks_url":"https://api.github.com/repos/django/django/forks","keys_url":"https://api.github.com/repos/django/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django/django/teams","hooks_url":"https://api.github.com/repos/django/django/hooks","issue_events_url":"https://api.github.com/repos/django/django/issues/events{/number}","events_url":"https://api.github.com/repos/django/django/events","assignees_url":"https://api.github.com/repos/django/django/assignees{/user}","branches_url":"https://api.github.com/repos/django/django/branches{/branch}","tags_url":"https://api.github.com/repos/django/django/tags","blobs_url":"https://api.github.com/repos/django/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/django/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django/django/statuses/{sha}","languages_url":"https://api.github.com/repos/django/django/languages","stargazers_url":"https://api.github.com/repos/django/django/stargazers","contributors_url":"https://api.github.com/repos/django/django/contributors","subscribers_url":"https://api.github.com/repos/django/django/subscribers","subscription_url":"https://api.github.com/repos/django/django/subscription","commits_url":"https://api.github.com/repos/django/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/django/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/django/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/django/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/django/django/contents/{+path}","compare_url":"https://api.github.com/repos/django/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django/django/merges","archive_url":"https://api.github.com/repos/django/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django/django/downloads","issues_url":"https://api.github.com/repos/django/django/issues{/number}","pulls_url":"https://api.github.com/repos/django/django/pulls{/number}","milestones_url":"https://api.github.com/repos/django/django/milestones{/number}","notifications_url":"https://api.github.com/repos/django/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django/django/labels{/name}","releases_url":"https://api.github.com/repos/django/django/releases{/id}","deployments_url":"https://api.github.com/repos/django/django/deployments","created_at":"2012-04-28T02:47:18Z","updated_at":"2016-09-24T17:50:41Z","pushed_at":"2016-09-24T22:28:45Z","git_url":"git://github.com/django/django.git","ssh_url":"git@github.com:django/django.git","clone_url":"https://github.com/django/django.git","svn_url":"https://github.com/django/django","homepage":"https://www.djangoproject.com/","size":201111,"stargazers_count":21357,"watchers_count":21357,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8587,"mirror_url":null,"open_issues_count":81,"forks":8587,"open_issues":81,"watchers":21357,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/7255"},"html":{"href":"https://github.com/django/django/pull/7255"},"issue":{"href":"https://api.github.com/repos/django/django/issues/7255"},"comments":{"href":"https://api.github.com/repos/django/django/issues/7255/comments"},"review_comments":{"href":"https://api.github.com/repos/django/django/pulls/7255/comments"},"review_comment":{"href":"https://api.github.com/repos/django/django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/django/django/pulls/7255/commits"},"statuses":{"href":"https://api.github.com/repos/django/django/statuses/3d0b8ef4943bb06360ca85723c2c77ed0241ff92"}}}}
{"actor":{"display_login":"timgraham"}}