{"action":"created","issue":{"url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/488","repository_url":"https://api.github.com/repos/pgjdbc/pgjdbc","labels_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/488/labels{/name}","comments_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/488/comments","events_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/488/events","html_url":"https://github.com/pgjdbc/pgjdbc/issues/488","id":124571200,"number":488,"title":"RETURNING * blindy appended to prepared batch when clause already exists in statement","user":{"login":"apjoseph","id":5465805,"avatar_url":"https://avatars.githubusercontent.com/u/5465805?v=3","gravatar_id":"","url":"https://api.github.com/users/apjoseph","html_url":"https://github.com/apjoseph","followers_url":"https://api.github.com/users/apjoseph/followers","following_url":"https://api.github.com/users/apjoseph/following{/other_user}","gists_url":"https://api.github.com/users/apjoseph/gists{/gist_id}","starred_url":"https://api.github.com/users/apjoseph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apjoseph/subscriptions","organizations_url":"https://api.github.com/users/apjoseph/orgs","repos_url":"https://api.github.com/users/apjoseph/repos","events_url":"https://api.github.com/users/apjoseph/events{/privacy}","received_events_url":"https://api.github.com/users/apjoseph/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"vlsi","id":213894,"avatar_url":"https://avatars.githubusercontent.com/u/213894?v=3","gravatar_id":"","url":"https://api.github.com/users/vlsi","html_url":"https://github.com/vlsi","followers_url":"https://api.github.com/users/vlsi/followers","following_url":"https://api.github.com/users/vlsi/following{/other_user}","gists_url":"https://api.github.com/users/vlsi/gists{/gist_id}","starred_url":"https://api.github.com/users/vlsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlsi/subscriptions","organizations_url":"https://api.github.com/users/vlsi/orgs","repos_url":"https://api.github.com/users/vlsi/repos","events_url":"https://api.github.com/users/vlsi/events{/privacy}","received_events_url":"https://api.github.com/users/vlsi/received_events","type":"User","site_admin":false},"assignees":[{"login":"vlsi","id":213894,"avatar_url":"https://avatars.githubusercontent.com/u/213894?v=3","gravatar_id":"","url":"https://api.github.com/users/vlsi","html_url":"https://github.com/vlsi","followers_url":"https://api.github.com/users/vlsi/followers","following_url":"https://api.github.com/users/vlsi/following{/other_user}","gists_url":"https://api.github.com/users/vlsi/gists{/gist_id}","starred_url":"https://api.github.com/users/vlsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlsi/subscriptions","organizations_url":"https://api.github.com/users/vlsi/orgs","repos_url":"https://api.github.com/users/vlsi/repos","events_url":"https://api.github.com/users/vlsi/events{/privacy}","received_events_url":"https://api.github.com/users/vlsi/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/pgjdbc/pgjdbc/milestones/2","html_url":"https://github.com/pgjdbc/pgjdbc/milestones/9.4.1210","labels_url":"https://api.github.com/repos/pgjdbc/pgjdbc/milestones/2/labels","id":1885587,"number":2,"title":"9.4.1210","description":"","creator":{"login":"vlsi","id":213894,"avatar_url":"https://avatars.githubusercontent.com/u/213894?v=3","gravatar_id":"","url":"https://api.github.com/users/vlsi","html_url":"https://github.com/vlsi","followers_url":"https://api.github.com/users/vlsi/followers","following_url":"https://api.github.com/users/vlsi/following{/other_user}","gists_url":"https://api.github.com/users/vlsi/gists{/gist_id}","starred_url":"https://api.github.com/users/vlsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlsi/subscriptions","organizations_url":"https://api.github.com/users/vlsi/orgs","repos_url":"https://api.github.com/users/vlsi/repos","events_url":"https://api.github.com/users/vlsi/events{/privacy}","received_events_url":"https://api.github.com/users/vlsi/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":4,"state":"open","created_at":"2016-07-15T13:00:27Z","updated_at":"2016-08-07T07:07:40Z","due_on":"2016-08-30T21:00:00Z","closed_at":null},"comments":47,"created_at":"2016-01-02T02:15:09Z","updated_at":"2016-08-08T07:53:46Z","closed_at":null,"body":"`Connection.prepareStatement(String, int)` results in `RETURNING *` being appended to SQL batched statements regardless of whether or not a `RETURNING` clause already exists in the statement. So for example:\r\n\r\n`INSERT INTO death_star(id,exhaust_port) VALUES ( :id, :exhaust_port) RETURNING id;`\r\n\r\nbecomes\r\n\r\n`INSERT INTO death_star(id,exhaust_port) VALUES ( ?, ?) RETURNING id RETURNING *;`\r\n\r\nI have been made aware that it is possible to just use Connection.prepareStatement(String), however this is not possible using many popular frameworks such as JDBI, since those operations are done under the hood.\r\n\r\nI know pgjdbc cannot make it its mission to make life easier for every framework out there; yet, I am not sure I understand the need to append `RETURNING *` when generated keys are requested. Shouldn't the user explicitly specify the keys they want returned in RETURNING clause? Could a global option be added to disable the current behavior and append nothing to the SQL? \r\n\r\nSee related StackOverflow [issue](http://stackoverflow.com/questions/34560647/pg-jdbc-appends-returning-on-prepared-batch-wtih-existing-returning-clause) (JDBI)\r\n\r\nAs a side note, I'm not sure if it is actually worth doing prepared batches with pgjdbc in my case since batching is apparently [forced off when user defined types, arrays, or text fields are used] (https://github.com/2ndQuadrant/pgjdbc/commit/1471bd93fce5401c8bc80f686f8beace9572ec79). -I have these types in many tables (I considered user defined types one main benefits of Postgres in the first place!). This constraint is seemingly paradoxical because batching functionality is exactly what one would desire when they have many rows of large (think postgis geometry) user defined types and thus need to transmit data more effectively than individualized insert statements with round trips in order to insert/update data as quickly as possible. Sure one could use COPY, but it doesn't return values and isn't supported by any of the ORM frameworks (JDBI, Spring JDBC Template, etc) out there\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/comments/238165713","html_url":"https://github.com/pgjdbc/pgjdbc/issues/488#issuecomment-238165713","issue_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/488","id":238165713,"user":{"login":"vlsi","id":213894,"avatar_url":"https://avatars.githubusercontent.com/u/213894?v=3","gravatar_id":"","url":"https://api.github.com/users/vlsi","html_url":"https://github.com/vlsi","followers_url":"https://api.github.com/users/vlsi/followers","following_url":"https://api.github.com/users/vlsi/following{/other_user}","gists_url":"https://api.github.com/users/vlsi/gists{/gist_id}","starred_url":"https://api.github.com/users/vlsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlsi/subscriptions","organizations_url":"https://api.github.com/users/vlsi/orgs","repos_url":"https://api.github.com/users/vlsi/repos","events_url":"https://api.github.com/users/vlsi/events{/privacy}","received_events_url":"https://api.github.com/users/vlsi/received_events","type":"User","site_admin":false},"created_at":"2016-08-08T07:53:46Z","updated_at":"2016-08-08T07:53:46Z","body":"Does anybody know of a \"open-source application\" that can be used as a regression suite?\r\nI mean \"add yet another travis job to check that newer pgjdbc works fine for existing applications\".\r\n\r\nFor instance: hibernate regression tests or even full-blown applications.\r\n\r\nI think #618 is ready to merge (all tests pass, including \"run tests with simpleProtocolOnly=true\"), however it is a non-trivial change, so I would love to hear from real-life applications."}}
{"actor":{"display_login":"vlsi"}}