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 f6b78555
authored
Oct 11, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't try to select the primary key for models without primary key. Closes #4607
1 parent
492dad28
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletions
changelog.md
lib/model.js
test/unit/model/findall.test.js
changelog.md
View file @
f6b7855
# Next
-
[
FIXED
]
Partial rollback of datatype validations by hiding it behind the
`typeValidation`
flag.
-
[
FIXED
]
Don't try to select the primary key for models without primary key
[
#4607
](
https://github.com/sequelize/sequelize/issues/4607
)
# 3.11.0
-
[
INTERNALS
]
Updated dependencies
[
#4594
](
https://github.com/sequelize/sequelize/pull/4594
)
...
...
lib/model.js
View file @
f6b7855
...
...
@@ -1354,7 +1354,7 @@ Model.prototype.findAll = function(options) {
validateIncludedElements
.
call
(
this
,
options
,
tableNames
);
// If we're not raw, we have to make sure we include the primary key for deduplication
if
(
!
options
.
raw
&&
options
.
attributes
.
indexOf
(
this
.
primaryKeyAttribute
)
===
-
1
)
{
if
(
options
.
attributes
&&
!
options
.
raw
&&
this
.
primaryKeyAttribute
&&
options
.
attributes
.
indexOf
(
this
.
primaryKeyAttribute
)
===
-
1
)
{
options
.
originalAttributes
=
options
.
attributes
;
options
.
attributes
=
[
this
.
primaryKeyAttribute
].
concat
(
options
.
attributes
);
}
...
...
test/unit/model/findall.test.js
View file @
f6b7855
...
...
@@ -68,6 +68,25 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]);
});
});
it
(
'works for models without PK #4607'
,
function
()
{
var
Model
=
current
.
define
(
'model'
,
{},
{
timestamps
:
false
});
var
Foo
=
current
.
define
(
'foo'
);
Model
.
hasOne
(
Foo
);
Model
.
removeAttribute
(
'id'
);
return
Model
.
findAll
({
attributes
:
{
include
:
[
'name'
]
},
include
:
[
Foo
]
}).
bind
(
this
).
then
(
function
()
{
expect
(
this
.
stub
.
getCall
(
0
).
args
[
2
].
attributes
).
to
.
deep
.
equal
([
'name'
]);
});
});
});
});
});
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