{"action":"created","issue":{"url":"https://api.github.com/repos/twittner/cql/issues/3","labels_url":"https://api.github.com/repos/twittner/cql/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/twittner/cql/issues/3/comments","events_url":"https://api.github.com/repos/twittner/cql/issues/3/events","html_url":"https://github.com/twittner/cql/pull/3","id":97765224,"number":3,"title":"Allow cas operations","user":{"login":"whitehead1415","id":1903823,"avatar_url":"https://avatars.githubusercontent.com/u/1903823?v=3","gravatar_id":"","url":"https://api.github.com/users/whitehead1415","html_url":"https://github.com/whitehead1415","followers_url":"https://api.github.com/users/whitehead1415/followers","following_url":"https://api.github.com/users/whitehead1415/following{/other_user}","gists_url":"https://api.github.com/users/whitehead1415/gists{/gist_id}","starred_url":"https://api.github.com/users/whitehead1415/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitehead1415/subscriptions","organizations_url":"https://api.github.com/users/whitehead1415/orgs","repos_url":"https://api.github.com/users/whitehead1415/repos","events_url":"https://api.github.com/users/whitehead1415/events{/privacy}","received_events_url":"https://api.github.com/users/whitehead1415/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-28T18:02:51Z","updated_at":"2015-07-29T00:59:06Z","closed_at":"2015-07-29T00:59:05Z","pull_request":{"url":"https://api.github.com/repos/twittner/cql/pulls/3","html_url":"https://github.com/twittner/cql/pull/3","diff_url":"https://github.com/twittner/cql/pull/3.diff","patch_url":"https://github.com/twittner/cql/pull/3.patch"},"body":"**Problem:**\r\nCAS operations do not always return the same number of columns. It depends on whether the operation succeeded or not.\r\n\r\n**Example:**\r\nINSERT INTO users (userId, name) VALUES (\"foo\", \"bar\") IF NOT EXISTS;\r\nIf this operation is successful the row result will have 1 boolean column.\r\n\r\n| [applied] |\r\n|--------------|\r\n| True        |\r\n\r\nIf it fails then the row result will have 3 columns\r\n\r\n| [applied] | userId | name |\r\n|--------------|-----------|---------|\r\n| False       | \"foo\"   | \"bar\"  |\r\n\r\n**Solution:**\r\ncheck if first column name in row result is [applied] then if it is ignore the column count.\r\n\r\nThis way you can do something like this\r\n\r\n```\r\ntrans :: (MonadClient m, CQL.Tuple a, RunQ q) => q CQL.W a (Identity Bool) -> CQL.QueryParams a -> m Bool\r\ntrans q p = do\r\n  r <- runQ q p\r\n  case r of\r\n    CQL.RsResult _ (CQL.RowsResult _ ((Identity b):_)) -> return b\r\n    _                                                  -> throwM UnexpectedResponse\r\n```"},"comment":{"url":"https://api.github.com/repos/twittner/cql/issues/comments/125793840","html_url":"https://github.com/twittner/cql/pull/3#issuecomment-125793840","issue_url":"https://api.github.com/repos/twittner/cql/issues/3","id":125793840,"user":{"login":"whitehead1415","id":1903823,"avatar_url":"https://avatars.githubusercontent.com/u/1903823?v=3","gravatar_id":"","url":"https://api.github.com/users/whitehead1415","html_url":"https://github.com/whitehead1415","followers_url":"https://api.github.com/users/whitehead1415/followers","following_url":"https://api.github.com/users/whitehead1415/following{/other_user}","gists_url":"https://api.github.com/users/whitehead1415/gists{/gist_id}","starred_url":"https://api.github.com/users/whitehead1415/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitehead1415/subscriptions","organizations_url":"https://api.github.com/users/whitehead1415/orgs","repos_url":"https://api.github.com/users/whitehead1415/repos","events_url":"https://api.github.com/users/whitehead1415/events{/privacy}","received_events_url":"https://api.github.com/users/whitehead1415/received_events","type":"User","site_admin":false},"created_at":"2015-07-29T00:59:05Z","updated_at":"2015-07-29T00:59:05Z","body":"Yes I agree I don't think that relying on the column name is the best way to do it. It was just the only thing I could think of. \r\n\r\nI like the idea of the Row type much better. "}}