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

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() { ...@@ -1461,6 +1461,9 @@ module.exports = (function() {
var mapFieldNames = function(options, Model) { var mapFieldNames = function(options, Model) {
if (options.attributes) { if (options.attributes) {
options.attributes = options.attributes.map(function(attr) { 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) { if (Model.rawAttributes[attr] && Model.rawAttributes[attr].field) {
return [Model.rawAttributes[attr].field, attr]; return [Model.rawAttributes[attr].field, attr];
} }
...@@ -1470,9 +1473,11 @@ module.exports = (function() { ...@@ -1470,9 +1473,11 @@ module.exports = (function() {
if (options.where) { if (options.where) {
for (var attr in options.where) { for (var attr in options.where) {
if (Model.rawAttributes[attr] && Model.rawAttributes[attr].field) { if (typeof attr === "string") {
options.where[Model.rawAttributes[attr].field] = options.where[attr]; if (Model.rawAttributes[attr] && Model.rawAttributes[attr].field) {
delete options.where[attr]; 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!