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 ee509090
authored
Apr 17, 2015
by
Ruben Bridgewater
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deprecation message in tests
1 parent
2a7c7c73
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
50 deletions
test/integration/associations/belongs-to-many.test.js
test/integration/dialects/postgres/associations.test.js
test/integration/instance.test.js
test/integration/sequelize.test.js
test/integration/associations/belongs-to-many.test.js
View file @
ee50909
...
...
@@ -22,8 +22,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
});
this
.
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
,
active
:
DataTypes
.
BOOLEAN
});
this
.
User
.
belongsToMany
(
this
.
Task
);
this
.
Task
.
belongsToMany
(
this
.
User
);
this
.
User
.
belongsToMany
(
this
.
Task
,
{
through
:
'UserTasks'
}
);
this
.
Task
.
belongsToMany
(
this
.
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -54,8 +54,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
this
.
Article
=
sequelize
.
define
(
'Article'
,
{
'title'
:
DataTypes
.
STRING
});
this
.
Label
=
sequelize
.
define
(
'Label'
,
{
'text'
:
DataTypes
.
STRING
});
this
.
Article
.
belongsToMany
(
this
.
Label
);
this
.
Label
.
belongsToMany
(
this
.
Article
);
this
.
Article
.
belongsToMany
(
this
.
Label
,
{
through
:
'ArticleLabels'
}
);
this
.
Label
.
belongsToMany
(
this
.
Article
,
{
through
:
'ArticleLabels'
}
);
return
sequelize
.
sync
({
force
:
true
});
}).
then
(
function
()
{
...
...
@@ -417,8 +417,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -445,8 +445,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
uid
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
tid
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -503,8 +503,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -532,8 +532,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Task
.
create
({
title
:
'task'
});
...
...
@@ -555,8 +555,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
this
.
User
=
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
});
this
.
Task
=
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
this
.
User
.
belongsToMany
(
this
.
Task
);
this
.
Task
.
belongsToMany
(
this
.
User
);
this
.
User
.
belongsToMany
(
this
.
Task
,
{
through
:
'UserTasks'
}
);
this
.
Task
.
belongsToMany
(
this
.
User
,
{
through
:
'UserTasks'
}
);
this
.
sequelize
=
sequelize
;
return
sequelize
.
sync
({
force
:
true
});
...
...
@@ -617,8 +617,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Task
.
create
({
title
:
'task'
});
...
...
@@ -640,8 +640,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -669,8 +669,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
this
.
User
=
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
});
this
.
Task
=
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
this
.
User
.
belongsToMany
(
this
.
Task
);
this
.
Task
.
belongsToMany
(
this
.
User
);
this
.
User
.
belongsToMany
(
this
.
Task
,
{
through
:
'UserTasks'
}
);
this
.
Task
.
belongsToMany
(
this
.
User
,
{
through
:
'UserTasks'
}
);
this
.
sequelize
=
sequelize
;
return
sequelize
.
sync
({
force
:
true
});
...
...
@@ -740,8 +740,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -785,8 +785,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
]
});
//create associations
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
});
});
});
...
...
@@ -796,8 +796,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -823,8 +823,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
});
User
.
belongsToMany
(
Task
);
Task
.
belongsToMany
(
User
);
User
.
belongsToMany
(
Task
,
{
through
:
'UserTasks'
}
);
Task
.
belongsToMany
(
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
User
.
bulkCreate
([
...
...
@@ -856,8 +856,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
},
{
timestamps
:
false
});
this
.
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
},
{
timestamps
:
false
});
this
.
User
.
belongsToMany
(
this
.
Task
);
this
.
Task
.
belongsToMany
(
this
.
User
);
this
.
User
.
belongsToMany
(
this
.
Task
,
{
through
:
'UserTasks'
}
);
this
.
Task
.
belongsToMany
(
this
.
User
,
{
through
:
'UserTasks'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
});
});
...
...
@@ -933,8 +933,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
}
});
Beacons
.
belongsToMany
(
Users
);
Users
.
belongsToMany
(
Beacons
);
Beacons
.
belongsToMany
(
Users
,
{
through
:
'UserBeacons'
}
);
Users
.
belongsToMany
(
Beacons
,
{
through
:
'UserBeacons'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
});
});
...
...
@@ -964,8 +964,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
,
ParanoidUser
=
paranoidSequelize
.
define
(
'ParanoidUser'
,
{})
,
ParanoidTask
=
paranoidSequelize
.
define
(
'ParanoidTask'
,
{});
ParanoidUser
.
belongsToMany
(
ParanoidTask
);
ParanoidTask
.
belongsToMany
(
ParanoidUser
);
ParanoidUser
.
belongsToMany
(
ParanoidTask
,
{
through
:
'UserTasks'
}
);
ParanoidTask
.
belongsToMany
(
ParanoidUser
,
{
through
:
'UserTasks'
}
);
expect
(
ParanoidUser
.
options
.
paranoid
).
to
.
be
.
ok
;
expect
(
ParanoidTask
.
options
.
paranoid
).
to
.
be
.
ok
;
...
...
@@ -1558,8 +1558,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
describe
(
'source belongs to target'
,
function
()
{
beforeEach
(
function
()
{
this
.
A
.
belongsTo
(
this
.
B
,
{
as
:
'relation1'
});
this
.
A
.
belongsToMany
(
this
.
B
,
{
as
:
'relation2'
});
this
.
B
.
belongsToMany
(
this
.
A
,
{
as
:
'relation2'
});
this
.
A
.
belongsToMany
(
this
.
B
,
{
as
:
'relation2'
,
through
:
'AB'
});
this
.
B
.
belongsToMany
(
this
.
A
,
{
as
:
'relation2'
,
through
:
'AB'
});
return
this
.
sequelize
.
sync
({
force
:
true
});
});
...
...
@@ -1584,8 +1584,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
describe
(
'target belongs to source'
,
function
()
{
beforeEach
(
function
()
{
this
.
B
.
belongsTo
(
this
.
A
,
{
as
:
'relation1'
});
this
.
A
.
belongsToMany
(
this
.
B
,
{
as
:
'relation2'
});
this
.
B
.
belongsToMany
(
this
.
A
,
{
as
:
'relation2'
});
this
.
A
.
belongsToMany
(
this
.
B
,
{
as
:
'relation2'
,
through
:
'AB'
});
this
.
B
.
belongsToMany
(
this
.
A
,
{
as
:
'relation2'
,
through
:
'AB'
});
return
this
.
sequelize
.
sync
({
force
:
true
});
});
...
...
@@ -1717,8 +1717,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
it
(
'can cascade deletes both ways by default'
,
function
()
{
var
self
=
this
;
this
.
User
.
belongsToMany
(
this
.
Task
);
this
.
Task
.
belongsToMany
(
this
.
User
);
this
.
User
.
belongsToMany
(
this
.
Task
,
{
through
:
'tasksusers'
}
);
this
.
Task
.
belongsToMany
(
this
.
User
,
{
through
:
'tasksusers'
}
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
bind
({}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -1758,8 +1758,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
self
=
this
,
spy
=
sinon
.
spy
();
this
.
User
.
belongsToMany
(
this
.
Task
,
{
onDelete
:
'RESTRICT'
});
this
.
Task
.
belongsToMany
(
this
.
User
,
{
onDelete
:
'RESTRICT'
});
this
.
User
.
belongsToMany
(
this
.
Task
,
{
onDelete
:
'RESTRICT'
,
through
:
'tasksusers'
});
this
.
Task
.
belongsToMany
(
this
.
User
,
{
onDelete
:
'RESTRICT'
,
through
:
'tasksusers'
});
return
this
.
sequelize
.
sync
({
force
:
true
}).
bind
({}).
then
(
function
()
{
return
Promise
.
all
([
...
...
@@ -1791,8 +1791,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
var
spy
=
sinon
.
spy
()
,
self
=
this
;
self
.
User
.
belongsToMany
(
self
.
Task
,
{
onDelete
:
'RESTRICT'
});
self
.
Task
.
belongsToMany
(
self
.
User
,
{
onDelete
:
'CASCADE'
});
self
.
User
.
belongsToMany
(
self
.
Task
,
{
onDelete
:
'RESTRICT'
,
through
:
'tasksusers'
});
self
.
Task
.
belongsToMany
(
self
.
User
,
{
onDelete
:
'CASCADE'
,
through
:
'tasksusers'
});
return
this
.
sequelize
.
sync
({
force
:
true
}).
bind
({}).
then
(
function
()
{
return
Sequelize
.
Promise
.
join
(
...
...
@@ -1829,8 +1829,8 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
it
(
'should be possible to remove all constraints'
,
function
()
{
var
self
=
this
;
this
.
User
.
belongsToMany
(
this
.
Task
,
{
constraints
:
false
});
this
.
Task
.
belongsToMany
(
this
.
User
,
{
constraints
:
false
});
this
.
User
.
belongsToMany
(
this
.
Task
,
{
constraints
:
false
,
through
:
'tasksusers'
});
this
.
Task
.
belongsToMany
(
this
.
User
,
{
constraints
:
false
,
through
:
'tasksusers'
});
return
this
.
sequelize
.
sync
({
force
:
true
}).
bind
({}).
then
(
function
()
{
return
Promise
.
all
([
...
...
test/integration/dialects/postgres/associations.test.js
View file @
ee50909
...
...
@@ -55,8 +55,8 @@ if (dialect.match(/^postgres/)) {
this
.
users
=
null
;
this
.
tasks
=
null
;
this
.
User
.
has
Many
(
this
.
Task
,
{
as
:
'Tasks'
,
through
:
'usertasks'
});
this
.
Task
.
has
Many
(
this
.
User
,
{
as
:
'Users'
,
through
:
'usertasks'
});
this
.
User
.
belongsTo
Many
(
this
.
Task
,
{
as
:
'Tasks'
,
through
:
'usertasks'
});
this
.
Task
.
belongsTo
Many
(
this
.
User
,
{
as
:
'Users'
,
through
:
'usertasks'
});
var
users
=
[]
,
tasks
=
[];
...
...
test/integration/instance.test.js
View file @
ee50909
...
...
@@ -1707,7 +1707,7 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
return
User
.
sync
().
then
(
function
()
{
var
user
=
User
.
build
({
username
:
'foo'
});
expect
(
user
.
values
).
to
.
deep
.
equal
({
username
:
'foo'
,
id
:
null
});
expect
(
user
.
get
({
plain
:
true
})
).
to
.
deep
.
equal
({
username
:
'foo'
,
id
:
null
});
});
});
});
...
...
test/integration/sequelize.test.js
View file @
ee50909
...
...
@@ -397,7 +397,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
if
(
Support
.
getTestDialect
()
===
'postgres'
)
{
it
(
'replaces named parameters with the passed object and ignores casts'
,
function
()
{
return
expect
(
this
.
sequelize
.
query
(
'select :one as foo, :two as bar, \'1000\'::integer as baz'
,
null
,
{
raw
:
true
},
{
one
:
1
,
two
:
2
}).
get
(
0
))
return
expect
(
this
.
sequelize
.
query
(
'select :one as foo, :two as bar, \'1000\'::integer as baz'
,
null
,
{
raw
:
true
,
replacements
:
{
one
:
1
,
two
:
2
}
}).
get
(
0
))
.
to
.
eventually
.
deep
.
equal
([{
foo
:
1
,
bar
:
2
,
baz
:
1000
}]);
});
...
...
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