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 f7585ac0
authored
Sep 29, 2018
by
Sushant
Committed by
GitHub
Sep 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: fix memory leak due to instance reference by isImmutable (#9973)
1 parent
6382078a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
16 deletions
lib/instance-validator.js
lib/utils/validator-extras.js
lib/instance-validator.js
View file @
f7585ac
...
@@ -7,7 +7,6 @@ const Promise = require('./promise');
...
@@ -7,7 +7,6 @@ const Promise = require('./promise');
const
DataTypes
=
require
(
'./data-types'
);
const
DataTypes
=
require
(
'./data-types'
);
const
BelongsTo
=
require
(
'./associations/belongs-to'
);
const
BelongsTo
=
require
(
'./associations/belongs-to'
);
const
validator
=
require
(
'./utils/validator-extras'
).
validator
;
const
validator
=
require
(
'./utils/validator-extras'
).
validator
;
const
extendModelValidations
=
require
(
'./utils/validator-extras'
).
extendModelValidations
;
/**
/**
* Instance Validator.
* Instance Validator.
...
@@ -54,8 +53,6 @@ class InstanceValidator {
...
@@ -54,8 +53,6 @@ class InstanceValidator {
* @private
* @private
*/
*/
this
.
inProgress
=
false
;
this
.
inProgress
=
false
;
extendModelValidations
(
modelInstance
);
}
}
/**
/**
...
@@ -310,7 +307,7 @@ class InstanceValidator {
...
@@ -310,7 +307,7 @@ class InstanceValidator {
if
(
!
Array
.
isArray
(
validatorArgs
))
{
if
(
!
Array
.
isArray
(
validatorArgs
))
{
if
(
validatorType
===
'isImmutable'
)
{
if
(
validatorType
===
'isImmutable'
)
{
validatorArgs
=
[
validatorArgs
,
field
];
validatorArgs
=
[
validatorArgs
,
field
,
this
.
modelInstance
];
}
else
if
(
isLocalizedValidator
||
validatorType
===
'isIP'
)
{
}
else
if
(
isLocalizedValidator
||
validatorType
===
'isIP'
)
{
validatorArgs
=
[];
validatorArgs
=
[];
}
else
{
}
else
{
...
...
lib/utils/validator-extras.js
View file @
f7585ac
...
@@ -64,19 +64,12 @@ const extensions = {
...
@@ -64,19 +64,12 @@ const extensions = {
};
};
exports
.
extensions
=
extensions
;
exports
.
extensions
=
extensions
;
function
extendModelValidations
(
modelInstance
)
{
/** Instance based validators */
const
extensions
=
{
validator
.
isImmutable
=
function
(
value
,
validatorArgs
,
field
,
modelInstance
)
{
isImmutable
(
str
,
param
,
field
)
{
return
modelInstance
.
isNewRecord
||
modelInstance
.
dataValues
[
field
]
===
modelInstance
.
_previousDataValues
[
field
];
return
modelInstance
.
isNewRecord
||
modelInstance
.
dataValues
[
field
]
===
modelInstance
.
_previousDataValues
[
field
];
};
}
};
_
.
forEach
(
extensions
,
(
extend
,
key
)
=>
{
validator
[
key
]
=
extend
;
});
}
exports
.
extendModelValidations
=
extendModelValidations
;
/** Extra validators */
validator
.
notNull
=
function
(
val
)
{
validator
.
notNull
=
function
(
val
)
{
return
!
[
null
,
undefined
].
includes
(
val
);
return
!
[
null
,
undefined
].
includes
(
val
);
};
};
...
...
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