不要怂,就是干,撸起袖子干!

Commit e8dc3b27 by Mick Hansen

Fix #1792 - Don't coerce attribute names to string when checking for mappings

1 parent 89ec5c00
Showing with 8 additions and 3 deletions
......@@ -1461,6 +1461,9 @@ module.exports = (function() {
var mapFieldNames = function(options, Model) {
if (options.attributes) {
options.attributes = options.attributes.map(function(attr) {
// Object lookups will force any variable to strings, we don't want that for special objects etc
if (typeof attr !== "string") return attr;
// Map attributes to aliased syntax attributes
if (Model.rawAttributes[attr] && Model.rawAttributes[attr].field) {
return [Model.rawAttributes[attr].field, attr];
}
......@@ -1470,9 +1473,11 @@ module.exports = (function() {
if (options.where) {
for (var attr in options.where) {
if (Model.rawAttributes[attr] && Model.rawAttributes[attr].field) {
options.where[Model.rawAttributes[attr].field] = options.where[attr];
delete options.where[attr];
if (typeof attr === "string") {
if (Model.rawAttributes[attr] && Model.rawAttributes[attr].field) {
options.where[Model.rawAttributes[attr].field] = options.where[attr];
delete options.where[attr];
}
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!