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

3.0, Inflector, Missing uninflected singular rule makes address->addres in bake #5428

Closed
spiliot opened this issue Dec 17, 2014 · 11 comments
Closed
Assignees
Milestone

Comments

@spiliot
Copy link
Contributor

spiliot commented Dec 17, 2014

In 2.x there is an uninflected rule for singular words ending in .*ss.

Since the inflector structure seems to have changed in 3.0, if a table contains an address_id bake looks for a table addres (note single ending s).

Obviously Inflector::rules('singular', ['/^address/i' => '\0']) does the trick for this word but I think a more global solution is needed.

@dereuromark dereuromark added this to the 3.0.0 milestone Dec 17, 2014
@dereuromark
Copy link
Member

I think your problem is a different one.
The inflector works as expected. You should never try to singularize an already singular word (address, plural would be addresses which correctly inflects to address then).
Thus the error must be somewhere further down the chain, where it shouldn't try to inflect "address" in the first place, as all "..._id" contain the singular form already.

@spiliot
Copy link
Contributor Author

spiliot commented Dec 17, 2014

Indeed, good point. But is it a bug or a feature of bake trying to singularize?

@markstory
Copy link
Member

I think the issue is bake possibly singularizing a singular value. That will go wrong in many ways.

@spiliot spiliot changed the title 3.0, Inflector, Missing uninflected singular rule makes address->addres 3.0, Inflector, Missing uninflected singular rule makes address->addres in bake Dec 17, 2014
@ADmad
Copy link
Member

ADmad commented Dec 19, 2014

Didn't we fix the issue of bake trying to singularize already singular names?

@dereuromark
Copy link
Member

@spiliot Would be good to know if you used the latest version and/or latest 3.0 branch and confirmed that this is still an issue.

@spiliot
Copy link
Contributor Author

spiliot commented Dec 19, 2014

I'm still getting it in the latest 1452111e44fe2aad9.

The relevant field in the table is address_id smallint(5) UNSIGNED

Stack trace (if it is of any help):
#0 /var/www/caketest3/vendor/cakephp/cakephp/src/Database/Schema/Collection.php(92): Cake\Database\Schema\Collection->_reflect('Column', 'addres', Array, Object(Cake\Database\Schema\Table))
#1 /var/www/caketest3/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(62): Cake\Database\Schema\Collection->describe('addres', Array)
#2 /var/www/caketest3/vendor/cakephp/cakephp/src/ORM/Table.php(339): Cake\Database\Schema\CachedCollection->describe('addres')
#3 /var/www/caketest3/vendor/cakephp/cakephp/src/ORM/Table.php(412): Cake\ORM\Table->schema()
#4 /var/www/caketest3/plugins/Bake/src/Shell/Task/ViewTask.php(432): Cake\ORM\Table->primaryKey()
#5 /var/www/caketest3/plugins/Bake/src/Shell/Task/ViewTask.php(267): Bake\Shell\Task\ViewTask->_associations(Object(App\Model\Table\CustomersTable))
#6 /var/www/caketest3/plugins/Bake/src/Shell/Task/ViewTask.php(137): Bake\Shell\Task\ViewTask->_loadController()
#7 /var/www/caketest3/plugins/Bake/src/Shell/BakeShell.php(222): Bake\Shell\Task\ViewTask->main('Customers')
#8 [internal function]: Bake\Shell\BakeShell->all('customers')

@dereuromark
Copy link
Member

Sounds like your associations could be defined wrongly. Can you please add them here?

@spiliot
Copy link
Contributor Author

spiliot commented Dec 19, 2014

I don't have any associations manually setup, I'm running cake bake all customers

@markstory markstory self-assigned this Dec 19, 2014
@ADmad
Copy link
Member

ADmad commented Dec 24, 2014

The problem is ConventionsTrait::_modelNameFromKey() method.

Inflector::pluralize(Inflector::classify('address')); will return Addres. Swapping the order of inflection methods yields expected result.

@markstory
Copy link
Member

I can take care of that tonight.

@markstory
Copy link
Member

Closing as a pull request is open now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants