sequelize/sequelize — pull request #2474 by overlookmotel (2014-10-24 16:15:21+00:00)
Title: User model names rather than singularized table names

My previous PR about singularizing model names for auto-created through tables (https://github.com/sequelize/sequelize/pull/2429) was rather long, so is taking some time to review. I'm going to re-factor it to make it clearer.

In the meantime, this PR fixes 3 places in the code which I consider to be bugs.

In each case, in order to make the `as` alias of a model, the code uses a model's table name and singularizes it, whereas I feel it should reference the model name. Where the table has been created by Sequelize `sync()`, this makes no difference - a model called 'User' has table name 'Users' which when singularized is of course 'User' so `Utils.singularize(model.tableName)` produces that same result as `model.name`.

In my opinion, Sequelize is a database abstraction layer, so the table names should never need to be referenced in user code. Then you can change the tables in a DB without ever having to alter code.

If you agree, I hope it may be possible to merge this PR fairly quickly. An update I want to push to [sequelize-hierarchy](https://github.com/overlookmotel/sequelize-hierarchy) plugin depends on it. I hope I'm not being too pushy!