{"action":"created","issue":{"url":"https://api.github.com/repos/swoft-cloud/swoft-component/issues/209","repository_url":"https://api.github.com/repos/swoft-cloud/swoft-component","labels_url":"https://api.github.com/repos/swoft-cloud/swoft-component/issues/209/labels{/name}","comments_url":"https://api.github.com/repos/swoft-cloud/swoft-component/issues/209/comments","events_url":"https://api.github.com/repos/swoft-cloud/swoft-component/issues/209/events","html_url":"https://github.com/swoft-cloud/swoft-component/pull/209","id":365100926,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5MTI4MDYz","number":209,"title":"add: Added support of QueryBuilder column alias","user":{"login":"HZMarico","id":15900595,"node_id":"MDQ6VXNlcjE1OTAwNTk1","avatar_url":"https://avatars0.githubusercontent.com/u/15900595?v=4","gravatar_id":"","url":"https://api.github.com/users/HZMarico","html_url":"https://github.com/HZMarico","followers_url":"https://api.github.com/users/HZMarico/followers","following_url":"https://api.github.com/users/HZMarico/following{/other_user}","gists_url":"https://api.github.com/users/HZMarico/gists{/gist_id}","starred_url":"https://api.github.com/users/HZMarico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HZMarico/subscriptions","organizations_url":"https://api.github.com/users/HZMarico/orgs","repos_url":"https://api.github.com/users/HZMarico/repos","events_url":"https://api.github.com/users/HZMarico/events{/privacy}","received_events_url":"https://api.github.com/users/HZMarico/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-29T05:59:02Z","updated_at":"2018-10-31T14:24:44Z","closed_at":"2018-10-09T09:47:52Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/swoft-cloud/swoft-component/pulls/209","html_url":"https://github.com/swoft-cloud/swoft-component/pull/209","diff_url":"https://github.com/swoft-cloud/swoft-component/pull/209.diff","patch_url":"https://github.com/swoft-cloud/swoft-component/pull/209.patch"},"body":"修复无法使用数据表列字段别名问题\r\n\r\nExample：\r\n```\r\nQuery::table(User::class)->one([\r\n    'sex' => 'sex',\r\n    'name' => 'nickName'\r\n])->getResult();\r\n\r\n# 此处将数据表name字段，别名为nickName\r\n```\r\n\r\nError Message:\r\n```\r\nUndefined index: nickName\r\n /Library/WebServer/duomai/data-server/vendor/swoft/db/src/Helper/EntityHelper.php:62\r\n /Library/WebServer/duomai/data-server/vendor/swoft/db/src/QueryBuilder.php:1438\r\n /Library/WebServer/duomai/data-server/vendor/swoft/db/src/DbDataResult.php:28\r\n /Library/WebServer/duomai/data-server/vendor/swoft/db/test/Cases/Mysql/QueryBuilderTest.php:526\r\n /Library/WebServer/duomai/data-server/vendor/phpunit/phpunit/src/TextUI/Command.php:186\r\n /Library/WebServer/duomai/data-server/vendor/phpunit/phpunit/src/TextUI/Command.php:116\r\n```\r\n\r\n主要原因为QueryBuilder潜在的逻辑BUG\r\n导致使用时，会进行 EntityHelper::formatListByType\r\n从而在制定列别名后，无法返回数据\r\n\r\n且，未通过Entity进行的查询，仍然进行了EntityHelper::formatListByType\r\n性能，以及逻辑上，存在冗余损耗\r\n\r\nFeature:\r\n```\r\nQuery::table(User::class)->one([\r\n    'sex' => 'sex',\r\n    'name' => 'nickName'\r\n])->getResult();\r\n\r\n# 返回 ['sex' => 2, 'nickname' => '名称' ]\r\n```\r\n\r\n顺手也把get，获取多条数据的相同问题也修复了\r\n```\r\nQuery::table(User::class)->get([\r\n    'sex' => 'sex',\r\n    'name' => 'nickName'\r\n])->getResult();\r\n```"},"comment":{"url":"https://api.github.com/repos/swoft-cloud/swoft-component/issues/comments/434706723","html_url":"https://github.com/swoft-cloud/swoft-component/pull/209#issuecomment-434706723","issue_url":"https://api.github.com/repos/swoft-cloud/swoft-component/issues/209","id":434706723,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDcwNjcyMw==","user":{"login":"inhere","id":5302062,"node_id":"MDQ6VXNlcjUzMDIwNjI=","avatar_url":"https://avatars2.githubusercontent.com/u/5302062?v=4","gravatar_id":"","url":"https://api.github.com/users/inhere","html_url":"https://github.com/inhere","followers_url":"https://api.github.com/users/inhere/followers","following_url":"https://api.github.com/users/inhere/following{/other_user}","gists_url":"https://api.github.com/users/inhere/gists{/gist_id}","starred_url":"https://api.github.com/users/inhere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inhere/subscriptions","organizations_url":"https://api.github.com/users/inhere/orgs","repos_url":"https://api.github.com/users/inhere/repos","events_url":"https://api.github.com/users/inhere/events{/privacy}","received_events_url":"https://api.github.com/users/inhere/received_events","type":"User","site_admin":false},"created_at":"2018-10-31T14:24:44Z","updated_at":"2018-10-31T14:24:44Z","author_association":"MEMBER","body":"不是原来是啥类型就是啥吗"}}
{"actor":{"display_login":"inhere"}}