Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] fix mysql schema for srid (point) #31851

Closed
wants to merge 1 commit into from
Closed

[7.x] fix mysql schema for srid (point) #31851

wants to merge 1 commit into from

Conversation

rodrigopedra
Copy link
Contributor

@rodrigopedra rodrigopedra commented Mar 9, 2020

As described in #31543 if a migration add a column of type POINT using the SRID parameter and also uses the after modifier, the generated SQL is invalid.

Steps to reproduce:

Schema::create('test', function (Blueprint $table) {
    $table->bigIncrements('id');
});
        
Schema::table('test', function (Blueprint $table) {
    $table->point('location', 4326)->after('id');
});

Expected SQL:

alter table `test` add `location` point not null srid 4326 after `id`;

Actual SQL:

alter table `test` add `location` point not null after `id` srid 4326;

When adding modifiers, the Grammar base class iterates over the $modifiers array and processes them in other:

https://github.com/laravel/framework/blob/7.x/src/Illuminate/Database/Schema/Grammars/Grammar.php#L144-L161

This PR, moves the 'Srid' modifier sooner in the MySqlGrammar's $modifier array, so it is processed before the relevant modifiers.

I added two tests:

  • one to check syntax using the SRID without the after modifier
  • one to check syntax using the SRID with the after modifier

As this is a bugfix and version 6.x is LTS I will send another PR to the 6.x branch

@themsaid
Copy link
Member

themsaid commented Mar 9, 2020

No need to submit a PR for 7.x separately.

@themsaid themsaid closed this Mar 9, 2020
@rodrigopedra
Copy link
Contributor Author

Ok, sorry. Thanks for the heads up.

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