{"action":"closed","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/6878","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/6878/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/6878/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/6878/events","html_url":"https://github.com/cakephp/cakephp/issues/6878","id":90721018,"number":6878,"title":"SQLite datasource incorrectly parses fields with multiple occurances of 'as'","user":{"login":"larryb82","id":980675,"avatar_url":"https://avatars.githubusercontent.com/u/980675?v=3","gravatar_id":"","url":"https://api.github.com/users/larryb82","html_url":"https://github.com/larryb82","followers_url":"https://api.github.com/users/larryb82/followers","following_url":"https://api.github.com/users/larryb82/following{/other_user}","gists_url":"https://api.github.com/users/larryb82/gists{/gist_id}","starred_url":"https://api.github.com/users/larryb82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larryb82/subscriptions","organizations_url":"https://api.github.com/users/larryb82/orgs","repos_url":"https://api.github.com/users/larryb82/repos","events_url":"https://api.github.com/users/larryb82/events{/privacy}","received_events_url":"https://api.github.com/users/larryb82/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/datasource","name":"datasource","color":"FFFFFF"},{"url":"https://api.github.com/repos/cakephp/cakephp/labels/Defect","name":"Defect","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/45","html_url":"https://github.com/cakephp/cakephp/milestones/2.6.8","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/45/labels","id":1138936,"number":45,"title":"2.6.8","description":"Bugfixes and optimizations for 2.6","creator":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":25,"state":"open","created_at":"2015-05-28T23:32:42Z","updated_at":"2015-06-25T13:50:54Z","due_on":"2015-06-28T04:00:00Z","closed_at":null},"comments":4,"created_at":"2015-06-24T16:08:27Z","updated_at":"2015-06-25T13:50:54Z","closed_at":"2015-06-25T13:50:54Z","body":"The following code snippet does not work properly when using an SQLite datasource.  The field name is parsed as **bigint)) as WeldCheck__avg_diameter** instead of **WeldCheck__avg_diameter** which changes the structure of the $records array.  The SQL executes without any issues.\r\n\r\n```php\r\n// cast will prevent overflow errors on MS SQL Server\r\n$Inspection->WeldCheck->virtualFields['avg_diameter'] = 0;\r\n$records = $Inspection->find('all', array(\r\n  'fields' => array(\r\n    'avg(cast (WeldMeasurement.circle_diameter as bigint)) as WeldCheck__avg_diameter',\r\n    ..\r\n  )));\r\n```\r\n\r\nI already have a solution for this, I'll try to create a pull request later today."}}