{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/11793","repository_url":"https://api.github.com/repos/cakephp/cakephp","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/11793/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/11793/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/11793/events","html_url":"https://github.com/cakephp/cakephp/issues/11793","id":302782492,"number":11793,"title":"Proposal for a better to read and write case expression","user":{"login":"burzum","id":162789,"avatar_url":"https://avatars0.githubusercontent.com/u/162789?v=4","gravatar_id":"","url":"https://api.github.com/users/burzum","html_url":"https://github.com/burzum","followers_url":"https://api.github.com/users/burzum/followers","following_url":"https://api.github.com/users/burzum/following{/other_user}","gists_url":"https://api.github.com/users/burzum/gists{/gist_id}","starred_url":"https://api.github.com/users/burzum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/burzum/subscriptions","organizations_url":"https://api.github.com/users/burzum/orgs","repos_url":"https://api.github.com/users/burzum/repos","events_url":"https://api.github.com/users/burzum/events{/privacy}","received_events_url":"https://api.github.com/users/burzum/received_events","type":"User","site_admin":false},"labels":[{"id":60504144,"url":"https://api.github.com/repos/cakephp/cakephp/labels/Enhancement","name":"Enhancement","color":"bfe5bf","default":false},{"id":83815438,"url":"https://api.github.com/repos/cakephp/cakephp/labels/ORM","name":"ORM","color":"ffffff","default":false},{"id":60504137,"url":"https://api.github.com/repos/cakephp/cakephp/labels/RFC","name":"RFC","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-06T16:57:19Z","updated_at":"2018-03-06T17:05:51Z","closed_at":null,"author_association":"MEMBER","body":"When I read this https://stackoverflow.com/questions/49129058/cakephp-3-query-ifnull I remembered that I disliked this, it's aweful to read and remember.\r\n\r\n```php\r\n$query\r\n    ->newExpr()\r\n    ->addCase(\r\n        [\r\n            $query->newExpr()->add([\r\n                'Sales.isforeign' => $isforeign,\r\n                'Sales.source' => $source\r\n            ])\r\n        ],\r\n        [1, 0],\r\n        ['integer', 'integer']\r\n    );\r\n```\r\n\r\nSo I had a discussion with @lorenzo about this and we agreed to implement something like this:\r\n\r\n```php\r\n$case = (new CaseExpression())\r\n    ->when([\r\n        'foo' => 1,\r\n        'bar' => 0\r\n    ])\r\n    ->then(1)\r\n    ->otherWise('1', 'integer');\r\n\r\n$query\r\n    ->find()\r\n    ->addCase($case);\r\n```\r\n\r\nAny other ideas or improvements please?"},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/370853586","html_url":"https://github.com/cakephp/cakephp/issues/11793#issuecomment-370853586","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/11793","id":370853586,"user":{"login":"josegonzalez","id":65675,"avatar_url":"https://avatars2.githubusercontent.com/u/65675?v=4","gravatar_id":"","url":"https://api.github.com/users/josegonzalez","html_url":"https://github.com/josegonzalez","followers_url":"https://api.github.com/users/josegonzalez/followers","following_url":"https://api.github.com/users/josegonzalez/following{/other_user}","gists_url":"https://api.github.com/users/josegonzalez/gists{/gist_id}","starred_url":"https://api.github.com/users/josegonzalez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josegonzalez/subscriptions","organizations_url":"https://api.github.com/users/josegonzalez/orgs","repos_url":"https://api.github.com/users/josegonzalez/repos","events_url":"https://api.github.com/users/josegonzalez/events{/privacy}","received_events_url":"https://api.github.com/users/josegonzalez/received_events","type":"User","site_admin":false},"created_at":"2018-03-06T17:05:51Z","updated_at":"2018-03-06T17:05:51Z","author_association":"MEMBER","body":"Can you redo that case api with the example you have in the first bit?\r\n"}}
{"actor":{"display_login":"josegonzalez"}}