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
不要怂,就是干,撸起袖子干!
You need to sign in or sign up before continuing.
Commit e3bba447
authored
Sep 12, 2018
by
Dario
Committed by
Sushant
Sep 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(count): duplicate mapping of fields break scopes (#9821)
1 parent
2c3a6e71
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
lib/model.js
test/integration/model/scope/count.test.js
lib/model.js
View file @
e3bba44
...
@@ -1850,8 +1850,6 @@ class Model {
...
@@ -1850,8 +1850,6 @@ class Model {
col
=
this
.
name
+
'.'
+
(
options
.
col
||
this
.
primaryKeyField
);
col
=
this
.
name
+
'.'
+
(
options
.
col
||
this
.
primaryKeyField
);
}
}
Utils
.
mapOptionFieldNames
(
options
,
this
);
options
.
plain
=
!
options
.
group
;
options
.
plain
=
!
options
.
group
;
options
.
dataType
=
new
DataTypes
.
INTEGER
();
options
.
dataType
=
new
DataTypes
.
INTEGER
();
options
.
includeIgnoreAttributes
=
false
;
options
.
includeIgnoreAttributes
=
false
;
...
...
test/integration/model/scope/count.test.js
View file @
e3bba44
...
@@ -16,6 +16,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -16,6 +16,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
this
.
ScopeMe
=
this
.
sequelize
.
define
(
'ScopeMe'
,
{
this
.
ScopeMe
=
this
.
sequelize
.
define
(
'ScopeMe'
,
{
username
:
Sequelize
.
STRING
,
username
:
Sequelize
.
STRING
,
email
:
Sequelize
.
STRING
,
email
:
Sequelize
.
STRING
,
aliasValue
:
{
field
:
'alias_value'
,
type
:
Sequelize
.
INTEGER
},
access_level
:
Sequelize
.
INTEGER
,
access_level
:
Sequelize
.
INTEGER
,
other_value
:
Sequelize
.
INTEGER
other_value
:
Sequelize
.
INTEGER
},
{
},
{
...
@@ -65,7 +69,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -65,7 +69,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
}
}]
}]
};
};
},
withAliasedField
:
{
where
:
{
aliasValue
:
{
[
Sequelize
.
Op
.
ne
]:
1
}
}
}
},
}
}
});
});
this
.
Child
.
belongsTo
(
this
.
ScopeMe
);
this
.
Child
.
belongsTo
(
this
.
ScopeMe
);
...
@@ -73,10 +82,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -73,10 +82,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(()
=>
{
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(()
=>
{
const
records
=
[
const
records
=
[
{
username
:
'tony'
,
email
:
'tony@sequelizejs.com'
,
access_level
:
3
,
other_value
:
7
},
{
username
:
'tony'
,
email
:
'tony@sequelizejs.com'
,
access_level
:
3
,
other_value
:
7
,
aliasValue
:
12
},
{
username
:
'tobi'
,
email
:
'tobi@fakeemail.com'
,
access_level
:
10
,
other_value
:
11
},
{
username
:
'tobi'
,
email
:
'tobi@fakeemail.com'
,
access_level
:
10
,
other_value
:
11
,
aliasValue
:
5
},
{
username
:
'dan'
,
email
:
'dan@sequelizejs.com'
,
access_level
:
5
,
other_value
:
10
},
{
username
:
'dan'
,
email
:
'dan@sequelizejs.com'
,
access_level
:
5
,
other_value
:
10
,
aliasValue
:
1
},
{
username
:
'fred'
,
email
:
'fred@foobar.com'
,
access_level
:
3
,
other_value
:
7
}
{
username
:
'fred'
,
email
:
'fred@foobar.com'
,
access_level
:
3
,
other_value
:
7
,
aliasValue
:
10
}
];
];
return
this
.
ScopeMe
.
bulkCreate
(
records
);
return
this
.
ScopeMe
.
bulkCreate
(
records
);
}).
then
(()
=>
{
}).
then
(()
=>
{
...
@@ -113,6 +122,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -113,6 +122,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return
expect
(
this
.
ScopeMe
.
scope
(
'lowAccess'
).
count
({
where
:
{
username
:
'dan'
}})).
to
.
eventually
.
equal
(
1
);
return
expect
(
this
.
ScopeMe
.
scope
(
'lowAccess'
).
count
({
where
:
{
username
:
'dan'
}})).
to
.
eventually
.
equal
(
1
);
});
});
it
(
'should be able to merge scopes with where on aliased fields'
,
function
()
{
return
expect
(
this
.
ScopeMe
.
scope
(
'withAliasedField'
).
count
({
where
:
{
aliasValue
:
5
}
})).
to
.
eventually
.
equal
(
1
);
});
it
(
'should ignore the order option if it is found within the scope'
,
function
()
{
it
(
'should ignore the order option if it is found within the scope'
,
function
()
{
return
expect
(
this
.
ScopeMe
.
scope
(
'withOrder'
).
count
()).
to
.
eventually
.
equal
(
4
);
return
expect
(
this
.
ScopeMe
.
scope
(
'withOrder'
).
count
()).
to
.
eventually
.
equal
(
4
);
});
});
...
...
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