strongloop / strong-remoting

Communicate between objects in servers, mobile apps, and other servers.
www.strongloop.com
Other
105 stars 93 forks source link

Object values should not be coerced into Loopback models #254

Closed fabien closed 8 years ago

fabien commented 8 years ago

See: https://github.com/strongloop/loopback/issues/1806

When replacing this line: https://github.com/strongloop/strong-remoting/blob/master/lib/http-context.js#L213

With the following:

if (typeof val !== 'object' && Dynamic.canConvert(otype)) {
  val = dynamic(val, otype, ctx);
}

The previous behavior is preserved, and all failing test cases in my project pass. In theory it sounds great to cast data as much as possible, but in this case it causes a new Model instance to be created, which might have defaults set. These default values would then end up overwriting saved data when updating.

bajtos commented 8 years ago

Closing in favour of the solution described in https://github.com/strongloop/loopback/issues/1806#issuecomment-217393388, which has been already implemented and published.