Skip to content

[10.x] Throw exception when trying to escape array for database connection - #48836

Merged
taylorotwell merged 3 commits into
laravel:10.xfrom
sidneyprins:throw-exception-when-escaping-array
Oct 30, 2023
Merged

taylorotwell merged 3 commits into
laravel:10.xfrom
sidneyprins:throw-exception-when-escaping-array

Conversation

@sidneyprins

@sidneyprins sidneyprins commented Oct 27, 2023 •

Copy link
Copy Markdown
Contributor

When trying to escape an array value with the database connection class, typeError is thrown due to str_contains() expecting a string. Now a correct exception is thrown.

It happens for example when you try to substitute bindings into raw SQL and this part has for some reason array values in it.

Simplified version

        $queryBuilder = DB::query();
        $queryBuilder->getGrammar()->substituteBindingsIntoRawSql(
            '?', [ [ 'a', 'b'] ]
        );

@sidneyprins sidneyprins changed the title Throw error when trying to escape array [10.x] Throw error when trying to escape array Oct 27, 2023
@sidneyprins sidneyprins changed the title [10.x] Throw error when trying to escape array [10.x] Throw exception when trying to escape array Oct 27, 2023
@sidneyprins sidneyprins changed the title [10.x] Throw exception when trying to escape array [10.x] Throw exception when trying to escape array for database connection Oct 27, 2023
@sidneyprins
sidneyprins marked this pull request as ready for review October 27, 2023 14:14
@taylorotwell
taylorotwell merged commit 0aeecec into laravel:10.x Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants