laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Review default use of inflection for critical parts of apps / tighten inflection dependency #2251

Open tomcastleman opened 4 years ago

tomcastleman commented 4 years ago

I recently encountered an issue where fixes to pluralization rules of doctrine/inflector in a non-major package upgrade broke BC in a Laravel app due to Eloquent's use of inflection by default in the generation of table names and such. The thread was closed by @grahamcampbell so I thought I'd move it here.

I raised the question with the maintainer of doctrine/inflection who confirmed that pluralization rule fixes are indeed made in non-major version upgrades of the package. He also shared his opinion which you can read there.

Using an inflector for table names and critical parts of the DB layer seems a bit flawed to me if the pluralization rules are going to change under the hood without a major version upgrade, potentially breaking production apps if not caught.

For small well-tested apps, sure it's easy to find the issue (hopefully with failing tests) and quickly manually override the Model::$table property for example, but there could well be cases where it's not so obvious something has broken and for the consequences to be more severe. Particularly for less experienced devs.

Would be interested in the opinion of others!

GrahamCampbell commented 4 years ago

Yeh, this is worth discussion, and this is the right place for it (and not on closed/merged PRs). :)

GrahamCampbell commented 4 years ago

Something we could consider is moving to symfony's inflector in Laravel 8 or 9.

fulopattila122 commented 4 years ago

Something we could consider is moving to symfony's inflector in Laravel 8 or 9.

What's the major difference between Symfony's and Doctrine's Inflector?