Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 54b9cf37
authored
Feb 09, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all calls to mapFieldNames to Utils
1 parent
ff8a672f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
46 deletions
lib/model.js
lib/model.js
View file @
54b9cf3
...
...
@@ -716,7 +716,7 @@ module.exports = (function() {
if
(
options
.
attributes
===
undefined
)
{
options
.
attributes
=
Object
.
keys
(
this
.
tableAttributes
);
}
mapFieldNames
.
call
(
this
,
options
,
this
);
Utils
.
mapOptionFieldNames
(
options
,
this
);
options
=
paranoidClause
(
this
,
options
);
...
...
@@ -838,7 +838,7 @@ module.exports = (function() {
validateIncludedElements
.
call
(
this
,
options
);
}
mapFieldNames
.
call
(
this
,
options
,
this
);
Utils
.
mapOptionFieldNames
(
options
,
this
);
options
.
dataType
=
DataTypes
.
INTEGER
;
options
.
includeIgnoreAttributes
=
false
;
...
...
@@ -1442,7 +1442,7 @@ module.exports = (function() {
options
.
type
=
QueryTypes
.
BULKDELETE
;
mapFieldNames
.
call
(
this
,
options
,
this
);
Utils
.
mapOptionFieldNames
(
options
,
this
);
return
Promise
.
try
(
function
()
{
// Run before hook
...
...
@@ -1513,7 +1513,7 @@ module.exports = (function() {
var
self
=
this
,
instances
;
mapFieldNames
.
call
(
this
,
options
,
this
);
Utils
.
mapOptionFieldNames
(
options
,
this
);
return
Promise
.
try
(
function
()
{
// Run before hook
...
...
@@ -1697,7 +1697,7 @@ module.exports = (function() {
}
});
mapFieldNames
.
call
(
self
,
options
,
self
);
Utils
.
mapOptionFieldNames
(
options
,
self
);
// Run query to update all rows
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(
options
),
valuesUse
,
options
.
where
,
options
,
self
.
tableAttributes
).
then
(
function
(
affectedRows
)
{
...
...
@@ -1747,46 +1747,6 @@ 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
]
&&
attr
!==
Model
.
rawAttributes
[
attr
].
field
)
{
return
[
Model
.
rawAttributes
[
attr
].
field
,
attr
];
}
return
attr
;
});
}
if
(
options
.
where
)
{
var
attributes
=
options
.
where
,
attribute
,
rawAttribute
;
if
(
options
.
where
instanceof
Utils
.
and
||
options
.
where
instanceof
Utils
.
or
)
{
attributes
=
undefined
;
options
.
where
.
args
=
options
.
where
.
args
.
map
(
function
(
where
)
{
return
mapFieldNames
({
where
:
where
},
Model
).
where
;
});
}
if
(
attributes
)
{
for
(
attribute
in
attributes
)
{
rawAttribute
=
Model
.
rawAttributes
[
attribute
];
if
(
rawAttribute
&&
rawAttribute
.
field
!==
rawAttribute
.
fieldName
)
{
attributes
[
rawAttribute
.
field
]
=
attributes
[
attribute
];
delete
attributes
[
attribute
];
}
}
}
}
return
options
;
};
// private
// validateIncludedElements should have been called before this method
...
...
@@ -1998,7 +1958,7 @@ module.exports = (function() {
include
.
attributes
=
Object
.
keys
(
include
.
model
.
tableAttributes
);
}
include
=
map
FieldNames
(
include
,
include
.
model
);
include
=
Utils
.
mapOption
FieldNames
(
include
,
include
.
model
);
// pseudo include just needed the attribute logic, return
if
(
include
.
_pseudo
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment