{"action":"created","issue":{"url":"https://api.github.com/repos/linq2db/linq2db/issues/1184","repository_url":"https://api.github.com/repos/linq2db/linq2db","labels_url":"https://api.github.com/repos/linq2db/linq2db/issues/1184/labels{/name}","comments_url":"https://api.github.com/repos/linq2db/linq2db/issues/1184/comments","events_url":"https://api.github.com/repos/linq2db/linq2db/issues/1184/events","html_url":"https://github.com/linq2db/linq2db/pull/1184","id":330981530,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzODMzOTk2","number":1184,"title":"PostgreSQL functions schema provider support","user":{"login":"MaceWindu","id":1099238,"node_id":"MDQ6VXNlcjEwOTkyMzg=","avatar_url":"https://avatars1.githubusercontent.com/u/1099238?v=4","gravatar_id":"","url":"https://api.github.com/users/MaceWindu","html_url":"https://github.com/MaceWindu","followers_url":"https://api.github.com/users/MaceWindu/followers","following_url":"https://api.github.com/users/MaceWindu/following{/other_user}","gists_url":"https://api.github.com/users/MaceWindu/gists{/gist_id}","starred_url":"https://api.github.com/users/MaceWindu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaceWindu/subscriptions","organizations_url":"https://api.github.com/users/MaceWindu/orgs","repos_url":"https://api.github.com/users/MaceWindu/repos","events_url":"https://api.github.com/users/MaceWindu/events{/privacy}","received_events_url":"https://api.github.com/users/MaceWindu/received_events","type":"User","site_admin":false},"labels":[{"id":895599695,"node_id":"MDU6TGFiZWw4OTU1OTk2OTU=","url":"https://api.github.com/repos/linq2db/linq2db/labels/provider-postgresql","name":"provider-postgresql","color":"336791","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/linq2db/linq2db/milestones/9","html_url":"https://github.com/linq2db/linq2db/milestone/9","labels_url":"https://api.github.com/repos/linq2db/linq2db/milestones/9/labels","id":3412757,"node_id":"MDk6TWlsZXN0b25lMzQxMjc1Nw==","number":9,"title":"2.2.0","description":"","creator":{"login":"MaceWindu","id":1099238,"node_id":"MDQ6VXNlcjEwOTkyMzg=","avatar_url":"https://avatars1.githubusercontent.com/u/1099238?v=4","gravatar_id":"","url":"https://api.github.com/users/MaceWindu","html_url":"https://github.com/MaceWindu","followers_url":"https://api.github.com/users/MaceWindu/followers","following_url":"https://api.github.com/users/MaceWindu/following{/other_user}","gists_url":"https://api.github.com/users/MaceWindu/gists{/gist_id}","starred_url":"https://api.github.com/users/MaceWindu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaceWindu/subscriptions","organizations_url":"https://api.github.com/users/MaceWindu/orgs","repos_url":"https://api.github.com/users/MaceWindu/repos","events_url":"https://api.github.com/users/MaceWindu/events{/privacy}","received_events_url":"https://api.github.com/users/MaceWindu/received_events","type":"User","site_admin":false},"open_issues":22,"closed_issues":6,"state":"open","created_at":"2018-06-09T11:58:49Z","updated_at":"2018-07-20T11:37:57Z","due_on":"2018-07-26T07:00:00Z","closed_at":null},"comments":2,"created_at":"2018-06-10T16:16:30Z","updated_at":"2018-07-21T14:33:53Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/linq2db/linq2db/pulls/1184","html_url":"https://github.com/linq2db/linq2db/pull/1184","diff_url":"https://github.com/linq2db/linq2db/pull/1184.diff","patch_url":"https://github.com/linq2db/linq2db/pull/1184.patch"},"body":"Fix #1162, #1205, #1191\r\n\r\nWhat included in this PR:\r\n- functions/procedures schema loading for postgresql\r\n- functions/procedures generation by T4 for postgresql\r\n- aggregate functions generation by T4\r\n- fix #1205 name generation using c# keyword for association properties and procedure parameters\r\n- fix #1191 table and procedures generation with duplicate names)\r\n\r\nWhat is not supported by this PR (feel free to create separate issue):\r\n- postgresql functions with dynamic results like json_to_record/json_to_recordset (we load them in schema but don't generate properly in T4)\r\n- procedures in pgsql 11 - this could work, but not tested as pgsql v11 is not released yet\r\n\r\nImportant implementation notes\r\n\r\nBecause prior to v11 postgresql didn't have procedures, it supports some unusual function features:\r\n- void functions. Because we need to be able to call such functions in C# as functions, they will have `object func(...)` signature\r\n- out parameters in functions. Postgresql return then as a single return value: scalar for one parameter and record for multiple out parameters. We don't generate out/ref parameters for functions and map results to scalar value or class in case of multiple out parameters:\r\n\r\nOne out parameter:\r\n```cs\r\n// one out parameter of text type\r\nstring somefunction(...inputs...)\r\n```\r\nMultiple out parameters (two):\r\n```cs\r\nFunctionResult Function(...inputs...)\r\n\r\nclass FunctionResult\r\n{\r\n    public int? out_param;\r\n    public string another_out_param;\r\n}\r\n\r\n// this method is called from generated data context constructor and if you disabled constructors generation, you need to call it from your custom constructor\r\npublic void InitMappingSchema()\r\n{\r\n    MappingSchema.SetConvertExpression<object[], FunctionResult>(tuple => new FunctionResult() { out_param= (int?)tuple[0], another_out_param= (string)tuple[1] });\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/linq2db/linq2db/issues/comments/406800472","html_url":"https://github.com/linq2db/linq2db/pull/1184#issuecomment-406800472","issue_url":"https://api.github.com/repos/linq2db/linq2db/issues/1184","id":406800472,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjgwMDQ3Mg==","user":{"login":"MaceWindu","id":1099238,"node_id":"MDQ6VXNlcjEwOTkyMzg=","avatar_url":"https://avatars1.githubusercontent.com/u/1099238?v=4","gravatar_id":"","url":"https://api.github.com/users/MaceWindu","html_url":"https://github.com/MaceWindu","followers_url":"https://api.github.com/users/MaceWindu/followers","following_url":"https://api.github.com/users/MaceWindu/following{/other_user}","gists_url":"https://api.github.com/users/MaceWindu/gists{/gist_id}","starred_url":"https://api.github.com/users/MaceWindu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaceWindu/subscriptions","organizations_url":"https://api.github.com/users/MaceWindu/orgs","repos_url":"https://api.github.com/users/MaceWindu/repos","events_url":"https://api.github.com/users/MaceWindu/events{/privacy}","received_events_url":"https://api.github.com/users/MaceWindu/received_events","type":"User","site_admin":false},"created_at":"2018-07-21T14:33:53Z","updated_at":"2018-07-21T14:33:53Z","author_association":"CONTRIBUTOR","body":"I've partially fixed duplicate function/class name generation, but it still could be broken in some cases. To fix it properly, we need to update our code-generation AST (`ITree`) to store types as links to ITree elements instead of strings - currently it makes rename operation very fragile.\r\n\r\nI would like to work on this later (probably for next or next+1 release)"}}
{"actor":{"display_login":"MaceWindu"}}