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 bea65490
authored
Sep 08, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(schemas): add test for model dropping with schema
1 parent
544429ab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
lib/model.js
test/dao-factory.test.js
lib/model.js
View file @
bea6549
...
...
@@ -392,10 +392,10 @@ module.exports = (function() {
return
self
.
drop
(
options
);
}
}).
then
(
function
()
{
return
self
.
QueryInterface
.
createTable
(
self
.
getTableName
(
options
),
attributes
,
options
);
return
self
.
QueryInterface
.
createTable
(
self
.
getTableName
(),
attributes
,
options
);
}).
then
(
function
()
{
return
Promise
.
map
(
self
.
options
.
indexes
,
function
(
index
)
{
return
self
.
QueryInterface
.
addIndex
(
self
.
getTableName
(
options
),
index
.
fields
,
index
,
self
.
tableName
);
return
self
.
QueryInterface
.
addIndex
(
self
.
getTableName
(),
index
.
fields
,
index
,
self
.
tableName
);
});
}).
return
(
this
);
};
...
...
@@ -407,7 +407,7 @@ module.exports = (function() {
* @return {Promise}
*/
Model
.
prototype
.
drop
=
function
(
options
)
{
return
this
.
QueryInterface
.
dropTable
(
this
.
getTableName
(
options
),
options
);
return
this
.
QueryInterface
.
dropTable
(
this
.
getTableName
(),
options
);
};
Model
.
prototype
.
dropSchema
=
function
(
schema
)
{
...
...
@@ -446,7 +446,7 @@ module.exports = (function() {
* @param {Object} options The hash of options from any query. You can use one model to access tables with matching schemas by overriding `getTableName` and using custom key/values to alter the name of the table. (eg. subscribers_1, subscribers_2)
* @return {String|Object}
*/
Model
.
prototype
.
getTableName
=
function
(
options
)
{
Model
.
prototype
.
getTableName
=
function
()
{
return
this
.
QueryGenerator
.
addSchema
(
this
);
};
...
...
@@ -690,7 +690,7 @@ module.exports = (function() {
options
=
paranoidClause
.
call
(
this
,
options
);
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(
options
),
options
,
Utils
.
_
.
defaults
({
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(),
options
,
Utils
.
_
.
defaults
({
type
:
QueryTypes
.
SELECT
,
hasJoin
:
hasJoin
,
tableNames
:
Object
.
keys
(
tableNames
)
...
...
@@ -704,7 +704,7 @@ module.exports = (function() {
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
optcpy
.
where
||
null
;
return
this
.
QueryInterface
.
select
(
this
,
[[
this
.
getTableName
(
options
),
this
.
name
],
joinTableName
],
optcpy
,
Utils
.
_
.
defaults
({
return
this
.
QueryInterface
.
select
(
this
,
[[
this
.
getTableName
(),
this
.
name
],
joinTableName
],
optcpy
,
Utils
.
_
.
defaults
({
type
:
QueryTypes
.
SELECT
},
queryOptions
,
{
transaction
:
(
options
||
{}).
transaction
}));
};
...
...
@@ -798,7 +798,7 @@ module.exports = (function() {
mapFieldNames
.
call
(
this
,
options
,
this
);
options
=
paranoidClause
.
call
(
this
,
options
);
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(
options
),
options
,
Utils
.
_
.
defaults
({
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(),
options
,
Utils
.
_
.
defaults
({
plain
:
true
,
type
:
QueryTypes
.
SELECT
,
hasJoin
:
hasJoin
,
...
...
@@ -837,7 +837,7 @@ module.exports = (function() {
options
=
paranoidClause
.
call
(
this
,
options
);
return
this
.
QueryInterface
.
rawSelect
(
this
.
getTableName
(
options
),
options
,
aggregateFunction
,
this
);
return
this
.
QueryInterface
.
rawSelect
(
this
.
getTableName
(),
options
,
aggregateFunction
,
this
);
};
/**
...
...
@@ -1284,7 +1284,7 @@ module.exports = (function() {
}
// Insert all records at once
return
self
.
QueryInterface
.
bulkInsert
(
self
.
getTableName
(
options
),
records
,
options
,
attributes
);
return
self
.
QueryInterface
.
bulkInsert
(
self
.
getTableName
(),
records
,
options
,
attributes
);
}
}).
then
(
function
()
{
// Run after hook
...
...
@@ -1348,9 +1348,9 @@ module.exports = (function() {
if
(
self
.
_timestampAttributes
.
deletedAt
&&
!
options
.
force
)
{
var
attrValueHash
=
{};
attrValueHash
[
self
.
_timestampAttributes
.
deletedAt
]
=
Utils
.
now
(
self
.
modelManager
.
sequelize
.
options
.
dialect
);
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(
options
),
attrValueHash
,
where
,
options
,
self
.
rawAttributes
);
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(),
attrValueHash
,
where
,
options
,
self
.
rawAttributes
);
}
else
{
return
self
.
QueryInterface
.
bulkDelete
(
self
.
getTableName
(
options
),
where
,
options
,
self
);
return
self
.
QueryInterface
.
bulkDelete
(
self
.
getTableName
(),
where
,
options
,
self
);
}
}).
tap
(
function
()
{
// Run afterDestroy hook on each record individually
...
...
@@ -1497,7 +1497,7 @@ module.exports = (function() {
}
// Run query to update all rows
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(
options
),
attrValueHashUse
,
where
,
options
,
self
.
tableAttributes
).
then
(
function
(
affectedRows
)
{
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(),
attrValueHashUse
,
where
,
options
,
self
.
tableAttributes
).
then
(
function
(
affectedRows
)
{
if
(
options
.
returning
)
{
return
[
affectedRows
.
length
,
affectedRows
];
}
...
...
test/dao-factory.test.js
View file @
bea6549
...
...
@@ -1665,6 +1665,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
'should be able to drop with schemas'
,
function
()
{
return
this
.
UserSpecial
.
drop
();
});
it
(
"should be able to list schemas"
,
function
(
done
){
this
.
sequelize
.
showAllSchemas
().
then
(
function
(
schemas
)
{
expect
(
schemas
).
to
.
be
.
instanceof
(
Array
)
...
...
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