{"action":"created","issue":{"url":"https://api.github.com/repos/metabase/metabase/issues/3657","repository_url":"https://api.github.com/repos/metabase/metabase","labels_url":"https://api.github.com/repos/metabase/metabase/issues/3657/labels{/name}","comments_url":"https://api.github.com/repos/metabase/metabase/issues/3657/comments","events_url":"https://api.github.com/repos/metabase/metabase/issues/3657/events","html_url":"https://github.com/metabase/metabase/issues/3657","id":184882634,"number":3657,"title":"Unable to optionally cast to array in SQL Editor mode","user":{"login":"jacobsmith","id":3843162,"avatar_url":"https://avatars.githubusercontent.com/u/3843162?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobsmith","html_url":"https://github.com/jacobsmith","followers_url":"https://api.github.com/users/jacobsmith/followers","following_url":"https://api.github.com/users/jacobsmith/following{/other_user}","gists_url":"https://api.github.com/users/jacobsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobsmith/subscriptions","organizations_url":"https://api.github.com/users/jacobsmith/orgs","repos_url":"https://api.github.com/users/jacobsmith/repos","events_url":"https://api.github.com/users/jacobsmith/events{/privacy}","received_events_url":"https://api.github.com/users/jacobsmith/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/metabase/metabase/labels/Bug","name":"Bug","color":"CC333F"},{"url":"https://api.github.com/repos/metabase/metabase/labels/Query%20Builder/Native","name":"Query Builder/Native","color":"0DC5EC"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-24T15:59:33Z","updated_at":"2016-10-24T16:47:58Z","closed_at":null,"body":"We have a few queries where users want to be able to add in multiple conditions (i.e., ID is in (`1, 2, 3`) or type is (`Ball, Bat`)).\r\n\r\nI've been able to restructure a text variable as an array using type casts in Postgres, \r\n`select * from foobars where foobars.id in (string_to_array({{foobar_id}}, ',')::integer[])`,\r\nHowever, as soon as I try and make that optional;\r\n\r\n`select * from foobars [[ where foobars.id in (string_to_array({{foobar_id}}, ',')::integer[]) ]]`\r\n\r\nI start getting syntax errors. I imagine that it has to do with the coercion to an array including the `[` and `]` characters which may be running amok of the variable parsing, but I don't know for sure.\r\n\r\nAlso, if there is a better way of doing this, I'd love to learn! This feels a bit hacky and like I might be overlooking a simpler solution.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/metabase/metabase/issues/comments/255796862","html_url":"https://github.com/metabase/metabase/issues/3657#issuecomment-255796862","issue_url":"https://api.github.com/repos/metabase/metabase/issues/3657","id":255796862,"user":{"login":"jacobsmith","id":3843162,"avatar_url":"https://avatars.githubusercontent.com/u/3843162?v=3","gravatar_id":"","url":"https://api.github.com/users/jacobsmith","html_url":"https://github.com/jacobsmith","followers_url":"https://api.github.com/users/jacobsmith/followers","following_url":"https://api.github.com/users/jacobsmith/following{/other_user}","gists_url":"https://api.github.com/users/jacobsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobsmith/subscriptions","organizations_url":"https://api.github.com/users/jacobsmith/orgs","repos_url":"https://api.github.com/users/jacobsmith/repos","events_url":"https://api.github.com/users/jacobsmith/events{/privacy}","received_events_url":"https://api.github.com/users/jacobsmith/received_events","type":"User","site_admin":false},"created_at":"2016-10-24T16:47:58Z","updated_at":"2016-10-24T16:47:58Z","body":"Yes, the UI error is:\r\n\r\n```\r\nERROR: syntax error at or near \"[\" Position: 156\r\n```\r\n\r\nAnd STDOUT is here (linking to a gist because it's ~100 lines of output) https://gist.github.com/jacobsmith/65145c74c2fa300f4e60e750faf84f07"}}
{"actor":{"display_login":"jacobsmith"}}