From @dmarcelino on May 16, 2015 12:30
Originally reported in balderdashy/waterline#698: when executing .update() if the record contains an array, this array becomes a string in the afterUpdate values.
A failing test has been added in balderdashy/waterline-adapter-tests#73 and only sails-mysql breaks it, build results in https://travis-ci.org/balderdashy/waterline-adapter-tests/jobs/62815681#L556
Original issue balderdashy/waterline#698 reported by @chadxz:
When I update a record in the database (using 'sails-mysql' adapter), the values passed to the afterUpdate lifecycle callback looks like this:
{ id: '4d094885-7e6f-4454-91f0-6a55e3d1b6eb',
accountId: 'webhooksControllerTestAccountId',
appId: 'webhooksControllerTestAppId',
endpointId: 'updatedEndpointId',
webhookURL: 'updatedWebhookURL',
groups: '["updatedGroups"]',
createdAt: Thu Oct 23 2014 15:34:12 GMT-0500 (CDT),
updatedAt: Thu Oct 23 2014 15:34:12 GMT-0500 (CDT) }
As you can tell from the model definition below, the groups field is an array. I have checked to ensure that i'm passing it an array when its going in, and reading it back out of the database the value is an array, but the value passed to the afterUpdate is a string
I can probably fix this and issue a PR, but i was wondering where I should start looking for the issue... would the code responsible for serializing arrays to string and back be in waterline or sails-mysql?
model definition:
module.exports = {
attributes: {
id: {
type: 'string',
primaryKey: true
},
accountId: {
type: 'string',
required: true
},
appId: {
type: 'string',
required: true
},
endpointId: {
type: 'string',
required: true
},
webhookURL: {
type: 'string',
required: true
},
groups: {
type: 'array',
defaultsTo: []
},
toJSON: function () {
var obj = this.toObject();
delete obj.createdAt;
delete obj.updatedAt;
return obj;
}
}
Copied from original issue: balderdashy/sails-mysql#219
From @dmarcelino on May 16, 2015 12:30
Originally reported in balderdashy/waterline#698: when executing
.update()if the record contains an array, this array becomes a string in theafterUpdatevalues.A failing test has been added in balderdashy/waterline-adapter-tests#73 and only sails-mysql breaks it, build results in https://travis-ci.org/balderdashy/waterline-adapter-tests/jobs/62815681#L556
Original issue balderdashy/waterline#698 reported by @chadxz:
Copied from original issue: balderdashy/sails-mysql#219