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 ee4dde20
authored
Feb 25, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into milestones/2.0.0
2 parents
d801f426
79b1f6f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
10 deletions
changelog.md
lib/associations/has-many-double-linked.js
test/associations/has-many.test.js
changelog.md
View file @
ee4dde2
Notice: All 1.7.x changes are present in 2.0.x aswell
# v1.7.0-rc9
# v1.7.0-rc9
(next)
-
[
PERFORMANCE
]
fixes performance regression introduced in rc7
-
[
FEATURE
]
include all relations for a model
[
#1421
](
https://github.com/sequelize/sequelize/pull/1421
)
-
[
FEATURE
]
covers more advanced include cases with limiting and filtering
# v1.7.0-rc8
-
[
BUG
]
fixes bug with required includes without wheres with subqueries
...
...
lib/associations/has-many-double-linked.js
View file @
ee4dde2
...
...
@@ -25,16 +25,12 @@ module.exports = (function() {
//fully qualify
var
instancePrimaryKeys
=
Object
.
keys
(
self
.
instance
.
Model
.
primaryKeys
)
,
instancePrimaryKey
=
instancePrimaryKeys
.
length
>
0
?
instancePrimaryKeys
[
0
]
:
'id'
where
[
through
.
tableName
+
"."
+
self
.
association
.
identifier
]
=
self
.
instance
[
instancePrimaryKey
]
var
primaryKeys
=
Object
.
keys
(
through
.
primaryKeys
)
,
foreignKey
=
primaryKeys
.
filter
(
function
(
pk
)
{
return
pk
!=
self
.
association
.
identifier
})[
0
]
,
foreignPrimary
=
Object
.
keys
(
self
.
association
.
target
.
primaryKeys
)
foreignPrimary
=
foreignPrimary
.
length
===
1
?
foreignPrimary
[
0
]
:
'id'
where
[
through
.
tableName
+
"."
+
foreignKey
]
=
{
join
:
self
.
association
.
target
.
tableName
+
"."
+
foreignPrimary
}
where
[
through
.
tableName
+
"."
+
self
.
association
.
identifier
]
=
self
.
instance
[
instancePrimaryKey
]
where
[
through
.
tableName
+
"."
+
self
.
association
.
foreignIdentifier
]
=
{
join
:
self
.
association
.
target
.
tableName
+
"."
+
foreignPrimary
}
if
(
Object
(
targetAssociation
.
through
)
===
targetAssociation
.
through
)
{
queryOptions
.
hasJoinTableModel
=
true
...
...
test/associations/has-many.test.js
View file @
ee4dde2
...
...
@@ -946,7 +946,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
describe
(
'
join table model
'
,
function
()
{
describe
(
'
through
'
,
function
()
{
beforeEach
(
function
(
done
)
{
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{})
this
.
Project
=
this
.
sequelize
.
define
(
'Project'
,
{})
...
...
@@ -1049,9 +1049,56 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
this
.
sequelize
.
sync
().
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
Worker
.
create
().
done
(
function
(
err
,
worker
)
{
Worker
.
create
({
id
:
1337
}).
done
(
function
(
err
,
worker
)
{
expect
(
err
).
not
.
to
.
be
.
ok
Task
.
create
({
id
:
7331
}).
done
(
function
(
err
,
task
)
{
expect
(
err
).
not
.
to
.
be
.
ok
worker
.
addTask
(
task
).
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
worker
.
addTask
(
task
).
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
done
()
})
})
})
})
})
})
it
(
'should be able to add twice (second call result in UPDATE call) with custom primary keys and without any attributes (and timestamps off) on the through model'
,
function
(
done
)
{
var
Worker
=
this
.
sequelize
.
define
(
'Worker'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
}
},
{
timestamps
:
false
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
}
},
{
timestamps
:
false
})
,
WorkerTasks
=
this
.
sequelize
.
define
(
'WorkerTasks'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
}
},
{
timestamps
:
false
})
Worker
.
hasMany
(
Task
,
{
through
:
WorkerTasks
})
Task
.
hasMany
(
Worker
,
{
through
:
WorkerTasks
})
this
.
sequelize
.
sync
().
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
Worker
.
create
({
id
:
1337
}).
done
(
function
(
err
,
worker
)
{
expect
(
err
).
not
.
to
.
be
.
ok
Task
.
create
().
done
(
function
(
err
,
task
)
{
Task
.
create
(
{
id
:
7331
}
).
done
(
function
(
err
,
task
)
{
expect
(
err
).
not
.
to
.
be
.
ok
worker
.
addTask
(
task
).
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
...
...
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