{"action":"closed","issue":{"url":"https://api.github.com/repos/citusdata/pg_shard/issues/94","labels_url":"https://api.github.com/repos/citusdata/pg_shard/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/citusdata/pg_shard/issues/94/comments","events_url":"https://api.github.com/repos/citusdata/pg_shard/issues/94/events","html_url":"https://github.com/citusdata/pg_shard/issues/94","id":63339549,"number":94,"title":"Table constraints deparsed incorrectly","user":{"login":"jasonmp85","id":50673,"avatar_url":"https://avatars.githubusercontent.com/u/50673?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonmp85","html_url":"https://github.com/jasonmp85","followers_url":"https://api.github.com/users/jasonmp85/followers","following_url":"https://api.github.com/users/jasonmp85/following{/other_user}","gists_url":"https://api.github.com/users/jasonmp85/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonmp85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonmp85/subscriptions","organizations_url":"https://api.github.com/users/jasonmp85/orgs","repos_url":"https://api.github.com/users/jasonmp85/repos","events_url":"https://api.github.com/users/jasonmp85/events{/privacy}","received_events_url":"https://api.github.com/users/jasonmp85/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/citusdata/pg_shard/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/citusdata/pg_shard/labels/waffle:%20needs%20review","name":"waffle: needs review","color":"ededed"}],"state":"closed","locked":false,"assignee":{"login":"onderkalaci","id":7829470,"avatar_url":"https://avatars.githubusercontent.com/u/7829470?v=3","gravatar_id":"","url":"https://api.github.com/users/onderkalaci","html_url":"https://github.com/onderkalaci","followers_url":"https://api.github.com/users/onderkalaci/followers","following_url":"https://api.github.com/users/onderkalaci/following{/other_user}","gists_url":"https://api.github.com/users/onderkalaci/gists{/gist_id}","starred_url":"https://api.github.com/users/onderkalaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onderkalaci/subscriptions","organizations_url":"https://api.github.com/users/onderkalaci/orgs","repos_url":"https://api.github.com/users/onderkalaci/repos","events_url":"https://api.github.com/users/onderkalaci/events{/privacy}","received_events_url":"https://api.github.com/users/onderkalaci/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/citusdata/pg_shard/milestones/2","html_url":"https://github.com/citusdata/pg_shard/milestones/v1.2","labels_url":"https://api.github.com/repos/citusdata/pg_shard/milestones/2/labels","id":994236,"number":2,"title":"v1.2","description":"","creator":{"login":"jasonmp85","id":50673,"avatar_url":"https://avatars.githubusercontent.com/u/50673?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonmp85","html_url":"https://github.com/jasonmp85","followers_url":"https://api.github.com/users/jasonmp85/followers","following_url":"https://api.github.com/users/jasonmp85/following{/other_user}","gists_url":"https://api.github.com/users/jasonmp85/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonmp85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonmp85/subscriptions","organizations_url":"https://api.github.com/users/jasonmp85/orgs","repos_url":"https://api.github.com/users/jasonmp85/repos","events_url":"https://api.github.com/users/jasonmp85/events{/privacy}","received_events_url":"https://api.github.com/users/jasonmp85/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":3,"state":"open","created_at":"2015-02-24T22:47:36Z","updated_at":"2015-05-22T04:44:09Z","due_on":"2015-06-23T06:00:00Z","closed_at":null},"comments":5,"created_at":"2015-03-21T00:46:38Z","updated_at":"2015-05-22T04:44:09Z","closed_at":"2015-05-22T04:44:09Z","body":"While reviewing error message style in `pg_shard`, I noticed that an error message in [the DDL extension code][1] referred to a set of constraints as a _column constraint_. \"That's odd\", I thought… \"I thought those were table constraints?\"\r\n\r\nThe unit test for this section of code extends the following DDL command:\r\n\r\n```sql\r\nCREATE TABLE employees ( \r\n    first_name text NOT NULL, \r\n    last_name  text NOT NULL, \r\n    id         bigint NOT NULL, \r\n    salary     numeric DEFAULT 0.00, \r\n    start_date timestamp without time zone, \r\n    resume     text, \r\n    CONSTRAINT sal_check CHECK (salary >= 0.00) \r\n);\r\n```\r\n\r\nThere are several column constraints here (specifically, `NOT NULL` ones), but the final `CONSTRAINT` is a table constraint because it is not syntactically attached to any column. But here's what the extended DDL looks like:\r\n\r\n```sql\r\nCREATE TABLE employees_12345 ( \r\n    first_name  text NOT NULL, \r\n    last_name   text NOT NULL, \r\n    id          bigint NOT NULL, \r\n    salary      numeric DEFAULT 0.00, \r\n    start_date  timestamp without time zone, \r\n    resume text CONSTRAINT sal_check CHECK (salary >= 0.00) \r\n);\r\n```\r\n\r\nThe constraint is generated _right next to the final column_, when in fact there should be a comma to separate it. The unit test itself is wrong (it should have a comma).\r\n\r\n[1]: https://github.com/citusdata/pg_shard/blob/v1.1.0/extend_ddl_commands.c?ts=4#L628-L662"}}