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 12b58b68
authored
Jul 15, 2012
by
Sascha Depold
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #213 from innofluence/master
Fix for issue 210
2 parents
5d053be7
14cb25aa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletions
lib/associations/has-many-single-linked.js
spec/associations/has-many.spec.js
lib/associations/has-many-single-linked.js
View file @
12b58b6
...
...
@@ -15,7 +15,7 @@ module.exports = (function() {
HasManySingleLinked
.
prototype
.
injectSetter
=
function
(
emitter
,
oldAssociations
,
newAssociations
)
{
var
self
=
this
,
options
=
this
.
options
||
{}
,
options
=
this
.
__factory
.
options
// clear the old associations
oldAssociations
.
forEach
(
function
(
associatedObject
)
{
...
...
spec/associations/has-many.spec.js
View file @
12b58b6
...
...
@@ -162,6 +162,33 @@ describe('HasMany', function() {
})
})
})
it
(
"clears associations when passing null to the set-method with omitNull set to true"
,
function
(
done
)
{
sequelize
.
options
.
omitNull
=
true
;
var
User
=
sequelize
.
define
(
'User'
,
{
username
:
Sequelize
.
STRING
})
,
Task
=
sequelize
.
define
(
'Task'
,
{
title
:
Sequelize
.
STRING
})
Task
.
hasMany
(
User
)
sequelize
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
create
({
username
:
'foo'
}).
success
(
function
(
user
)
{
Task
.
create
({
title
:
'task'
}).
success
(
function
(
task
)
{
task
.
setUsers
([
user
]).
success
(
function
()
{
task
.
getUsers
().
success
(
function
(
_users
)
{
expect
(
_users
.
length
).
toEqual
(
1
)
task
.
setUsers
(
null
).
success
(
function
()
{
task
.
getUsers
().
success
(
function
(
_users
)
{
expect
(
_users
.
length
).
toEqual
(
0
)
done
()
})
})
})
})
})
})
})
})
})
describe
(
'(N:M)'
,
function
()
{
...
...
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