{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/6770","repository_url":"https://api.github.com/repos/doctrine/doctrine2","labels_url":"https://api.github.com/repos/doctrine/doctrine2/issues/6770/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/issues/6770/comments","events_url":"https://api.github.com/repos/doctrine/doctrine2/issues/6770/events","html_url":"https://github.com/doctrine/doctrine2/issues/6770","id":264971669,"number":6770,"title":"= in order by for postgres query","user":{"login":"AntonioCS","id":1086401,"avatar_url":"https://avatars3.githubusercontent.com/u/1086401?v=4","gravatar_id":"","url":"https://api.github.com/users/AntonioCS","html_url":"https://github.com/AntonioCS","followers_url":"https://api.github.com/users/AntonioCS/followers","following_url":"https://api.github.com/users/AntonioCS/following{/other_user}","gists_url":"https://api.github.com/users/AntonioCS/gists{/gist_id}","starred_url":"https://api.github.com/users/AntonioCS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AntonioCS/subscriptions","organizations_url":"https://api.github.com/users/AntonioCS/orgs","repos_url":"https://api.github.com/users/AntonioCS/repos","events_url":"https://api.github.com/users/AntonioCS/events{/privacy}","received_events_url":"https://api.github.com/users/AntonioCS/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-12T14:52:03Z","updated_at":"2017-10-12T14:56:05Z","closed_at":null,"author_association":"NONE","body":"Hey,\r\n\r\nI am trying to re-create the following query in doctrine:\r\n```\r\nSELECT \r\n\tr1.resource_id, r1.age_group_id\r\nFROM\r\n\tresource_age_groups r1\r\nLEFT JOIN\r\n\tage_group e1\r\nON\r\n\tr1.age_group_id = e1.id\r\nWHERE\r\n\tr1.age_group_id IN (2,3)\t\r\nORDER BY \r\n\tr1.age_group_id=2 DESC, r1.age_group_id=3 DESC\r\n```\r\n\r\nThis is the part that is failing in my doctrine code\r\n\r\n```\r\n   $qb                    \r\n                    ->addOrderBy($qb->expr()->eq('age_groups.id', 2), 'DESC')\r\n```\r\n\r\nI get the following exception: [Syntax Error] line 0, col 338: Error: Expected end of string, got '='\r\n\r\n![image](https://user-images.githubusercontent.com/1086401/31502467-0b2fe91a-af65-11e7-817d-fce022084f70.png)\r\n\r\nI also tried just adding a string instead of the expression but I got the same error.\r\nIs there any way to bypass this?\r\n"},"comment":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/comments/336163180","html_url":"https://github.com/doctrine/doctrine2/issues/6770#issuecomment-336163180","issue_url":"https://api.github.com/repos/doctrine/doctrine2/issues/6770","id":336163180,"user":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars2.githubusercontent.com/u/154256?v=4","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"created_at":"2017-10-12T14:56:04Z","updated_at":"2017-10-12T14:56:04Z","author_association":"OWNER","body":"DQL works with entities, not with table names - please check the\nhttp://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html\n\nYou probably want something like\n\nSELECT\n    r1.resource_id, r1.age_group_id, r1.age_group_id = 2 AS sort1,\nr1.age_group_id = 3 AS sort2\nFROM\n    Resource\\Age\\Groups r1\nLEFT JOIN\n    r1.group e1\nWHERE\n    r1.id IN (2,3)\nORDER BY\n    sort1 DESC, sort2 DESC\n\nAlthough I think the equality isn't supported in `SELECT` (would need a\ncustom DQL function)\n\nMarco Pivetta\n\nhttp://twitter.com/Ocramius\n\nhttp://ocramius.github.com/\n\nOn Thu, Oct 12, 2017 at 4:52 PM, AntonioCS <notifications@github.com> wrote:\n\n> Hey,\n>\n> I am trying to re-create the following query in doctrine:\n>\n> SELECT\n> \tr1.resource_id, r1.age_group_id\n> FROM\n> \tresource_age_groups r1\n> LEFT JOIN\n> \tedcoms_age_group e1\n> ON\n> \tr1.age_group_id = e1.id\n> WHERE\n> \tr1.age_group_id IN (2,3)\t\n> ORDER BY\n> \tr1.age_group_id=2 DESC, r1.age_group_id=3 DESC\n>\n> This is the part that is failing in my doctrine code\n>\n>    $qb\n>                     ->addOrderBy($qb->expr()->eq('age_groups.id', 2), 'DESC')\n>\n> I get the following exception: [Syntax Error] line 0, col 338: Error:\n> Expected end of string, got '='\n>\n> [image: image]\n> <https://user-images.githubusercontent.com/1086401/31502467-0b2fe91a-af65-11e7-817d-fce022084f70.png>\n>\n> I also tried just adding a string instead of the expression but I got the\n> same error.\n> Is there any way to bypass this?\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/doctrine/doctrine2/issues/6770>, or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AAJakDc5m35iPfKExHiPO3QTo1X63uN_ks5srieWgaJpZM4P3Iio>\n> .\n>\n"}}
{"actor":{"display_login":"Ocramius"}}