Jason Sims
Jason Sims

Reputation: 1158

Waterline fails to honor model type

I'm having an issue where my model is defined with an attribute of type boolean but at some point it's being interpreted as a string.

For example, with a model that looks like this:

{
  attributes: {
    id: 'string'
    boolean_thing: {type: 'boolean', columnName: 'BooleanThing'},
  }
}

when given a request like this:

/api/foo?boolean_thing=false

will result in the where criteria being passed to the adapter looks like this:

{ 
  where: { 
    BooleanThing: 'false' 
  },
  limit: 30,
  skip: 0 
}

I'm currently running [email protected]. Does anyone know if this is a bug or a misconfiguration issue on my part?

Upvotes: 1

Views: 83

Answers (1)

mdunisch
mdunisch

Reputation: 3697

Maybe this problem: https://github.com/balderdashy/sails/issues/1818?

You can do this as a fix:

var bol = (req.params("boolean_thing") == "true");
mymodel.find().where({BooleanThing: bol}).exec(...

Upvotes: 1

Related Questions