Skip to content

Schema Builder: collaction() should be wrapped by quotes #23944

@rentalhost

Description

@rentalhost
  • Laravel Version: 5.6.17 (lastest)
  • PHP Version: 7.2.2 ZTS MSVC15 (Visual C++ 2017) x64
  • Database Driver & Version: MariaDB 10.1.14

Description:

Else, ->collection('binary') could fails in some cases, because of the generated code is something like addressable_type varchar(255) collate binary not null (the correct is addressable_type varchar(255) collate "binary" not null).

I think that it should be applied to both: collaction and charset.

It affects MariaDB 10.1, but I don't know if it affects other DBMS and which versions.

I am not the best person to PR that, so if someone could do that, it will be very useful.

Steps to reproduce

Full test case:

Schema::create('addresses', function (Blueprint $blueprint) {
    $blueprint->string('addressable_type')->collation(static::COLLATION_BINARY);
});

Code generated:

create table `platform_addresses` (`addressable_type` varchar(255) collate binary
  not null) default character set utf8mb4 collate utf8mb4_unicode_ci

Code manually fixed:

create table `platform_addresses` (`addressable_type` varchar(255) collate "binary"
  not null) default character set utf8mb4 collate utf8mb4_unicode_ci

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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