Skip to content

Only support Node v4.0.0 and up #5205

Closed

Description

@mickhansen

To lower CI times for increased productivity and sense of well being.

Activity

  1. added
    breaking change
    on Jan 13, 2016
  2. added this to the 4.0 milestone on Jan 13, 2016
  3. alitaheri commented on Jan 13, 2016

    @alitaheri
    Contributor

    I agree with this 👍

  4. verdier commented on Jan 13, 2016

    @verdier
    Contributor

    Agree 👍 and project could use ES6 features such as class or even co...?! 🔋

  5. mickhansen commented on Jan 13, 2016

    @mickhansen
    ContributorAuthor

    @verdier We're likely not moving to generators internally, since ideally we'd still have unofficial support for older v8 versions with less features.

    We plan to add class support yes, however we still need to support the old sequelize.define :)

  6. felixfbecker commented on Jan 13, 2016

    @felixfbecker
    Contributor

    And dont forget how much the codebase would benefit from arrow functions (also the docs).
    Maybe this would also be the time to refactor the code so that "instances" are actually instances of models? E.g. Sequelize.prototype.define would return an anonymous class that extends the Model class, and "instances" will actually be instances of that class.

  7. felixfbecker commented on Jan 13, 2016

    @felixfbecker
    Contributor

    And optionally, you can pass define you own class as the first argument as long as it extends Model, so you can actually define getters/setters as real getters/setters and customize your model with everything, even toJson().

  8. mickhansen commented on Jan 13, 2016

    @mickhansen
    ContributorAuthor

    @felixfbecker yeah the plan is to change it so instances are instanceas of models, we need to change a lot of model checks though.

    Plan is to support both ES6 classes and define.
    As for arrow functions, definitely :) Away with var self = this

  9. felixfbecker commented on Jan 13, 2016

    @felixfbecker
    Contributor

    Then in the very distant ES7 future instead of define you could use decorators on your model class

    @attributes({
      ...
    })
    @tableName('...')
    class Test extends Sequelize.Model { ... }
  10. mickhansen commented on Jan 13, 2016

    @mickhansen
    ContributorAuthor

    @felixfbecker yeah, there's another issue for ES6 class support, you can add your help and opinons here.
    For ES6 we're probably looking at something like:

    class Test extends Sequelize.Model {
      static tableName () => 'test'
      static attributes () => ({
        firstName: Sequelize.STRING
      })
    }
  11. felixfbecker commented on Jan 13, 2016

    @felixfbecker
    Contributor

    @mickhansen No, please please please. Don't do this. Thats what I hate the most about PHP ORMs, that just because the language is so inflexible you always have to implement these methods that do nothing but return the configuration. But Javascript is flexible. You can assign stuff on classes. You can build classes dynamically. Think about it, currently define is basically a class factory. You pass it arguments beforehand that define how this new model will map to the database.

    With a class based approach, this would map perfectly to decorators - which are nothing but a function that take a class (or anything) and decorate it with additional info - at declaration time. Until decorators are here, this would mean that you simply pass define the class as a first argument, and the additional info as second argument.

    I think static methods should have nothing to do with that additional info. You could add your own static methods like findByMyCustomAttribute(), just like you could add your own instance methods and getters and setters. It also doesnt make sense - the table name is never dynamic. It should be defined once and not returned by a method. Btw, your example doesnt work in ES6, as there are no arrow methods on classes. You would have to write a full method with a return statement.

    Just my 0.02€

  12. mickhansen commented on Jan 14, 2016

    @mickhansen
    ContributorAuthor

    @felixfbecker the ES6 class system does now allow static properties defined in the class method.
    Decorators are not here for everyone yet, and we'd love to support ES6 classes fully still.

    What would you suggest, with a code example, instead of going full ES6 classes?
    I suggested this syntax because that's how React does it and i find that to be okay, but i certainly welcome any suggestions :)

    The implementations however needs to be mappable from sequelize.define()

  13. verdier commented on Jan 14, 2016

    @verdier
    Contributor

    @mickhansen @laggingreflex

    Just to let you know, here is what we use today: (ES7 + Decorators + Babel)

    @model()
    class MyModel {
     @attribute(Sequelize.INTEGER)
     @validate({ min: 0 })
     hours;
    
     @hook('afterValidate')
     async validate() {
     }
    
     ...
    }

    But that's not a solution for ES6 without transpiler... For ES6 we could have something like that:

    class MyModel extends Sequelize.ModelFactory({
     hours: {
      type: Sequelize.INTEGER,
      validate: { min: 0 }
     }
    }) {
     beforeValidate(options) {
     }
    }

    and, bonus, to use co (we have build a minimalistic lib co-wrap-proto):

    class MyModel extends Sequelize.ModelFactory({
     hours: {
      type: Sequelize.INTEGER,
      validate: { min: 0 }
     }
    }) {
     *beforeValidate(options) {
     }
    }
    MyModel = coWrapProto(MyModel); // Wrap all generator ownProperties into `co.wrap`
  14. mickhansen commented on Jan 14, 2016

    @mickhansen
    ContributorAuthor

    Thanks for the suggestions @verdier, although the ModelFactory stuff seems non-idiomatic

  15. mickhansen commented on Jan 14, 2016

    @mickhansen
    ContributorAuthor

    ES7+ Property Initializers would solve this even better than decorators

  16. 14 remaining items

  17. overlookmotel commented on Jan 15, 2016

    @overlookmotel
    Contributor

    To return to original subject of this issue, how about continuing to test against node v0.12 in Travis but (1) making sure those test runs are scheduled after the v4 and v5 test runs, and (2) marking them as allowed to fail in Travis?

    That way you'd get the green tick from Travis quicker, but still be able to keep an eye on whether anything is broken on node v0.12.

  18. verdier commented on Jan 15, 2016

    @verdier
    Contributor

    What about ES6 features?

  19. overlookmotel commented on Jan 15, 2016

    @overlookmotel
    Contributor

    @verdier Well @mickhansen was saying he'd like v0.12 to remain unofficially supported but to stop testing against it to speed up Travis. I have no idea how support for both v0.12 and ES6 is going to be achieved - I'm just saying that if the aim is to maintain some support for v0.12, we need some indication of when things have got broken.

  20. verdier commented on Jan 15, 2016

    @verdier
    Contributor

    There is no support for ES6 in node 0.12 and even with --harmony it's still very incomplete. One class or => somewhere in the code and none of the v0.12 tests will pass...

  21. mickhansen commented on Jan 15, 2016

    @mickhansen
    ContributorAuthor

    We will be doing ES6 through babel, we'll be compiling to code that should still run on Node v0.10.
    We just don't want to bother with running CI for it. Having 0.12 as an allowed failure could be a way to go.

  22. felixfbecker commented on Jan 15, 2016

    @felixfbecker
    Contributor

    Should this also mean to drop the bluebird dependency?

  23. mickhansen commented on Jan 15, 2016

    @mickhansen
    ContributorAuthor

    No, ES6 promises are slower and lack features we rely on, and do not necessarily exist in older versions.

  24. sushantdhiman commented on Jan 15, 2016

    @sushantdhiman
    Contributor

    Yes please remove other Node and IO versions from CI, +1

  25. overlookmotel commented on Jan 16, 2016

    @overlookmotel
    Contributor

    I think I mentioned in another issue thread I've been wondering if there's a way to speed up the test runs by running multiple tests in parallel (within the same Travis process). This would speed things up a lot as most of the time is spent waiting for async IO with the database. But I don't know if anyone's already built something like this for mocha.

  26. mickhansen commented on Jan 16, 2016

    @mickhansen
    ContributorAuthor

    @overlookmotel Tricky for our integration tests which all hit the database though, would have to have isolated databases, but i suppose that could actually be doable on Travis.

  27. sushantdhiman commented on May 24, 2016

    @sushantdhiman
    Contributor

    Can it be closed now as #5918 has been merged to master ? @janmeier @mickhansen

  28. overlookmotel commented on May 24, 2016

    @overlookmotel
    Contributor

    Where shall we discuss what ES6 features should be permitted in Sequelize v4 codebase? Or is it basically anything that's supported in node v4?

  29. mickhansen commented on May 24, 2016

    @mickhansen
    ContributorAuthor
  30. mickhansen commented on May 24, 2016

    @mickhansen
    ContributorAuthor

    @overlookmotel i guess basically anything that's supported by v4, but we haven't decided yet.

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 change

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions