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 2123ee51
authored
Nov 30, 2017
by
Jozef Hartinger
Committed by
Sushant
Nov 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model): pick own properties for attributes / getters / sanitizors (fix #8719) (#8720)
1 parent
5c3b4e3b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
lib/dialects/sqlite/query.js
lib/model.js
test/integration/model/attributes.test.js
lib/dialects/sqlite/query.js
View file @
2123ee5
...
...
@@ -184,7 +184,7 @@ class Query extends AbstractQuery {
});
}
return
tableTypes
[
name
]
return
tableTypes
.
hasOwnProperty
(
name
)
?
query
.
applyParsers
(
tableTypes
[
name
],
value
)
:
value
;
});
...
...
lib/model.js
View file @
2123ee5
...
...
@@ -3139,7 +3139,7 @@ class Model {
options
=
options
||
{};
if
(
key
)
{
if
(
this
.
_customGetters
[
key
]
&&
!
options
.
raw
)
{
if
(
this
.
_customGetters
.
hasOwnProperty
(
key
)
&&
!
options
.
raw
)
{
return
this
.
_customGetters
[
key
].
call
(
this
,
key
,
options
);
}
if
(
options
.
plain
&&
this
.
_options
.
include
&&
this
.
_options
.
includeNames
.
indexOf
(
key
)
!==
-
1
)
{
...
...
@@ -3298,7 +3298,7 @@ class Model {
}
// If there's a data type sanitizer
if
(
!
(
value
instanceof
Utils
.
SequelizeMethod
)
&&
this
.
constructor
.
_dataTypeSanitizers
[
key
]
)
{
if
(
!
(
value
instanceof
Utils
.
SequelizeMethod
)
&&
this
.
constructor
.
_dataTypeSanitizers
.
hasOwnProperty
(
key
)
)
{
value
=
this
.
constructor
.
_dataTypeSanitizers
[
key
].
call
(
this
,
value
,
options
);
}
...
...
test/integration/model/attributes.test.js
View file @
2123ee5
...
...
@@ -71,6 +71,31 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
it
(
'allows for an attribute to be called "toString"'
,
function
()
{
const
Person
=
this
.
sequelize
.
define
(
'person'
,
{
name
:
Sequelize
.
STRING
,
nick
:
Sequelize
.
STRING
},
{
timestamps
:
false
});
return
this
.
sequelize
.
sync
({
force
:
true
})
.
then
(()
=>
Person
.
create
({
name
:
'Jozef'
,
nick
:
'Joe'
}))
.
then
(()
=>
Person
.
findOne
({
attributes
:
[
'nick'
,
[
'name'
,
'toString'
]
],
where
:
{
name
:
'Jozef'
}
}))
.
then
(
person
=>
{
expect
(
person
.
dataValues
[
'toString'
]).
to
.
equal
(
'Jozef'
);
expect
(
person
.
get
(
'toString'
)).
to
.
equal
(
'Jozef'
);
});
});
});
});
});
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