Skip to content

Bindings not correctly assigned in SQL exceptions #28245

@peterpan666

Description

@peterpan666
  • Laravel Version: 5.7.12 (but maybe in every versions)
  • PHP Version: 7.2.1
  • Database Driver & Version: MySQL 5.6.38

Description:

When an SQL exception is thrown, the bindings are not correctly assigned in the exception's message when one of the values contains a question mark ?.

Steps To Reproduce:

On a simple Laravel install, try to run the following in php artisan tinker :

App\User::create(['foo' => '?', 'email' => 'bar@example.com']);

You should have an Exception like this :

Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'foo' in 'field list' (SQL: insert into `users` (`foo`, `email`, `updated_at`, `created_at`) values (bar@example.com, 2019-04-17 12:51:12, 2019-04-17 12:51:12, ?))'

Here you can see that the value of email is in foo and that created_at is empty...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions