Skip to content

[5.8] Fix MySQL Schema Grammar $modifiers order#29265

Merged
taylorotwell merged 2 commits intolaravel:5.8from
mpyw:fix-mysql-schema-grammar-modifiers-order
Jul 23, 2019
Merged

[5.8] Fix MySQL Schema Grammar $modifiers order#29265
taylorotwell merged 2 commits intolaravel:5.8from
mpyw:fix-mysql-schema-grammar-modifiers-order

Conversation

@mpyw
Copy link
Copy Markdown
Contributor

@mpyw mpyw commented Jul 23, 2019

Charset/Collate must be placed before VirtualAs/StoredAs.

e.g.

$table->string('hash', 64)->charset('ascii')->storedAs('sha2(url, 256)')

According to Sequel Pro, this is equivalent to:

`hash` varchar(64) CHARACTER SET ascii GENERATED ALWAYS AS (sha2(`url`,256)) STORED

Currently, however, this is compiled as (Syntax Error):

`hash` varchar(64) as (sha2(url, 256)) stored character set ascii

@mpyw mpyw changed the title Fix MySQL Schema Grammar $modifiers order [5.8] Fix MySQL Schema Grammar $modifiers order Jul 23, 2019
mpyw added 2 commits July 23, 2019 14:47
Charset/Collate must be placed before VirtualAs/StoredAs.

e.g.

```php
$table->string('hash', 64)->charset('ascii')->storedAs('sha2(`url`,256)')
```

According to Sequel Pro, this is equivalent to:

```sql
`hash` varchar(64) CHARACTER SET ascii GENERATED ALWAYS AS (sha2(`url`,256)) STORED
```
@taylorotwell taylorotwell merged commit b41c04a into laravel:5.8 Jul 23, 2019
@mpyw mpyw deleted the fix-mysql-schema-grammar-modifiers-order branch July 24, 2019 05:11
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.

3 participants