{"action":"created","issue":{"url":"https://api.github.com/repos/fuel/orm/issues/209","labels_url":"https://api.github.com/repos/fuel/orm/issues/209/labels{/name}","comments_url":"https://api.github.com/repos/fuel/orm/issues/209/comments","events_url":"https://api.github.com/repos/fuel/orm/issues/209/events","html_url":"https://github.com/fuel/orm/issues/209","id":10293813,"number":209,"title":"Cannot reliably use DB::expr within ORM query + related due to table/column aliasing","user":{"login":"torchedmedia","id":1058807,"avatar_url":"https://avatars.githubusercontent.com/u/1058807?v=3","gravatar_id":"","url":"https://api.github.com/users/torchedmedia","html_url":"https://github.com/torchedmedia","followers_url":"https://api.github.com/users/torchedmedia/followers","following_url":"https://api.github.com/users/torchedmedia/following{/other_user}","gists_url":"https://api.github.com/users/torchedmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/torchedmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torchedmedia/subscriptions","organizations_url":"https://api.github.com/users/torchedmedia/orgs","repos_url":"https://api.github.com/users/torchedmedia/repos","events_url":"https://api.github.com/users/torchedmedia/events{/privacy}","received_events_url":"https://api.github.com/users/torchedmedia/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fuel/orm/labels/Address+in+2.0","name":"Address in 2.0","color":"0052cc"},{"url":"https://api.github.com/repos/fuel/orm/labels/Feature","name":"Feature","color":"444444"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2013-01-24T23:21:41Z","updated_at":"2015-01-06T09:40:56Z","closed_at":null,"body":"I have an ORM query for a related object (\"base\"), which looks like this: $class::query()->related('base');\r\n\r\nI want to add a condition in the query like so: ->where(\\DB::expr('DATE(base.created)'), $date_variable), but because of the column and table aliasing in ORM, neither base nor created are recognized.\r\n\r\nIdeally there would be a way to translate \"base\" and \"created\" into their aliases by using some method on the query object. Is this possible? If not, can it be added?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/fuel/orm/issues/comments/68844761","html_url":"https://github.com/fuel/orm/issues/209#issuecomment-68844761","issue_url":"https://api.github.com/repos/fuel/orm/issues/209","id":68844761,"user":{"login":"ve3","id":1568262,"avatar_url":"https://avatars.githubusercontent.com/u/1568262?v=3","gravatar_id":"","url":"https://api.github.com/users/ve3","html_url":"https://github.com/ve3","followers_url":"https://api.github.com/users/ve3/followers","following_url":"https://api.github.com/users/ve3/following{/other_user}","gists_url":"https://api.github.com/users/ve3/gists{/gist_id}","starred_url":"https://api.github.com/users/ve3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ve3/subscriptions","organizations_url":"https://api.github.com/users/ve3/orgs","repos_url":"https://api.github.com/users/ve3/repos","events_url":"https://api.github.com/users/ve3/events{/privacy}","received_events_url":"https://api.github.com/users/ve3/received_events","type":"User","site_admin":false},"created_at":"2015-01-06T09:40:56Z","updated_at":"2015-01-06T09:40:56Z","body":"+1 To this issue. I want it too.\r\nI cannot do $query->where(\\DB::expr('DATE(apm_meters.meter_daily_date)'), '<=', $filter_bill_cycle_date);"}}