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 dad03289
authored
Mar 16, 2016
by
Kevin Mannix
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated docs and tests for issues #5031 and #5489
1 parent
16b39c61
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
3 deletions
docs/docs/querying.md
test/integration/instance.test.js
test/unit/dialects/mysql/query-generator.test.js
test/unit/dialects/postgres/query-generator.test.js
test/unit/dialects/sqlite/query-generator.test.js
docs/docs/querying.md
View file @
dad0328
...
...
@@ -123,6 +123,7 @@ $gte: 6, // >= 6
$lt
:
10
,
// < 10
$lte
:
10
,
// <= 10
$ne
:
20
,
// != 20
$not
:
true
,
// IS NOT TRUE
$between
:
[
6
,
10
],
// BETWEEN 6 AND 10
$notBetween
:
[
11
,
15
],
// NOT BETWEEN 11 AND 15
$in
:
[
1
,
2
],
// IN [1, 2]
...
...
@@ -259,13 +260,13 @@ something.findOne({
// Will order by otherfunction(`col1`, 12, 'lalala') DESC
[
sequelize
.
fn
(
'otherfunction'
,
sequelize
.
col
(
'col1'
),
12
,
'lalala'
),
'DESC'
],
// Will order by name on an associated User
[
User
,
'name'
,
'DESC'
],
// Will order by name on an associated User aliased as Friend
[{
model
:
User
,
as
:
'Friend'
},
'name'
,
'DESC'
],
// Will order by name on a nested associated Company of an associated User
[
User
,
Company
,
'name'
,
'DESC'
],
]
...
...
test/integration/instance.test.js
View file @
dad0328
...
...
@@ -1851,6 +1851,42 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
});
it
(
'does not compare the existence of associations'
,
function
()
{
var
self
=
this
;
this
.
UserAssociationEqual
=
this
.
sequelize
.
define
(
'UserAssociationEquals'
,
{
username
:
DataTypes
.
STRING
,
age
:
DataTypes
.
INTEGER
},
{
timestamps
:
false
});
this
.
ProjectAssociationEqual
=
this
.
sequelize
.
define
(
'ProjectAssocationEquals'
,
{
title
:
DataTypes
.
STRING
,
overdue_days
:
DataTypes
.
INTEGER
},
{
timestamps
:
false
});
this
.
UserAssociationEqual
.
hasMany
(
this
.
ProjectAssociationEqual
,
{
as
:
'Projects'
,
foreignKey
:
'userId'
});
this
.
ProjectAssociationEqual
.
belongsTo
(
this
.
UserAssociationEqual
,
{
as
:
'Users'
,
foreignKey
:
'userId'
});
return
this
.
UserAssociationEqual
.
sync
({
force
:
true
}).
then
(
function
()
{
return
self
.
ProjectAssociationEqual
.
sync
({
force
:
true
}).
then
(
function
()
{
return
self
.
UserAssociationEqual
.
create
({
username
:
'jimhalpert'
}).
then
(
function
(
user1
)
{
return
self
.
ProjectAssociationEqual
.
create
({
title
:
'A Cool Project'
}).
then
(
function
(
project1
)
{
return
user1
.
setProjects
([
project1
]).
then
(
function
()
{
return
self
.
UserAssociationEqual
.
findOne
({
where
:
{
username
:
'jimhalpert'
},
include
:
[{
model
:
self
.
ProjectAssociationEqual
,
as
:
'Projects'
}]
}).
then
(
function
(
user2
)
{
return
self
.
UserAssociationEqual
.
create
({
username
:
'pambeesly'
}).
then
(
function
(
user3
)
{
expect
(
user1
.
get
(
'Projects'
)).
to
.
not
.
exist
;
expect
(
user2
.
get
(
'Projects'
)).
to
.
exist
;
expect
(
user1
.
equals
(
user2
)).
to
.
be
.
true
;
expect
(
user1
.
equals
(
user3
)).
to
.
not
.
be
.
true
;
});
});
});
});
});
});
});
});
});
describe
(
'values'
,
function
()
{
...
...
test/unit/dialects/mysql/query-generator.test.js
View file @
dad0328
...
...
@@ -369,6 +369,16 @@ if (Support.dialectIsMySQL()) {
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
ne
:
null
}}}],
expectation
:
'SELECT * FROM `myTable` WHERE `myTable`.`field` IS NOT NULL;'
,
context
:
QueryGenerator
},
{
title
:
'use IS NOT if not === BOOLEAN'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
not
:
true
}}}],
expectation
:
'SELECT * FROM `myTable` WHERE `myTable`.`field` IS NOT true;'
,
context
:
QueryGenerator
},
{
title
:
'use != if not !== BOOLEAN'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
not
:
3
}}}],
expectation
:
'SELECT * FROM `myTable` WHERE `myTable`.`field` != 3;'
,
context
:
QueryGenerator
}
],
...
...
test/unit/dialects/postgres/query-generator.test.js
View file @
dad0328
...
...
@@ -514,6 +514,16 @@ if (dialect.match(/^postgres/)) {
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
ne
:
null
}}}],
expectation
:
'SELECT * FROM myTable WHERE myTable.field IS NOT NULL;'
,
context
:
{
options
:
{
quoteIdentifiers
:
false
}}
},
{
title
:
'use IS NOT if not === BOOLEAN'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
not
:
true
}}}],
expectation
:
'SELECT * FROM myTable WHERE myTable.field IS NOT true;'
,
context
:
{
options
:
{
quoteIdentifiers
:
false
}}
},
{
title
:
'use != if not !== BOOLEAN'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
not
:
3
}}}],
expectation
:
'SELECT * FROM myTable WHERE myTable.field != 3;'
,
context
:
{
options
:
{
quoteIdentifiers
:
false
}}
}
],
...
...
test/unit/dialects/sqlite/query-generator.test.js
View file @
dad0328
...
...
@@ -347,6 +347,16 @@ if (dialect === 'sqlite') {
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
ne
:
null
}}}],
expectation
:
'SELECT * FROM `myTable` WHERE `myTable`.`field` IS NOT NULL;'
,
context
:
QueryGenerator
},
{
title
:
'use IS NOT if not === BOOLEAN'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
not
:
true
}}}],
expectation
:
'SELECT * FROM `myTable` WHERE `myTable`.`field` IS NOT 1;'
,
context
:
QueryGenerator
},
{
title
:
'use != if not !== BOOLEAN'
,
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
not
:
3
}}}],
expectation
:
'SELECT * FROM `myTable` WHERE `myTable`.`field` != 3;'
,
context
:
QueryGenerator
}
],
...
...
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