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 00b12c14
authored
Oct 09, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed disable foreign key constraint query
1 parent
619bd496
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
4 additions
and
74 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/mysql/query-generator.js
lib/dialects/postgres/query-generator.js
lib/dialects/sqlite/query-generator.js
lib/query-interface.js
lib/dialects/abstract/query-generator.js
View file @
00b12c1
...
...
@@ -261,27 +261,13 @@ module.exports = (function() {
},
/*
Globally enable foreign key constraints
*/
enableForeignKeyConstraintsQuery
:
function
()
{
throwMethodUndefined
(
'enableForeignKeyConstraintsQuery'
)
},
/*
Globally disable foreign key constraints
*/
disableForeignKeyConstraintsQuery
:
function
()
{
throwMethodUndefined
(
'disableForeignKeyConstraintsQuery'
)
},
/*
Quote an object based on its type. This is a more general version of quoteIdentifiers
Strings: should proxy to quoteIdentifiers
Arrays: First argument should be qouted, second argument should be append without quoting
Objects:
* If raw is set, that value should be returned verbatim, without quoting
* If fn is set, the string should start with the value of fn, starting paren, followed by
the values of cols (which is assumed to be an array), quoted and joined with ', ',
the values of cols (which is assumed to be an array), quoted and joined with ', ',
unless they are themselves objects
* If direction is set, should be prepended
...
...
@@ -366,8 +352,8 @@ module.exports = (function() {
if
(
value
instanceof
Utils
.
fn
||
value
instanceof
Utils
.
col
)
{
return
value
.
toString
(
this
)
}
else
{
return
SqlString
.
escape
(
value
,
false
,
null
,
this
.
dialect
,
field
)
}
return
SqlString
.
escape
(
value
,
false
,
null
,
this
.
dialect
,
field
)
}
}
}
...
...
lib/dialects/mysql/query-generator.js
View file @
00b12c1
...
...
@@ -589,16 +589,6 @@ module.exports = (function() {
return
fields
},
enableForeignKeyConstraintsQuery
:
function
()
{
var
sql
=
"SET FOREIGN_KEY_CHECKS = 1;"
return
Utils
.
_
.
template
(
sql
,
{})
},
disableForeignKeyConstraintsQuery
:
function
()
{
var
sql
=
"SET FOREIGN_KEY_CHECKS = 0;"
return
Utils
.
_
.
template
(
sql
,
{})
},
quoteIdentifier
:
function
(
identifier
,
force
)
{
return
Utils
.
addTicks
(
identifier
,
"`"
)
},
...
...
lib/dialects/postgres/query-generator.js
View file @
00b12c1
...
...
@@ -714,14 +714,6 @@ module.exports = (function() {
return
fields
},
enableForeignKeyConstraintsQuery
:
function
()
{
return
false
// not supported by dialect
},
disableForeignKeyConstraintsQuery
:
function
()
{
return
false
// not supported by dialect
},
createTrigger
:
function
(
tableName
,
triggerName
,
eventType
,
fireOnSpec
,
functionName
,
functionParams
,
optionsArray
)
{
var
sql
=
[
'CREATE <%= constraintVal %>TRIGGER <%= triggerName %>'
...
...
lib/dialects/sqlite/query-generator.js
View file @
00b12c1
...
...
@@ -179,7 +179,7 @@ module.exports = (function() {
,
attrLeft
=
((
primaryKeysLeft
.
length
!==
1
)
?
'id'
:
primaryKeysLeft
[
0
])
,
tableRight
=
((
include
.
association
.
associationType
===
'BelongsTo'
)
?
tableName
:
include
.
as
)
,
attrRight
=
include
.
association
.
identifier
joinQuery
+=
" LEFT OUTER JOIN "
+
this
.
quoteIdentifier
(
table
)
+
" AS "
+
this
.
quoteIdentifier
(
as
)
+
" ON "
+
this
.
quoteIdentifier
(
tableLeft
)
+
"."
+
this
.
quoteIdentifier
(
attrLeft
)
+
" = "
+
this
.
quoteIdentifier
(
tableRight
)
+
"."
+
this
.
quoteIdentifier
(
attrRight
)
}
else
{
var
primaryKeysSource
=
Object
.
keys
(
include
.
association
.
source
.
primaryKeys
)
...
...
@@ -377,16 +377,6 @@ module.exports = (function() {
return
fields
},
enableForeignKeyConstraintsQuery
:
function
()
{
var
sql
=
"PRAGMA foreign_keys = ON;"
return
Utils
.
_
.
template
(
sql
,
{})
},
disableForeignKeyConstraintsQuery
:
function
()
{
var
sql
=
"PRAGMA foreign_keys = OFF;"
return
Utils
.
_
.
template
(
sql
,
{})
},
hashToWhereConditions
:
function
(
hash
)
{
for
(
var
key
in
hash
)
{
if
(
hash
.
hasOwnProperty
(
key
))
{
...
...
lib/query-interface.js
View file @
00b12c1
...
...
@@ -434,7 +434,6 @@ module.exports = (function() {
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
chainer
.
add
(
self
,
'enableForeignKeyConstraints'
,
[])
chainer
.
add
(
self
,
'queryAndEmit'
,
[[
sql
,
dao
],
'delete'
])
chainer
.
runSerially
()
...
...
@@ -461,7 +460,6 @@ module.exports = (function() {
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
chainer
.
add
(
self
,
'enableForeignKeyConstraints'
,
[])
chainer
.
add
(
self
,
'queryAndEmit'
,
[
sql
,
'bulkUpdate'
])
return
chainer
.
runSerially
()
...
...
@@ -547,7 +545,6 @@ module.exports = (function() {
var
chainer
=
new
Utils
.
QueryChainer
()
chainer
.
add
(
self
,
'enableForeignKeyConstraints'
,
[])
chainer
.
add
(
self
,
'queryAndEmit'
,
[[
sql
,
dao
],
'delete'
])
chainer
.
runSerially
()
...
...
@@ -578,7 +575,6 @@ module.exports = (function() {
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
chainer
.
add
(
self
,
'enableForeignKeyConstraints'
,
[])
chainer
.
add
(
self
,
'queryAndEmit'
,
[
sql
,
'bulkDelete'
,
options
])
chainer
.
runSerially
()
...
...
@@ -660,30 +656,6 @@ module.exports = (function() {
}).
run
()
}
QueryInterface
.
prototype
.
enableForeignKeyConstraints
=
function
()
{
var
sql
=
this
.
QueryGenerator
.
enableForeignKeyConstraintsQuery
()
if
(
sql
)
{
return
queryAndEmit
.
call
(
this
,
sql
,
'enableForeignKeyConstraints'
)
}
else
{
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
this
.
emit
(
'enableForeignKeyConstraints'
,
null
)
emitter
.
emit
(
'success'
)
}).
run
()
}
}
QueryInterface
.
prototype
.
disableForeignKeyConstraints
=
function
()
{
var
sql
=
this
.
QueryGenerator
.
disableForeignKeyConstraintsQuery
()
if
(
sql
){
return
queryAndEmit
.
call
(
this
,
sql
,
'disableForeignKeyConstraints'
)
}
else
{
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
this
.
emit
(
'disableForeignKeyConstraints'
,
null
)
emitter
.
emit
(
'success'
)
}).
run
()
}
}
QueryInterface
.
prototype
.
createTrigger
=
function
(
tableName
,
triggerName
,
timingType
,
fireOnArray
,
functionName
,
functionParams
,
optionsArray
)
{
var
sql
=
this
.
QueryGenerator
.
createTrigger
(
tableName
,
triggerName
,
timingType
,
fireOnArray
,
functionName
...
...
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