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 5782fe0b
authored
Mar 08, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix more test cases
1 parent
62bd98f0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
28 deletions
lib/dialects/abstract/query-generator.js
lib/query-interface.js
lib/sequelize.js
test/associations/has-many.test.js
test/dao-factory.test.js
lib/dialects/abstract/query-generator.js
View file @
5782fe0
...
...
@@ -6,7 +6,8 @@ var Utils = require("../../utils")
module
.
exports
=
(
function
()
{
var
QueryGenerator
=
{
addSchema
:
function
(
param
)
{
var
schema
=
(
param
.
options
&&
param
.
options
.
schema
?
param
.
options
.
schema
:
undefined
)
var
self
=
this
,
schema
=
(
param
.
options
&&
param
.
options
.
schema
?
param
.
options
.
schema
:
undefined
)
,
schemaDelimiter
=
(
param
.
options
&&
param
.
options
.
schemaDelimiter
?
param
.
options
.
schemaDelimiter
:
undefined
)
if
(
!
schema
)
return
param
.
tableName
||
param
;
...
...
@@ -14,7 +15,10 @@ module.exports = (function() {
return
{
tableName
:
param
.
tableName
||
param
,
schema
:
schema
,
delimiter
:
schemaDelimiter
||
'.'
delimiter
:
schemaDelimiter
||
'.'
,
toString
:
function
()
{
return
self
.
quoteTable
(
this
)
}
}
},
...
...
lib/query-interface.js
View file @
5782fe0
...
...
@@ -28,26 +28,13 @@ module.exports = (function() {
var
self
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
self
.
showAllSchemas
().
success
(
function
(
schemaNames
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
schemaNames
.
forEach
(
function
(
schemaName
)
{
chainer
.
add
(
self
.
dropSchema
(
schemaName
))
})
chainer
.
run
()
.
success
(
function
()
{
self
.
emit
(
'dropAllSchemas'
,
null
)
emitter
.
emit
(
'success'
,
null
)
})
.
error
(
function
(
err
)
{
self
.
emit
(
'dropAllSchemas'
,
err
)
emitter
.
emit
(
'error'
,
err
)
})
}).
error
(
function
(
err
)
{
self
.
emit
(
'dropAllSchemas'
,
err
)
emitter
.
emit
(
'error'
,
err
)
})
chainer
.
run
().
proxy
(
emitter
)
}).
proxy
(
emitter
,
{
events
:
[
'sql'
,
'error'
]})
}).
run
()
}
...
...
@@ -364,7 +351,17 @@ module.exports = (function() {
if
(
self
.
QueryGenerator
.
describeTableQuery
)
{
sql
=
self
.
QueryGenerator
.
describeTableQuery
(
tableName
,
schema
,
schemaDelimiter
)
}
else
{
var
table
=
self
.
QueryGenerator
.
quoteIdentifier
(
self
.
QueryGenerator
.
addSchema
({
tableName
:
tableName
,
options
:
{
schema
:
schema
,
schemaDelimiter
:
schemaDelimiter
}}),
self
.
QueryGenerator
.
options
.
quoteIdentifiers
)
var
table
=
self
.
QueryGenerator
.
quoteIdentifier
(
self
.
QueryGenerator
.
addSchema
({
tableName
:
tableName
,
options
:
{
schema
:
schema
,
schemaDelimiter
:
schemaDelimiter
}
}),
self
.
QueryGenerator
.
options
.
quoteIdentifiers
)
sql
=
'DESCRIBE '
+
table
+
';'
}
...
...
lib/sequelize.js
View file @
5782fe0
...
...
@@ -366,11 +366,7 @@ module.exports = (function() {
}
Sequelize
.
prototype
.
dropAllSchemas
=
function
()
{
var
self
=
this
var
chainer
=
new
Utils
.
QueryChainer
()
chainer
.
add
(
self
.
getQueryInterface
().
dropAllSchemas
())
return
chainer
.
run
()
return
this
.
getQueryInterface
().
dropAllSchemas
()
}
Sequelize
.
prototype
.
sync
=
function
(
options
)
{
...
...
test/associations/has-many.test.js
View file @
5782fe0
...
...
@@ -639,7 +639,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
AcmeUser
.
hasMany
(
AcmeProject
,
{
through
:
AcmeProjectUsers
})
AcmeProject
.
hasMany
(
AcmeUser
,
{
through
:
AcmeProjectUsers
})
self
.
sequelize
.
dropAllSchemas
().
done
(
function
(
err
)
{
self
.
sequelize
.
dropAllSchemas
().
on
(
'sql'
,
function
(
sql
)
{
console
.
log
(
sql
);
}).
done
(
function
(
err
)
expect
(
err
).
not
.
to
.
be
.
ok
self
.
sequelize
.
createSchema
(
'acme'
).
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
...
...
test/dao-factory.test.js
View file @
5782fe0
...
...
@@ -1493,15 +1493,15 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect
(
UserSpecial
).
to
.
exist
expect
(
UserPublic
).
to
.
exist
if
(
dialect
===
"postgres"
)
{
expect
(
self
.
UserSpecialSync
.
getTableName
()).
to
.
equal
(
'"special"."UserSpecials"'
);
expect
(
self
.
UserSpecialSync
.
getTableName
()
.
toString
()
).
to
.
equal
(
'"special"."UserSpecials"'
);
expect
(
UserSpecial
.
indexOf
(
'INSERT INTO "special"."UserSpecials"'
)).
to
.
be
.
above
(
-
1
)
expect
(
UserPublic
.
indexOf
(
'INSERT INTO "UserPublics"'
)).
to
.
be
.
above
(
-
1
)
}
else
if
(
dialect
===
"sqlite"
)
{
expect
(
self
.
UserSpecialSync
.
getTableName
()
).
to
.
equal
(
'`special`.`
UserSpecials`'
);
expect
(
self
.
UserSpecialSync
.
getTableName
()
.
toString
()).
to
.
equal
(
'`special.
UserSpecials`'
);
expect
(
UserSpecial
.
indexOf
(
'INSERT INTO `special.UserSpecials`'
)).
to
.
be
.
above
(
-
1
)
expect
(
UserPublic
.
indexOf
(
'INSERT INTO `UserPublics`'
)).
to
.
be
.
above
(
-
1
)
}
else
{
expect
(
self
.
UserSpecialSync
.
getTableName
()).
to
.
equal
(
'`special.UserSpecials`'
);
expect
(
self
.
UserSpecialSync
.
getTableName
()
.
toString
()
).
to
.
equal
(
'`special.UserSpecials`'
);
expect
(
UserSpecial
.
indexOf
(
'INSERT INTO `special.UserSpecials`'
)).
to
.
be
.
above
(
-
1
)
expect
(
UserPublic
.
indexOf
(
'INSERT INTO `UserPublics`'
)).
to
.
be
.
above
(
-
1
)
}
...
...
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