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 cbabc1c8
authored
Mar 24, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get schema tests working
1 parent
356cd4fe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
14 deletions
lib/associations/has-many-double-linked.js
lib/associations/has-one.js
lib/dialects/abstract/query-generator.js
test/include/schema.test.js
lib/associations/has-many-double-linked.js
View file @
cbabc1c
...
@@ -34,7 +34,7 @@ module.exports = (function() {
...
@@ -34,7 +34,7 @@ module.exports = (function() {
new
Utils
.
where
(
new
Utils
.
where
(
through
.
rawAttributes
[
self
.
association
.
foreignIdentifier
],
{
through
.
rawAttributes
[
self
.
association
.
foreignIdentifier
],
{
join
:
new
Utils
.
literal
([
join
:
new
Utils
.
literal
([
self
.
QueryInterface
.
quoteTable
(
self
.
association
.
target
.
getTableName
()
),
self
.
QueryInterface
.
quoteTable
(
self
.
association
.
target
.
name
),
self
.
QueryInterface
.
quoteIdentifier
(
foreignPrimaryKey
)
self
.
QueryInterface
.
quoteIdentifier
(
foreignPrimaryKey
)
].
join
(
'.'
))
].
join
(
'.'
))
}
}
...
...
lib/associations/has-one.js
View file @
cbabc1c
...
@@ -67,7 +67,7 @@ module.exports = (function() {
...
@@ -67,7 +67,7 @@ module.exports = (function() {
var
where
=
{}
var
where
=
{}
params
=
params
||
{}
params
=
params
||
{}
params
.
where
=
[
params
.
where
]
||
[]
params
.
where
=
(
params
.
where
&&
[
params
.
where
])
||
[]
where
[
association
.
identifier
]
=
this
.
get
(
association
.
sourceIdentifier
)
where
[
association
.
identifier
]
=
this
.
get
(
association
.
sourceIdentifier
)
params
.
where
.
push
(
where
)
params
.
where
.
push
(
where
)
...
...
lib/dialects/abstract/query-generator.js
View file @
cbabc1c
...
@@ -648,7 +648,7 @@ module.exports = (function() {
...
@@ -648,7 +648,7 @@ module.exports = (function() {
if
(
subQuery
)
{
if
(
subQuery
)
{
// We need primary keys
// We need primary keys
subQueryAttributes
=
mainAttributes
subQueryAttributes
=
mainAttributes
mainAttributes
=
mainTableAs
[
mainTableAs
+
'.*'
]
mainAttributes
=
[
mainTableAs
+
'.*'
]
}
}
if
(
options
.
include
)
{
if
(
options
.
include
)
{
...
@@ -816,13 +816,16 @@ module.exports = (function() {
...
@@ -816,13 +816,16 @@ module.exports = (function() {
// If using subQuery select defined subQuery attributes and join subJoinQueries
// If using subQuery select defined subQuery attributes and join subJoinQueries
if
(
subQuery
)
{
if
(
subQuery
)
{
subQueryItems
.
push
(
"SELECT "
+
subQueryAttributes
.
join
(
', '
)
+
" FROM "
+
options
.
table
)
subQueryItems
.
push
(
"SELECT "
+
subQueryAttributes
.
join
(
', '
)
+
" FROM "
+
options
.
table
)
if
(
mainTableAs
)
{
subQueryItems
.
push
(
" AS "
+
mainTableAs
)
}
subQueryItems
.
push
(
subJoinQueries
.
join
(
''
))
subQueryItems
.
push
(
subJoinQueries
.
join
(
''
))
// Else do it the reguar way
// Else do it the reguar way
}
else
{
}
else
{
mainQueryItems
.
push
(
"SELECT "
+
mainAttributes
.
join
(
', '
)
+
" FROM "
+
options
.
table
)
mainQueryItems
.
push
(
"SELECT "
+
mainAttributes
.
join
(
', '
)
+
" FROM "
+
options
.
table
)
if
(
options
.
t
ableAs
)
{
if
(
mainT
ableAs
)
{
mainQueryItems
.
push
(
" AS "
+
options
.
t
ableAs
)
mainQueryItems
.
push
(
" AS "
+
mainT
ableAs
)
}
}
mainQueryItems
.
push
(
mainJoinQueries
.
join
(
''
))
mainQueryItems
.
push
(
mainJoinQueries
.
join
(
''
))
}
}
...
@@ -830,7 +833,7 @@ module.exports = (function() {
...
@@ -830,7 +833,7 @@ module.exports = (function() {
// Add WHERE to sub or main query
// Add WHERE to sub or main query
if
(
options
.
hasOwnProperty
(
'where'
))
{
if
(
options
.
hasOwnProperty
(
'where'
))
{
options
.
where
=
this
.
getWhereConditions
(
options
.
where
,
tableName
,
Model
,
options
)
options
.
where
=
this
.
getWhereConditions
(
options
.
where
,
mainTableAs
,
Model
,
options
)
if
(
subQuery
)
{
if
(
subQuery
)
{
subQueryItems
.
push
(
" WHERE "
+
options
.
where
)
subQueryItems
.
push
(
" WHERE "
+
options
.
where
)
}
else
{
}
else
{
...
...
test/include/schema.test.js
View file @
cbabc1c
...
@@ -245,7 +245,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -245,7 +245,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}
}
})
})
it
.
only
(
'should support an include with multiple different association types'
,
function
(
done
)
{
it
(
'should support an include with multiple different association types'
,
function
(
done
)
{
var
self
=
this
var
self
=
this
self
.
sequelize
.
dropAllSchemas
().
success
(
function
(){
self
.
sequelize
.
dropAllSchemas
().
success
(
function
(){
...
@@ -388,8 +388,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -388,8 +388,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
},
callback
)
},
callback
)
},
},
function
(
err
)
{
function
(
err
)
{
console
.
log
(
err
.
sql
);
console
.
log
(
err
);
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
AccUser
.
findAll
({
AccUser
.
findAll
({
...
@@ -436,8 +434,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -436,8 +434,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
)
)
}]
}]
},
done
)
},
done
)
}).
error
(
done
).
on
(
'sql'
,
function
(
sql
)
{
console
.
log
(
sql
)
})
})
})
})
})
})
...
@@ -1052,7 +1048,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
...
@@ -1052,7 +1048,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
})
})
})
})
it
(
'should be possible to extend the on clause with a where option on a hasOne include'
,
function
(
done
)
{
it
(
'should be possible to extend the on clause with a where option on a hasOne include'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{},
{
schema
:
"account"
})
var
User
=
this
.
sequelize
.
define
(
'User'
,
{},
{
schema
:
"account"
})
,
Project
=
this
.
sequelize
.
define
(
'Project'
,
{
,
Project
=
this
.
sequelize
.
define
(
'Project'
,
{
title
:
DataTypes
.
STRING
title
:
DataTypes
.
STRING
...
@@ -1409,7 +1405,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i
...
@@ -1409,7 +1405,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i
],
],
limit
:
3
,
limit
:
3
,
order
:
[
order
:
[
[
self
.
sequelize
.
literal
(
self
.
models
.
Product
.
getTableName
()
+
'.id'
)
,
'ASC'
]
[
self
.
models
.
Product
.
name
+
'.id'
,
'ASC'
]
]
]
}).
done
(
function
(
err
,
products
)
{
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
err
).
not
.
to
.
be
.
ok
...
@@ -1484,7 +1480,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i
...
@@ -1484,7 +1480,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i
})
})
})
})
it
(
'should support including date fields, with the correct timeszone'
,
function
(
done
)
{
x
it
(
'should support including date fields, with the correct timeszone'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'user'
,
{
var
User
=
this
.
sequelize
.
define
(
'user'
,
{
dateField
:
Sequelize
.
DATE
dateField
:
Sequelize
.
DATE
},
{
timestamps
:
false
,
schema
:
"account"
})
},
{
timestamps
:
false
,
schema
:
"account"
})
...
...
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