{"action":"created","comment":{"url":"https://api.github.com/repos/odoo/odoo/pulls/comments/187033136","pull_request_review_id":118720203,"id":187033136,"diff_hunk":"@@ -123,12 +123,20 @@ def constraint_definition(cr, constraintname):\n     cr.execute(\"SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conname=%s\", (constraintname,))\n     return cr.fetchone()[0] if cr.rowcount else None\n \n+def constraint_comment(cr, constraintname):\n+    \"\"\" Return the given constraint's comment. \"\"\"\n+    cr.execute(\"SELECT description FROM pg_description d JOIN pg_constraint c \"\n+               \"ON c.oid = d.objoid AND conname = %s;\", (constraintname,))","path":"odoo/tools/sql.py","position":7,"original_position":7,"commit_id":"3849e486f216f5885be3d0c12a4124cdadd341b8","original_commit_id":"3849e486f216f5885be3d0c12a4124cdadd341b8","user":{"login":"odony","id":2039870,"avatar_url":"https://avatars3.githubusercontent.com/u/2039870?v=4","gravatar_id":"","url":"https://api.github.com/users/odony","html_url":"https://github.com/odony","followers_url":"https://api.github.com/users/odony/followers","following_url":"https://api.github.com/users/odony/following{/other_user}","gists_url":"https://api.github.com/users/odony/gists{/gist_id}","starred_url":"https://api.github.com/users/odony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odony/subscriptions","organizations_url":"https://api.github.com/users/odony/orgs","repos_url":"https://api.github.com/users/odony/repos","events_url":"https://api.github.com/users/odony/events{/privacy}","received_events_url":"https://api.github.com/users/odony/received_events","type":"User","site_admin":false},"body":"Constraint names aren't unique, so even if the framework prefixes them with the model name, may I suggest we fully qualify them with the table?\r\n\r\n```python\r\nquery = \"\"\"\r\n    SELECT description FROM pg_description d\r\n                       JOIN pg_constraint c ON (c.oid = d.objoid AND conname = %s)\r\n                       JOIN pg_class t ON (t.oid = c.conrelid AND t.relname = %s)\r\n\"\"\"\r\ncr.execute(query, (constraintname, tablename))\r\n```\r\n(requires passing tablename)\r\n\r\nWe should probably do the same in `constraint_definition()`, etc.","created_at":"2018-05-09T13:08:21Z","updated_at":"2018-05-09T13:33:52Z","html_url":"https://github.com/odoo/odoo/pull/24619#discussion_r187033136","pull_request_url":"https://api.github.com/repos/odoo/odoo/pulls/24619","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments/187033136"},"html":{"href":"https://github.com/odoo/odoo/pull/24619#discussion_r187033136"},"pull_request":{"href":"https://api.github.com/repos/odoo/odoo/pulls/24619"}}},"pull_request":{"url":"https://api.github.com/repos/odoo/odoo/pulls/24619","id":186566712,"html_url":"https://github.com/odoo/odoo/pull/24619","diff_url":"https://github.com/odoo/odoo/pull/24619.diff","patch_url":"https://github.com/odoo/odoo/pull/24619.patch","issue_url":"https://api.github.com/repos/odoo/odoo/issues/24619","number":24619,"state":"open","locked":false,"title":"[IMP] Store the original constraint definition as a comment","user":{"login":"StefanRijnhart","id":1033124,"avatar_url":"https://avatars2.githubusercontent.com/u/1033124?v=4","gravatar_id":"","url":"https://api.github.com/users/StefanRijnhart","html_url":"https://github.com/StefanRijnhart","followers_url":"https://api.github.com/users/StefanRijnhart/followers","following_url":"https://api.github.com/users/StefanRijnhart/following{/other_user}","gists_url":"https://api.github.com/users/StefanRijnhart/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanRijnhart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanRijnhart/subscriptions","organizations_url":"https://api.github.com/users/StefanRijnhart/orgs","repos_url":"https://api.github.com/users/StefanRijnhart/repos","events_url":"https://api.github.com/users/StefanRijnhart/events{/privacy}","received_events_url":"https://api.github.com/users/StefanRijnhart/received_events","type":"User","site_admin":false},"body":"Store the original constraint definition as a comment on the constraint\r\nand use it to determine if the constraint definition was changed. This prevents\r\nendless re-adding of constraints that are reformatted by postgresql in an\r\nunrecognizable way (in which e.g. \"CHECK (credit*debit=0)\" becomes\r\n\"CHECK ((credit * debit) = 0::numeric)\")\r\n\r\nDescription of the issue/feature this PR addresses:\r\nExisting SQL constraints are not properly recognized on module update\r\n\r\nCurrent behavior before PR:\r\nAn update of the account module drops and re-adds _sql_constraints such as those on move and move line balance which can take a long time on large databases.\r\n\r\nDesired behavior after PR is merged:\r\nIf the constraint definition is not modified, the constraint is not dropped and re-added\r\n\r\n\r\n\r\n--\r\nI confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr\r\n","created_at":"2018-05-08T08:51:23Z","updated_at":"2018-05-09T13:33:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05693fe990cb129adbbd25ea77db88a8e0db55cc","assignee":null,"assignees":[],"requested_reviewers":[{"login":"xmo-odoo","id":7571158,"avatar_url":"https://avatars1.githubusercontent.com/u/7571158?v=4","gravatar_id":"","url":"https://api.github.com/users/xmo-odoo","html_url":"https://github.com/xmo-odoo","followers_url":"https://api.github.com/users/xmo-odoo/followers","following_url":"https://api.github.com/users/xmo-odoo/following{/other_user}","gists_url":"https://api.github.com/users/xmo-odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/xmo-odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmo-odoo/subscriptions","organizations_url":"https://api.github.com/users/xmo-odoo/orgs","repos_url":"https://api.github.com/users/xmo-odoo/repos","events_url":"https://api.github.com/users/xmo-odoo/events{/privacy}","received_events_url":"https://api.github.com/users/xmo-odoo/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/odoo/odoo/pulls/24619/commits","review_comments_url":"https://api.github.com/repos/odoo/odoo/pulls/24619/comments","review_comment_url":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/24619/comments","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/3849e486f216f5885be3d0c12a4124cdadd341b8","head":{"label":"StefanRijnhart:fix/12.0-master/check_constraint_by_comment","ref":"fix/12.0-master/check_constraint_by_comment","sha":"3849e486f216f5885be3d0c12a4124cdadd341b8","user":{"login":"StefanRijnhart","id":1033124,"avatar_url":"https://avatars2.githubusercontent.com/u/1033124?v=4","gravatar_id":"","url":"https://api.github.com/users/StefanRijnhart","html_url":"https://github.com/StefanRijnhart","followers_url":"https://api.github.com/users/StefanRijnhart/followers","following_url":"https://api.github.com/users/StefanRijnhart/following{/other_user}","gists_url":"https://api.github.com/users/StefanRijnhart/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanRijnhart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanRijnhart/subscriptions","organizations_url":"https://api.github.com/users/StefanRijnhart/orgs","repos_url":"https://api.github.com/users/StefanRijnhart/repos","events_url":"https://api.github.com/users/StefanRijnhart/events{/privacy}","received_events_url":"https://api.github.com/users/StefanRijnhart/received_events","type":"User","site_admin":false},"repo":{"id":19860462,"name":"odoo","full_name":"StefanRijnhart/odoo","owner":{"login":"StefanRijnhart","id":1033124,"avatar_url":"https://avatars2.githubusercontent.com/u/1033124?v=4","gravatar_id":"","url":"https://api.github.com/users/StefanRijnhart","html_url":"https://github.com/StefanRijnhart","followers_url":"https://api.github.com/users/StefanRijnhart/followers","following_url":"https://api.github.com/users/StefanRijnhart/following{/other_user}","gists_url":"https://api.github.com/users/StefanRijnhart/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanRijnhart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanRijnhart/subscriptions","organizations_url":"https://api.github.com/users/StefanRijnhart/orgs","repos_url":"https://api.github.com/users/StefanRijnhart/repos","events_url":"https://api.github.com/users/StefanRijnhart/events{/privacy}","received_events_url":"https://api.github.com/users/StefanRijnhart/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/StefanRijnhart/odoo","description":"Odoo (formerly OpenERP). Open Source Business Apps.","fork":true,"url":"https://api.github.com/repos/StefanRijnhart/odoo","forks_url":"https://api.github.com/repos/StefanRijnhart/odoo/forks","keys_url":"https://api.github.com/repos/StefanRijnhart/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StefanRijnhart/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StefanRijnhart/odoo/teams","hooks_url":"https://api.github.com/repos/StefanRijnhart/odoo/hooks","issue_events_url":"https://api.github.com/repos/StefanRijnhart/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/StefanRijnhart/odoo/events","assignees_url":"https://api.github.com/repos/StefanRijnhart/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/StefanRijnhart/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/StefanRijnhart/odoo/tags","blobs_url":"https://api.github.com/repos/StefanRijnhart/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StefanRijnhart/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StefanRijnhart/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/StefanRijnhart/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StefanRijnhart/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/StefanRijnhart/odoo/languages","stargazers_url":"https://api.github.com/repos/StefanRijnhart/odoo/stargazers","contributors_url":"https://api.github.com/repos/StefanRijnhart/odoo/contributors","subscribers_url":"https://api.github.com/repos/StefanRijnhart/odoo/subscribers","subscription_url":"https://api.github.com/repos/StefanRijnhart/odoo/subscription","commits_url":"https://api.github.com/repos/StefanRijnhart/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/StefanRijnhart/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/StefanRijnhart/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/StefanRijnhart/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/StefanRijnhart/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/StefanRijnhart/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StefanRijnhart/odoo/merges","archive_url":"https://api.github.com/repos/StefanRijnhart/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StefanRijnhart/odoo/downloads","issues_url":"https://api.github.com/repos/StefanRijnhart/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/StefanRijnhart/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/StefanRijnhart/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/StefanRijnhart/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StefanRijnhart/odoo/labels{/name}","releases_url":"https://api.github.com/repos/StefanRijnhart/odoo/releases{/id}","deployments_url":"https://api.github.com/repos/StefanRijnhart/odoo/deployments","created_at":"2014-05-16T15:01:20Z","updated_at":"2015-03-13T10:08:42Z","pushed_at":"2018-05-08T08:48:31Z","git_url":"git://github.com/StefanRijnhart/odoo.git","ssh_url":"git@github.com:StefanRijnhart/odoo.git","clone_url":"https://github.com/StefanRijnhart/odoo.git","svn_url":"https://github.com/StefanRijnhart/odoo","homepage":"https://www.odoo.com","size":2012208,"stargazers_count":0,"watchers_count":0,"language":"Gettext Catalog","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":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"odoo:master","ref":"master","sha":"0767d3580591f1138f3767fddd8767964efdbc97","user":{"login":"odoo","id":6368483,"avatar_url":"https://avatars2.githubusercontent.com/u/6368483?v=4","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"repo":{"id":19745004,"name":"odoo","full_name":"odoo/odoo","owner":{"login":"odoo","id":6368483,"avatar_url":"https://avatars2.githubusercontent.com/u/6368483?v=4","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odoo/odoo","description":"Odoo. Open Source Apps To Grow Your Business.","fork":false,"url":"https://api.github.com/repos/odoo/odoo","forks_url":"https://api.github.com/repos/odoo/odoo/forks","keys_url":"https://api.github.com/repos/odoo/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoo/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoo/odoo/teams","hooks_url":"https://api.github.com/repos/odoo/odoo/hooks","issue_events_url":"https://api.github.com/repos/odoo/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/odoo/odoo/events","assignees_url":"https://api.github.com/repos/odoo/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/odoo/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/odoo/odoo/tags","blobs_url":"https://api.github.com/repos/odoo/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoo/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoo/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoo/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/odoo/odoo/languages","stargazers_url":"https://api.github.com/repos/odoo/odoo/stargazers","contributors_url":"https://api.github.com/repos/odoo/odoo/contributors","subscribers_url":"https://api.github.com/repos/odoo/odoo/subscribers","subscription_url":"https://api.github.com/repos/odoo/odoo/subscription","commits_url":"https://api.github.com/repos/odoo/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoo/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoo/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoo/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoo/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/odoo/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoo/odoo/merges","archive_url":"https://api.github.com/repos/odoo/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoo/odoo/downloads","issues_url":"https://api.github.com/repos/odoo/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/odoo/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/odoo/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/odoo/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoo/odoo/labels{/name}","releases_url":"https://api.github.com/repos/odoo/odoo/releases{/id}","deployments_url":"https://api.github.com/repos/odoo/odoo/deployments","created_at":"2014-05-13T15:38:58Z","updated_at":"2018-05-09T13:31:17Z","pushed_at":"2018-05-09T13:28:33Z","git_url":"git://github.com/odoo/odoo.git","ssh_url":"git@github.com:odoo/odoo.git","clone_url":"https://github.com/odoo/odoo.git","svn_url":"https://github.com/odoo/odoo","homepage":"https://www.odoo.com","size":2026650,"stargazers_count":9526,"watchers_count":9526,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8083,"mirror_url":null,"archived":false,"open_issues_count":1611,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":8083,"open_issues":1611,"watchers":9526,"default_branch":"11.0"}},"_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/24619"},"html":{"href":"https://github.com/odoo/odoo/pull/24619"},"issue":{"href":"https://api.github.com/repos/odoo/odoo/issues/24619"},"comments":{"href":"https://api.github.com/repos/odoo/odoo/issues/24619/comments"},"review_comments":{"href":"https://api.github.com/repos/odoo/odoo/pulls/24619/comments"},"review_comment":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odoo/odoo/pulls/24619/commits"},"statuses":{"href":"https://api.github.com/repos/odoo/odoo/statuses/3849e486f216f5885be3d0c12a4124cdadd341b8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"odony"}}