{"action":"opened","issue":{"url":"https://api.github.com/repos/darold/pgFormatter/issues/65","repository_url":"https://api.github.com/repos/darold/pgFormatter","labels_url":"https://api.github.com/repos/darold/pgFormatter/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/darold/pgFormatter/issues/65/comments","events_url":"https://api.github.com/repos/darold/pgFormatter/issues/65/events","html_url":"https://github.com/darold/pgFormatter/issues/65","id":374090566,"node_id":"MDU6SXNzdWUzNzQwOTA1NjY=","number":65,"title":"DISTINCT and DISTINCT ON should not be treated as prefixes of the first SELECT column","user":{"login":"leorochael","id":239125,"node_id":"MDQ6VXNlcjIzOTEyNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/239125?v=4","gravatar_id":"","url":"https://api.github.com/users/leorochael","html_url":"https://github.com/leorochael","followers_url":"https://api.github.com/users/leorochael/followers","following_url":"https://api.github.com/users/leorochael/following{/other_user}","gists_url":"https://api.github.com/users/leorochael/gists{/gist_id}","starred_url":"https://api.github.com/users/leorochael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leorochael/subscriptions","organizations_url":"https://api.github.com/users/leorochael/orgs","repos_url":"https://api.github.com/users/leorochael/repos","events_url":"https://api.github.com/users/leorochael/events{/privacy}","received_events_url":"https://api.github.com/users/leorochael/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-25T19:10:00Z","updated_at":"2018-10-25T19:10:00Z","closed_at":null,"author_association":"NONE","body":"The `DISTINCT` and `DISTINCT ON` modifiers of the `SELECT` clause are currently treated by `pg_format` as prefixes of the first column to be selected.\r\n\r\nFor readability purposes, the `DISTINCT` clause should be treated as a modifier of the whole select clause.\r\n\r\nFor example a query like:\r\n\r\n```\r\nselect distinct on (a, b)\r\na, b, c\r\nfrom d\r\norder by a, b, c\r\n```\r\n\r\ncurrently gets formatted as:\r\n\r\n```\r\nSELECT\r\n    DISTINCT ON (a,\r\n        b) a,\r\n    b,\r\n    c\r\nFROM\r\n    d\r\nORDER BY\r\n    a,\r\n    b,\r\n    c\r\n```\r\n\r\nI think the `SELECT` part should be formatted as:\r\n\r\n```\r\nSELECT DISTINCT ON (a, b)\r\n    a,\r\n    b,\r\n    c\r\n```\r\n\r\nOr perhaps\r\n\r\n```\r\nSELECT\r\n    DISTINCT ON (\r\n        a,\r\n        b)\r\n    a,\r\n    b,\r\n    c\r\n```\r\n\r\nSimilarly, a query like:\r\n\r\n```\r\nselect distinct\r\na, b, c\r\nfrom d\r\n```\r\n\r\nGets formatted as:\r\n\r\n```\r\nSELECT\r\n    DISTINCT a,\r\n    b,\r\n    c\r\nFROM\r\n    d\r\n```\r\n\r\nWhere I think it would be better formatted as:\r\n\r\n```\r\nSELECT DISTINCT\r\n    a,\r\n    b,\r\n    c\r\nFROM\r\n    d\r\n```"}}
{"actor":{"display_login":"leorochael"}}