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

Suggestion: Remove all aliases in v5 #9372

Closed
5 tasks
SimonSchick opened this issue Apr 29, 2018 · 14 comments
Closed
5 tasks

Suggestion: Remove all aliases in v5 #9372

SimonSchick opened this issue Apr 29, 2018 · 14 comments
Labels
breaking change For issues and PRs. Changes that break compatibility and require a major version increment. good first issue For issues. An issue that is a good choice for first-time contributors.
Milestone

Comments

@SimonSchick
Copy link
Contributor

SimonSchick commented Apr 29, 2018

Not sure if I'm too late here but over the years Sequelize has create many many aliases functions. I think it would be a good idea to remove the aliases with the next major release.

  • find vs. findOne
  • findById vs. findByPrimary
  • afterBulkDestroy vs afterBulkDelete
  • addHook v. hook
  • VIRTUAL vs NONE

Edit: Formatting

@sushantdhiman sushantdhiman added breaking change For issues and PRs. Changes that break compatibility and require a major version increment. suggestion labels Apr 30, 2018
@sushantdhiman
Copy link
Contributor

I have edited your post for better readability.

Good idea overall, we need to deprecate duplicate cases first, then remove them from master. This change should be easy to implement in small PRs

@sushantdhiman sushantdhiman added this to the v5 milestone Apr 30, 2018
@sushantdhiman sushantdhiman added the good first issue For issues. An issue that is a good choice for first-time contributors. label Apr 30, 2018
@SimonSchick
Copy link
Contributor Author

@sunshinewyin the ones Iisted where just examples, there are quite a few more.

@SimonSchick
Copy link
Contributor Author

@sushantdhiman I'll see if I can do that.

@madmoizo
Copy link
Contributor

madmoizo commented Sep 14, 2018

As requested by @sushantdhiman

Final

Remove Keep
insertOrUpdate upsert ✔️
findById, findByPrimary findByPk ✔️
find findOne ✔️
findAndCount findAndCountAll ✔️
findOrInitialize findOrBuild ✔️
beforeConnection beforeConnect ✔️
[after,before]BulkDelete [after,before]BulkDestroy ✔️
[after,before]Delete [after,before]Destroy ✔️
hook addHook ✔️
updateAttributes update ✔️
DOUBLE PRECISION DOUBLE
NUMERIC DECIMAL
NONE VIRTUAL ✔️
asIs literal ✔️
Sequelize.condition Sequelize.where ✔️
Sequelize.prototype.Utils Sequelize.Utils ✔️
Sequelize.prototype.Promise Sequelize.Promise ✔️
Sequelize.prototype.TableHints Sequelize.TableHints ✔️
Sequelize.prototype.Op Sequelize.Op ✔️
Sequelize.prototype.Transaction Sequelize.Transaction ✔️
Sequelize.prototype.Model Sequelize.Model ✔️
Sequelize.prototype.Deferrable Sequelize.Deferrable ✔️
Sequelize.prototype.Error Sequelize.Error ✔️
Sequelize.prototype[error] Sequelize[error] ✔️

Question

Should we add deprecation message or just add the migration table in the changelog ?

@sushantdhiman
Copy link
Contributor

Thanks @frlinw , A few changes

  1. Keep both hasHooks/hasHook.
  2. upsert is well known name so we can keep this
  3. findByPk suggestion accepted

Should we add deprecation message or just add the migration table in the changelog ?

I can take care of deprecating them from v4 once these changes land to master

@SimonSchick
Copy link
Contributor Author

Yea sorry, been super busy, cudos to @frlinw for taking over.

@madmoizo
Copy link
Contributor

I started to work on it. I'm doing some reorg for imports (require) in test files because it's a mess, will make a PR after that.

@madmoizo
Copy link
Contributor

beforeConnection added to the list, it's not used internally and it's the last hook alias

@madmoizo madmoizo mentioned this issue Sep 18, 2018
4 tasks
@sushantdhiman
Copy link
Contributor

Implemented in #9933

@SimonSchick
Copy link
Contributor Author

Hey, what about all the prototype aliases eg.

Sequelize.prototype.fn = Sequelize.fn;
Sequelize.prototype.col = Sequelize.col;
Sequelize.prototype.cast = Sequelize.cast;
Sequelize.prototype.literal = Sequelize.literal;
Sequelize.prototype.and = Sequelize.and;
Sequelize.prototype.or = Sequelize.or;
Sequelize.prototype.json = Sequelize.json;
Sequelize.prototype.where = Sequelize.where;
Sequelize.prototype.validate = Sequelize.prototype.authenticate;

and more?

@sushantdhiman
Copy link
Contributor

They are ok for now

@SimonSchick
Copy link
Contributor Author

One more, what about the new DATATYPE() vs. DATETYPE() calls?

@sushantdhiman
Copy link
Contributor

new DATETYPE() is sure more verbose than DATETYPE, I prefer short functional syntax in this case. Once I tried to convert datatypes to classes but stopped just because of this issue

@SimonSchick
Copy link
Contributor Author

Another alias I came across is Transaction.LOCK vs. transactionInstance.LOCK, all other enums like that are static, why is that one available on the instance as well?

Also at the same time that section should be optimized, accessing enums shouldn't invoke object creation, we should just Object.freeze and assign it directly :)

krzepah pushed a commit to krzepah/mutasync-server that referenced this issue Jul 10, 2019
With V5 aliases have been removed ; (see sequelize/sequelize#9372 )
krzepah pushed a commit to krzepah/mutasync-server that referenced this issue Jul 10, 2019
with V5 aliases have been removed ; (see sequelize/sequelize#9372 )
krzepah pushed a commit to krzepah/mutasync-server that referenced this issue Jul 10, 2019
with V5 aliases have been removed ; (see sequelize/sequelize#9372 )
aichbauer pushed a commit to aichbauer/express-rest-api-boilerplate that referenced this issue Jul 21, 2019
* Chore: npm audit fix --force

* Chore: add core-js@2 dependency
babel/babel#9734  - in project error was : Cannot find module 'core-js/modules/es6.object.define-property' from 'index.js'

* Test: test fix after sequelize update
with V5 aliases have been removed ; (see sequelize/sequelize#9372 )

* Chore: updated yarn.lock
KimuraDanaka119 added a commit to KimuraDanaka119/express-rest-api-boilerplate that referenced this issue Jun 4, 2023
* Chore: npm audit fix --force

* Chore: add core-js@2 dependency
babel/babel#9734  - in project error was : Cannot find module 'core-js/modules/es6.object.define-property' from 'index.js'

* Test: test fix after sequelize update
with V5 aliases have been removed ; (see sequelize/sequelize#9372 )

* Chore: updated yarn.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change For issues and PRs. Changes that break compatibility and require a major version increment. good first issue For issues. An issue that is a good choice for first-time contributors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants