Skip to content

voten/app/Traits/CachableChannel.php has group by error #339

@night1008

Description

@night1008

Illuminate/Database/QueryException with message 'SQLSTATE[42803]: Grouping error: 7 ERROR: column "suggesteds.id" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: select "id", "channel_id" from "suggesteds" group by "channe... ^ (SQL: select "id", "channel_id" from "suggesteds" group by "channel_id")'

id caused from

public function getDefaultChannels()
 {
     return Cache::remember('default-channels-ids', 60 * 60 * 24, function () {
         return \App\Suggested::groupBy('channel_id')->select('id', 'channel_id')->pluck('channel_id');
     });
}

it should be

 \App\Suggested::groupBy('channel_id')->select('channel_id')->pluck('channel_id')

or

 \App\Suggested::distinct('channel_id')->select('channel_id')->pluck('channel_id')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions