Skip to content

Filter input array of numbers gets modified to array of strings #1287

Closed
@hotaru355

Description

@hotaru355

This is more an "annoyance" than a bug and could possibly be fixed quickly. If an array of numbers is used in a filter, it's values will get modified once used in a query:

var arrayOfNumbers = [1, 2];
app.models.MyModel.find({
  where: {
    myId: {
      inq: arrayOfNumbers
    }
  }, function(err, myModels) {
    console.log(typeof arrayOfNumbers[0]); // "string"
  });

This is annoying, if the array is required for further tasks later on. Work-around:

inq:arrayOfNumbers.slice()

Here a repo to replicate the issue: https://github.com/hotaru355/issue1287

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions