{"action":"created","issue":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/3138","repository_url":"https://api.github.com/repos/typeorm/typeorm","labels_url":"https://api.github.com/repos/typeorm/typeorm/issues/3138/labels{/name}","comments_url":"https://api.github.com/repos/typeorm/typeorm/issues/3138/comments","events_url":"https://api.github.com/repos/typeorm/typeorm/issues/3138/events","html_url":"https://github.com/typeorm/typeorm/issues/3138","id":383107172,"node_id":"MDU6SXNzdWUzODMxMDcxNzI=","number":3138,"title":"Multiple OrderBy","user":{"login":"dingyun651108","id":20982586,"node_id":"MDQ6VXNlcjIwOTgyNTg2","avatar_url":"https://avatars2.githubusercontent.com/u/20982586?v=4","gravatar_id":"","url":"https://api.github.com/users/dingyun651108","html_url":"https://github.com/dingyun651108","followers_url":"https://api.github.com/users/dingyun651108/followers","following_url":"https://api.github.com/users/dingyun651108/following{/other_user}","gists_url":"https://api.github.com/users/dingyun651108/gists{/gist_id}","starred_url":"https://api.github.com/users/dingyun651108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dingyun651108/subscriptions","organizations_url":"https://api.github.com/users/dingyun651108/orgs","repos_url":"https://api.github.com/users/dingyun651108/repos","events_url":"https://api.github.com/users/dingyun651108/events{/privacy}","received_events_url":"https://api.github.com/users/dingyun651108/received_events","type":"User","site_admin":false},"labels":[{"id":333605711,"node_id":"MDU6TGFiZWwzMzM2MDU3MTE=","url":"https://api.github.com/repos/typeorm/typeorm/labels/bug","name":"bug","color":"fc2929","default":true},{"id":712055178,"node_id":"MDU6TGFiZWw3MTIwNTUxNzg=","url":"https://api.github.com/repos/typeorm/typeorm/labels/driver:%20mssql","name":"driver: mssql","color":"0052cc","default":false},{"id":333605716,"node_id":"MDU6TGFiZWwzMzM2MDU3MTY=","url":"https://api.github.com/repos/typeorm/typeorm/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-21T12:59:25Z","updated_at":"2018-12-12T06:32:03Z","closed_at":null,"author_association":"NONE","body":"**Issue type:**\r\n\r\n[ ] question\r\n[ x ] bug report\r\n[ ] feature request\r\n[ ] documentation issue\r\n\r\n**Database system/driver:**\r\n\r\n[ ] `cordova`\r\n[ ] `mongodb`\r\n[x] `mssql`\r\n[ ] `mysql` / `mariadb`\r\n[ ] `oracle`\r\n[ ] `postgres`\r\n[ ] `sqlite`\r\n[ ] `sqljs`\r\n[ ] `react-native`\r\n[ ] `expo`\r\n\r\n**TypeORM version:**\r\n\r\n[x] `latest`\r\n[ ] `@next`\r\n[ ] `0.x.x` (or put your version here)\r\n\r\n**Steps to reproduce or a small repository showing the problem:**\r\n\r\nJoined table and Multiple OrderBy \r\n\r\n builder.addOrderBy('IF(type_id in (100, 200), 0, 1)', 'ASC')\r\n builder.addOrderBy('IF(category_id in (700, 800), 0, 1)', 'ASC')\r\n\r\nhere is the sql generated.\r\n SELECT DISTINCT `distinctAlias`.`job_id` as \"ids_job_id\", ,  FROM (SELECT\r\n\r\n\r\nI have checked the source code.  SelectQueryBuilder.ts \r\n\r\n```ts\r\nconst selectString = Object.keys(orderBys)\r\n            .map(orderCriteria => {\r\n                if (orderCriteria.indexOf(\".\") !== -1) {\r\n                    const [aliasName, propertyPath] = orderCriteria.split(\".\");\r\n                    const alias = this.expressionMap.findAliasByName(aliasName);\r\n                    const column = alias.metadata.findColumnWithPropertyName(propertyPath);\r\n                    return this.escape(parentAlias) + \".\" + this.escape(this.buildColumnAlias(aliasName, column!.databaseName));\r\n                } else {\r\n                    if (this.expressionMap.selects.find(select => select.selection === orderCriteria || select.aliasName === orderCriteria))\r\n                        return this.escape(parentAlias) + \".\" + orderCriteria; \r\n                    **return \"\";**    \r\n                }\r\n            }).join(\", \");\r\n```"},"comment":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/comments/446478200","html_url":"https://github.com/typeorm/typeorm/issues/3138#issuecomment-446478200","issue_url":"https://api.github.com/repos/typeorm/typeorm/issues/3138","id":446478200,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjQ3ODIwMA==","user":{"login":"dingyun651108","id":20982586,"node_id":"MDQ6VXNlcjIwOTgyNTg2","avatar_url":"https://avatars2.githubusercontent.com/u/20982586?v=4","gravatar_id":"","url":"https://api.github.com/users/dingyun651108","html_url":"https://github.com/dingyun651108","followers_url":"https://api.github.com/users/dingyun651108/followers","following_url":"https://api.github.com/users/dingyun651108/following{/other_user}","gists_url":"https://api.github.com/users/dingyun651108/gists{/gist_id}","starred_url":"https://api.github.com/users/dingyun651108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dingyun651108/subscriptions","organizations_url":"https://api.github.com/users/dingyun651108/orgs","repos_url":"https://api.github.com/users/dingyun651108/repos","events_url":"https://api.github.com/users/dingyun651108/events{/privacy}","received_events_url":"https://api.github.com/users/dingyun651108/received_events","type":"User","site_admin":false},"created_at":"2018-12-12T06:32:03Z","updated_at":"2018-12-12T06:32:03Z","author_association":"NONE","body":"Hi vlapo\n\nPls find it from below url, I have uploaded to my google driver.\n\nhttps://drive.google.com/file/d/1vY-EwZftEAi8zngTAEkW2CjpjUL_1j--/view?usp=sharing\n\nOn Wed, Dec 12, 2018 at 8:21 AM vlapo <notifications@github.com> wrote:\n\n> Could you provide small reproduction?\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/typeorm/typeorm/issues/3138#issuecomment-446414072>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AUArOhPuGxL9tH55zN8yS5oJ0UBiFigvks5u4Ev9gaJpZM4YtEgO>\n> .\n>\n\n\n-- \nBest Regards!\n丁贇\nDing Yun\nTim\n"}}
{"actor":{"display_login":"dingyun651108"}}