{"action":"created","issue":{"url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/544","repository_url":"https://api.github.com/repos/fsprojects/SQLProvider","labels_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/544/labels{/name}","comments_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/544/comments","events_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/544/events","html_url":"https://github.com/fsprojects/SQLProvider/pull/544","id":319816508,"number":544,"title":"Improved option type support in convertTypes.","user":{"login":"object","id":252126,"avatar_url":"https://avatars3.githubusercontent.com/u/252126?v=4","gravatar_id":"","url":"https://api.github.com/users/object","html_url":"https://github.com/object","followers_url":"https://api.github.com/users/object/followers","following_url":"https://api.github.com/users/object/following{/other_user}","gists_url":"https://api.github.com/users/object/gists{/gist_id}","starred_url":"https://api.github.com/users/object/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/object/subscriptions","organizations_url":"https://api.github.com/users/object/orgs","repos_url":"https://api.github.com/users/object/repos","events_url":"https://api.github.com/users/object/events{/privacy}","received_events_url":"https://api.github.com/users/object/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-03T07:42:26Z","updated_at":"2018-05-03T15:14:27Z","closed_at":"2018-05-03T15:10:59Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/fsprojects/SQLProvider/pulls/544","html_url":"https://github.com/fsprojects/SQLProvider/pull/544","diff_url":"https://github.com/fsprojects/SQLProvider/pull/544.diff","patch_url":"https://github.com/fsprojects/SQLProvider/pull/544.patch"},"body":"If option types are enabled (UseOptionTypes is set to true), then SQLProvider fails to retrieve results in some aggregate queries, here are examples:\r\n\r\n1. Create the following table\r\ncreate table test_a (\r\n    a_id_not_null number(5,0) not null,\r\n    a_text_not_null varchar2(20) not null,\r\n    a_id_null number(5,0) null,\r\n    a_text_null varchar2(20) null)\r\n\r\n2. Insert test data\r\ninsert into test_a (a_id_not_null, a_text_not_null, a_id_null, a_text_null) values (45, 'TEXT_VALUE', 45, 'TEXT_VALUE');\r\n\r\n3. The following queries fail with conversion exception (inside convertType function):\r\n\r\nquery { for t in ctx.TestA do\r\ngroupBy t.AIdNotNull into g\r\nselect (g.Min(fun p -> p.ATextNull)) }\r\n\r\nquery { for t in ctx.TestA do\r\ngroupBy t.AIdNull into g\r\nselect (g.Min(fun p -> p.ATextNotNull)) }\r\n\r\nThere are a few reasons for failures:\r\n\r\n1. convertType test that option types have a name prefixed with \"Option\". Not sure whether this was the case in earlier versions of F#, but present option type use the name \"FSharpOption\". I kept the test for both, just in case.\r\n\r\n2. When instantiating an option type, convertType used a call to unbox which resulted in Option<Object>, since at the time of unboxing compiler couldn't infer the type of underlying value. This caused exception in Convert.ChangeType which couldn't convert between Option<Object> and a primitive type. I had to replace unbox with specific type checks.\r\n\r\n3. Missing conversions for certain types, including String.\r\n\r\nCurrent PR fixes these problems, the above queries work."},"comment":{"url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/comments/386330719","html_url":"https://github.com/fsprojects/SQLProvider/pull/544#issuecomment-386330719","issue_url":"https://api.github.com/repos/fsprojects/SQLProvider/issues/544","id":386330719,"user":{"login":"Thorium","id":229355,"avatar_url":"https://avatars1.githubusercontent.com/u/229355?v=4","gravatar_id":"","url":"https://api.github.com/users/Thorium","html_url":"https://github.com/Thorium","followers_url":"https://api.github.com/users/Thorium/followers","following_url":"https://api.github.com/users/Thorium/following{/other_user}","gists_url":"https://api.github.com/users/Thorium/gists{/gist_id}","starred_url":"https://api.github.com/users/Thorium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Thorium/subscriptions","organizations_url":"https://api.github.com/users/Thorium/orgs","repos_url":"https://api.github.com/users/Thorium/repos","events_url":"https://api.github.com/users/Thorium/events{/privacy}","received_events_url":"https://api.github.com/users/Thorium/received_events","type":"User","site_admin":false},"created_at":"2018-05-03T15:14:27Z","updated_at":"2018-05-03T15:14:27Z","author_association":"MEMBER","body":"Thanks! \r\nI've always checked option types as `.IsNone` and then `.Value` but haven't tried those a lot with group-by."}}
{"actor":{"display_login":"Thorium"}}