Filth

Strange Group By behaviour

Posted 2 years ago by Filth

The following:

OldProduct::select('NAME', 'TYPE', 'FLAVOUR', 'DISPLAY', 'NEW')->where('product_link', $item->PRODUCTNAME)->groupBy('TYPE')->get();

Returns an error:

Syntax error or access violation: 1055 'old_db.orderform.NAME' isn't in GROUP BY (SQL: select `NAME`, `TYPE`, `FLAVOUR`, `DISPLAY`, `NEW`
  from `orderform` where `product_link` = Action Range group by `TYPE`

now if I take the generated sql and run it in sql pro I get an error, but if I wrap the search in quotations the query works as it should.

select `NAME`, `TYPE`, `FLAVOUR`, `DISPLAY`, `NEW` from `orderform` where `product_link` = 'Action Range' group by `TYPE`

So eloquent is missing the quotations, is this right and is there a solution?

Thanks

Please sign in or create an account to participate in this conversation.