Skip to content

[7.x] Fix inferred table reference for constrained#32847

Merged
taylorotwell merged 1 commit into
laravel:7.xfrom
jasonmccreary:fix-constraint-reference
May 16, 2020
Merged

[7.x] Fix inferred table reference for constrained#32847
taylorotwell merged 1 commit into
laravel:7.xfrom
jasonmccreary:fix-constraint-reference

Conversation

@jasonmccreary
Copy link
Copy Markdown
Contributor

@jasonmccreary jasonmccreary commented May 16, 2020

There was a minor bug in the logic to infer the table name for the new constrained method where it would take the string before the first matching foreign key column string.

This yields incorrect table names for columns which contain the foreign key as a substring.

For example, laravel_idea_id or american_idol_id yield a table name of laravels or americans, respectively.

This patch corrects the table name and also converts the ternary shorthand to null coalesce for a bit of modernization and symmetry.

@taylorotwell taylorotwell merged commit fc77933 into laravel:7.x May 16, 2020
@GrahamCampbell GrahamCampbell changed the title Fix inferred table reference for constrained [7.x] Fix inferred table reference for constrained May 17, 2020
@jasonmccreary jasonmccreary deleted the fix-constraint-reference branch May 19, 2020 13:04
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