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 4ebe4bcc
authored
Feb 25, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into hotfix/transaction_timeout
2 parents
1adae59a
6b9aa0c4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
14 deletions
changelog.md
lib/associations/has-many-double-linked.js
lib/dialects/abstract/query-generator.js
package.json
test/associations/has-many.test.js
test/dao-factory/findAll.test.js
changelog.md
View file @
4ebe4bc
Notice: All 1.7.x changes are present in 2.0.x aswell
Notice: All 1.7.x changes are present in 2.0.x aswell
# v1.7.0-rc9 (next)
# v1.7.0 (next)
-
[
FEATURE
]
covers more advanced include cases with limiting and filtering
# v1.7.0-rc9
-
[
PERFORMANCE
]
fixes performance regression introduced in rc7
-
[
PERFORMANCE
]
fixes performance regression introduced in rc7
-
[
FEATURE
]
include all relations for a model
[
#1421
](
https://github.com/sequelize/sequelize/pull/1421
)
-
[
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
-
[
BUG
]
N:M adder/getter with through model and custom primary keys now work
# v1.7.0-rc8
# v1.7.0-rc8
-
[
BUG
]
fixes bug with required includes without wheres with subqueries
-
[
BUG
]
fixes bug with required includes without wheres with subqueries
...
...
lib/associations/has-many-double-linked.js
View file @
4ebe4bc
...
@@ -25,16 +25,12 @@ module.exports = (function() {
...
@@ -25,16 +25,12 @@ module.exports = (function() {
//fully qualify
//fully qualify
var
instancePrimaryKeys
=
Object
.
keys
(
self
.
instance
.
daoFactory
.
primaryKeys
)
var
instancePrimaryKeys
=
Object
.
keys
(
self
.
instance
.
daoFactory
.
primaryKeys
)
,
instancePrimaryKey
=
instancePrimaryKeys
.
length
>
0
?
instancePrimaryKeys
[
0
]
:
'id'
,
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
=
Object
.
keys
(
self
.
association
.
target
.
primaryKeys
)
foreignPrimary
=
foreignPrimary
.
length
===
1
?
foreignPrimary
[
0
]
:
'id'
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
)
{
if
(
Object
(
targetAssociation
.
through
)
===
targetAssociation
.
through
)
{
queryOptions
.
hasJoinTableModel
=
true
queryOptions
.
hasJoinTableModel
=
true
...
...
lib/dialects/abstract/query-generator.js
View file @
4ebe4bc
...
@@ -780,7 +780,7 @@ module.exports = (function() {
...
@@ -780,7 +780,7 @@ module.exports = (function() {
if
(
Array
.
isArray
(
options
.
order
))
{
if
(
Array
.
isArray
(
options
.
order
))
{
options
.
order
.
forEach
(
function
(
t
)
{
options
.
order
.
forEach
(
function
(
t
)
{
if
(
subQuery
&&
!
(
t
[
0
]
instanceof
daoFactory
))
{
if
(
subQuery
&&
!
(
t
[
0
]
instanceof
daoFactory
)
&&
!
(
t
[
0
].
model
instanceof
daoFactory
)
)
{
subQueryOrder
.
push
(
this
.
quote
(
t
,
factory
))
subQueryOrder
.
push
(
this
.
quote
(
t
,
factory
))
}
}
mainQueryOrder
.
push
(
this
.
quote
(
t
,
factory
))
mainQueryOrder
.
push
(
this
.
quote
(
t
,
factory
))
...
...
package.json
View file @
4ebe4bc
{
{
"name"
:
"sequelize"
,
"name"
:
"sequelize"
,
"description"
:
"Multi dialect ORM for Node.JS"
,
"description"
:
"Multi dialect ORM for Node.JS"
,
"version"
:
"1.7.0-rc
8
"
,
"version"
:
"1.7.0-rc
9
"
,
"author"
:
"Sascha Depold <sascha@depold.com>"
,
"author"
:
"Sascha Depold <sascha@depold.com>"
,
"contributors"
:
[
"contributors"
:
[
{
{
...
...
test/associations/has-many.test.js
View file @
4ebe4bc
...
@@ -946,7 +946,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -946,7 +946,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
})
})
describe
(
'
join table model
'
,
function
()
{
describe
(
'
through
'
,
function
()
{
beforeEach
(
function
(
done
)
{
beforeEach
(
function
(
done
)
{
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{})
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{})
this
.
Project
=
this
.
sequelize
.
define
(
'Project'
,
{})
this
.
Project
=
this
.
sequelize
.
define
(
'Project'
,
{})
...
@@ -1049,9 +1049,56 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -1049,9 +1049,56 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
this
.
sequelize
.
sync
().
done
(
function
(
err
)
{
this
.
sequelize
.
sync
().
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
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
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
expect
(
err
).
not
.
to
.
be
.
ok
worker
.
addTask
(
task
).
done
(
function
(
err
)
{
worker
.
addTask
(
task
).
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
...
test/dao-factory/findAll.test.js
View file @
4ebe4bc
...
@@ -1039,7 +1039,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1039,7 +1039,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
callback
()
callback
()
})
})
},
function
()
{
done
()})
},
function
()
{
done
()})
})
,
})
it
(
'sorts by 2nd degree association'
,
function
(
done
)
{
it
(
'sorts by 2nd degree association'
,
function
(
done
)
{
var
self
=
this
var
self
=
this
...
@@ -1084,6 +1084,29 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1084,6 +1084,29 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
},
function
()
{
done
()})
},
function
()
{
done
()})
})
})
it
(
'sorts by 2nd degree association with alias while using limit'
,
function
(
done
)
{
var
self
=
this
async
.
forEach
([
[
'ASC'
,
'Europe'
,
'France'
,
'Fred'
],
[
'DESC'
,
'Europe'
,
'England'
,
'Kim'
]
],
function
(
params
,
callback
)
{
self
.
Continent
.
findAll
({
include
:
[
{
model
:
self
.
Country
,
include
:
[
self
.
Person
,
{
model
:
self
.
Person
,
as
:
'Residents'
}
]
}
],
order
:
[
[
{
model
:
self
.
Country
},
{
model
:
self
.
Person
,
as
:
'Residents'
},
'lastName'
,
params
[
0
]
]
],
limit
:
3
}).
done
(
function
(
err
,
continents
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
continents
).
to
.
exist
expect
(
continents
[
0
]).
to
.
exist
expect
(
continents
[
0
].
name
).
to
.
equal
(
params
[
1
])
expect
(
continents
[
0
].
countries
).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
]).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
].
name
).
to
.
equal
(
params
[
2
])
expect
(
continents
[
0
].
countries
[
0
].
residents
).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
].
residents
[
0
]).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
].
residents
[
0
].
name
).
to
.
equal
(
params
[
3
])
callback
()
})
},
function
()
{
done
()})
})
}),
}),
describe
(
'ManyToMany'
,
function
()
{
describe
(
'ManyToMany'
,
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