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 6643167a
authored
May 06, 2013
by
Martin Aspeli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make cascade optional
1 parent
151a23f6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
lib/dialects/postgres/query-generator.js
lib/query-interface.js
spec-jasmine/postgres/query-generator.spec.js
lib/dialects/postgres/query-generator.js
View file @
6643167
...
@@ -78,9 +78,10 @@ module.exports = (function() {
...
@@ -78,9 +78,10 @@ module.exports = (function() {
dropTableQuery
:
function
(
tableName
,
options
)
{
dropTableQuery
:
function
(
tableName
,
options
)
{
options
=
options
||
{}
options
=
options
||
{}
var
query
=
"DROP TABLE IF EXISTS <%= table %>
CASCADE
;"
var
query
=
"DROP TABLE IF EXISTS <%= table %>
<%= cascade %>
;"
return
Utils
.
_
.
template
(
query
)({
return
Utils
.
_
.
template
(
query
)({
table
:
QueryGenerator
.
addQuotes
(
tableName
)
table
:
QueryGenerator
.
addQuotes
(
tableName
),
cascade
:
options
.
cascade
?
" CASCADE"
:
""
})
})
},
},
...
...
lib/query-interface.js
View file @
6643167
...
@@ -79,8 +79,8 @@ module.exports = (function() {
...
@@ -79,8 +79,8 @@ module.exports = (function() {
return
queryAndEmit
.
call
(
this
,
sql
,
'createTable'
)
return
queryAndEmit
.
call
(
this
,
sql
,
'createTable'
)
}
}
QueryInterface
.
prototype
.
dropTable
=
function
(
tableName
)
{
QueryInterface
.
prototype
.
dropTable
=
function
(
tableName
,
options
)
{
var
sql
=
this
.
QueryGenerator
.
dropTableQuery
(
tableName
)
var
sql
=
this
.
QueryGenerator
.
dropTableQuery
(
tableName
,
options
)
return
queryAndEmit
.
call
(
this
,
sql
,
'dropTable'
)
return
queryAndEmit
.
call
(
this
,
sql
,
'dropTable'
)
}
}
...
@@ -95,7 +95,7 @@ module.exports = (function() {
...
@@ -95,7 +95,7 @@ module.exports = (function() {
chainer
.
add
(
self
,
'disableForeignKeyConstraints'
,
[])
chainer
.
add
(
self
,
'disableForeignKeyConstraints'
,
[])
tableNames
.
forEach
(
function
(
tableName
)
{
tableNames
.
forEach
(
function
(
tableName
)
{
chainer
.
add
(
self
,
'dropTable'
,
[
tableName
])
chainer
.
add
(
self
,
'dropTable'
,
[
tableName
,
{
cascade
:
true
}
])
})
})
chainer
.
add
(
self
,
'enableForeignKeyConstraints'
,
[])
chainer
.
add
(
self
,
'enableForeignKeyConstraints'
,
[])
...
...
spec-jasmine/postgres/query-generator.spec.js
View file @
6643167
...
@@ -95,11 +95,11 @@ describe('QueryGenerator', function() {
...
@@ -95,11 +95,11 @@ describe('QueryGenerator', function() {
dropTableQuery
:
[
dropTableQuery
:
[
{
{
arguments
:
[
'myTable'
],
arguments
:
[
'myTable'
,
{
cascade
:
true
}
],
expectation
:
"DROP TABLE IF EXISTS \"myTable\" CASCADE;"
expectation
:
"DROP TABLE IF EXISTS \"myTable\" CASCADE;"
},
},
{
{
arguments
:
[
'mySchema.myTable'
],
arguments
:
[
'mySchema.myTable'
,
{
cascade
:
true
}
],
expectation
:
"DROP TABLE IF EXISTS \"mySchema\".\"myTable\" CASCADE;"
expectation
:
"DROP TABLE IF EXISTS \"mySchema\".\"myTable\" CASCADE;"
}
}
],
],
...
...
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