Skip to content

Suggestion: Remove all aliases in v5 #9372

Closed

Description

@SimonSchick

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

Activity

  1. added
    breaking change
    on Apr 30, 2018
  2. sushantdhiman commented on Apr 30, 2018

    @sushantdhiman
    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

  3. added this to the v5 milestone on Apr 30, 2018
  4. added
    good first issue
    on Apr 30, 2018
  5. SimonSchick commented on Apr 30, 2018

    @SimonSchick
    ContributorAuthor

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

  6. SimonSchick commented on Apr 30, 2018

    @SimonSchick
    ContributorAuthor

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

  7. madmoizo commented on Sep 14, 2018

    @madmoizo
    Contributor

    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 ?

  8. sushantdhiman commented on Sep 14, 2018

    @sushantdhiman
    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

  9. SimonSchick commented on Sep 14, 2018

    @SimonSchick
    ContributorAuthor

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

  10. madmoizo commented on Sep 14, 2018

    @madmoizo
    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.

  11. madmoizo commented on Sep 15, 2018

    @madmoizo
    Contributor

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

  12. sushantdhiman commented on Sep 19, 2018

    @sushantdhiman
    Contributor

    Implemented in #9933

  13. SimonSchick commented on Oct 19, 2018

    @SimonSchick
    ContributorAuthor

    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?

  14. sushantdhiman commented on Oct 20, 2018

    @sushantdhiman
    Contributor

    They are ok for now

  15. SimonSchick commented on Oct 20, 2018

    @SimonSchick
    ContributorAuthor

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

  16. sushantdhiman commented on Oct 21, 2018

    @sushantdhiman
    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

  17. SimonSchick commented on Nov 17, 2018

    @SimonSchick
    ContributorAuthor

    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 :)

  18. added a commit that references this issue on Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changegood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions