Skip to content

when using selectRaw, array bindings are flattened  #39554

@atymic

Description

@atymic
  • Laravel Version:8.70.1
  • PHP Version: 8.0
  • Database Driver & Version: Mysql 8.0

Description:

Take the following query:

DB::table('whatever')
    ->selectRaw("SUM('case(`status` in (?)) as total_pending", [[1,2,3]])
    ->where('user', 1)
    ->groupBy('something')
    ->get()

When laravel runs this query, the bindings are flattened, which results in

SELECT SUM('case(`status` in (1)) as total_pending from whatever where user = 2 group by something

Possibly a security issue if query params are passed into a select raw? see #35865

Anyhow, I don't see why array bindings flattened, as they are supported by the database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions