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

findAndCountAll() and count() pollutes options.includes object #4191

Closed
atorkhov opened this Issue Jul 26, 2015 · 2 comments

Comments

3 participants
@atorkhov
Contributor

atorkhov commented Jul 26, 2015

findAndCountAll() and count() pollutes options.includes object that was passed to the call. This is a problem if I want to store and reuse query options sometime later.

@mickhansen mickhansen added the bug label Jul 27, 2015

@mickhansen

This comment has been minimized.

Contributor

mickhansen commented Jul 27, 2015

We need options = Model.$optClone(options) about here: https://github.com/sequelize/sequelize/blob/master/lib/model.js#L1494

@harish2704

This comment has been minimized.

Contributor

harish2704 commented Aug 24, 2015

Yes. I can confirm that at-least Mode.count method pollutes the options .
Because of this bug, A typical pagiante function like this

var store = {};
return model.count(modelOpts)
.bind(store)
  .then(function(count){
    this.count = count;
    var paginationParams = {
      count: count,
      page: paginationOpts.page,
      size: paginationOpts.size,
    };
    var pagination = paginator.paginate( paginationParams );
    this.pagination = pagination;
    modelOpts.offset = pagination.start-1;
    modelOpts.limit = pagination.size;
    return model.findAll( modelOpts );
  });

Is not working.

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