Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot reliably use DB::expr within ORM query + related due to table/column aliasing #209

Open
torchedmedia opened this issue Jan 24, 2013 · 4 comments

Comments

@torchedmedia
Copy link

I have an ORM query for a related object ("base"), which looks like this: $class::query()->related('base');

I 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.

Ideally 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?

Thanks.

@emlynwest
Copy link
Contributor

The problem with this is that the aliases are generated when the sql is compiled, and if that query is created through the ORM the DB class does not have any knowledge of how relation names map to aliases.

@emlynwest
Copy link
Contributor

This might now be fixed with fuel/core#1727

@emlynwest
Copy link
Contributor

Ah sorry, not the issue I was thinking of, ignore that.

@ve3
Copy link

ve3 commented Jan 6, 2015

+1 To this issue. I want it too.
I cannot do $query->where(\DB::expr('DATE(apm_meters.meter_daily_date)'), '<=', $filter_bill_cycle_date);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants