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

[6.x] Fix mysql schema for srid (point) #31852

Merged
merged 1 commit into from
Mar 9, 2020
Merged

[6.x] Fix mysql schema for srid (point) #31852

merged 1 commit into from
Mar 9, 2020

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 order:

https://github.com/laravel/framework/blob/6.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

This a submission of PR #31851 to the 6.x branch

@GrahamCampbell GrahamCampbell changed the title [6.x] fix mysql schema for srid (point) [6.x] Fix mysql schema for srid (point) Mar 9, 2020
@taylorotwell taylorotwell merged commit 2e9d90b into laravel:6.x Mar 9, 2020
@halloei
Copy link
Contributor

halloei commented Mar 9, 2020

Thanks @rodrigopedra !

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.

4 participants