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 85b9a564
authored
May 07, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the last remnant of queryandEmit
1 parent
8cbd6a67
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
221 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/mysql/connector-manager.js
lib/dialects/sqlite/query-interface.js
lib/query-chainer.js
lib/query-interface.js
lib/utils.js
lib/dialects/abstract/query-generator.js
View file @
85b9a56
...
@@ -39,6 +39,20 @@ module.exports = (function() {
...
@@ -39,6 +39,20 @@ module.exports = (function() {
throwMethodUndefined
(
'createTableQuery'
)
throwMethodUndefined
(
'createTableQuery'
)
},
},
describeTableQuery
:
function
(
tableName
,
schema
,
schemaDelimiter
)
{
var
table
=
this
.
quoteTable
(
this
.
addSchema
({
tableName
:
tableName
,
options
:
{
schema
:
schema
,
schemaDelimiter
:
schemaDelimiter
}
})
)
return
'DESCRIBE '
+
table
+
';'
},
/*
/*
Returns a query for dropping a table.
Returns a query for dropping a table.
*/
*/
...
...
lib/dialects/mysql/connector-manager.js
View file @
85b9a56
...
@@ -257,7 +257,7 @@ module.exports = (function() {
...
@@ -257,7 +257,7 @@ module.exports = (function() {
this
.
client
=
null
;
this
.
client
=
null
;
if
(
!
client
)
{
if
(
!
client
)
{
return
return
// TODO possible orphaning of clients?
}
}
client
.
end
(
function
()
{
client
.
end
(
function
()
{
...
...
lib/dialects/sqlite/query-interface.js
View file @
85b9a56
...
@@ -22,15 +22,19 @@ var QueryInterface = module.exports = {
...
@@ -22,15 +22,19 @@ var QueryInterface = module.exports = {
@since 1.6.0
@since 1.6.0
*/
*/
removeColumn
:
function
(
tableName
,
attributeName
,
emitter
,
queryAndEmit
)
{
removeColumn
:
function
(
tableName
,
attributeName
)
{
var
self
=
this
return
this
.
describeTable
(
tableName
).
then
(
function
(
fields
)
{
return
this
.
describeTable
(
tableName
).
then
(
function
(
fields
)
{
delete
fields
[
attributeName
]
delete
fields
[
attributeName
]
var
sql
=
this
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
var
sql
=
self
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
})
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
})
return
QueryInterface
.
execMultiQuery
.
call
(
this
,
subQueries
,
'removeColumn'
,
null
,
queryAndEmit
)
subQueries
.
unshift
(
null
)
}.
bind
(
this
))
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
})
})
})
},
},
/**
/**
...
@@ -48,17 +52,21 @@ var QueryInterface = module.exports = {
...
@@ -48,17 +52,21 @@ var QueryInterface = module.exports = {
@since 1.6.0
@since 1.6.0
*/
*/
changeColumn
:
function
(
tableName
,
attributes
,
emitter
,
queryAndEmit
)
{
changeColumn
:
function
(
tableName
,
attributes
)
{
var
attributeName
=
Utils
.
_
.
keys
(
attributes
)[
0
]
var
attributeName
=
Utils
.
_
.
keys
(
attributes
)[
0
]
,
self
=
this
return
this
.
describeTable
(
tableName
).
then
(
function
(
fields
)
{
return
this
.
describeTable
(
tableName
).
then
(
function
(
fields
)
{
fields
[
attributeName
]
=
attributes
[
attributeName
]
fields
[
attributeName
]
=
attributes
[
attributeName
]
var
sql
=
this
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
var
sql
=
self
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
})
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
})
return
QueryInterface
.
execMultiQuery
.
call
(
this
,
subQueries
,
'changeColumn'
,
emitter
,
queryAndEmit
)
subQueries
.
unshift
(
null
)
}.
bind
(
this
))
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
})
})
})
},
},
/**
/**
...
@@ -77,93 +85,19 @@ var QueryInterface = module.exports = {
...
@@ -77,93 +85,19 @@ var QueryInterface = module.exports = {
@since 1.6.0
@since 1.6.0
*/
*/
renameColumn
:
function
(
tableName
,
attrNameBefore
,
attrNameAfter
,
emitter
,
queryAndEmit
)
{
renameColumn
:
function
(
tableName
,
attrNameBefore
,
attrNameAfter
)
{
var
self
=
this
return
this
.
describeTable
(
tableName
).
then
(
function
(
fields
)
{
return
this
.
describeTable
(
tableName
).
then
(
function
(
fields
)
{
fields
[
attrNameAfter
]
=
Utils
.
_
.
clone
(
fields
[
attrNameBefore
])
fields
[
attrNameAfter
]
=
Utils
.
_
.
clone
(
fields
[
attrNameBefore
])
delete
fields
[
attrNameBefore
]
delete
fields
[
attrNameBefore
]
var
sql
=
this
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
attrNameBefore
,
attrNameAfter
,
fields
)
var
sql
=
self
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
attrNameBefore
,
attrNameAfter
,
fields
)
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
})
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
})
return
QueryInterface
.
execMultiQuery
.
call
(
this
,
subQueries
,
'renameColumn'
,
emitter
,
queryAndEmit
)
subQueries
.
unshift
(
null
)
}.
bind
(
this
))
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
})
})
})
},
},
execMultiQuery
:
function
(
queries
,
methodName
,
emitter
,
queryAndEmit
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
queries
.
splice
(
0
,
queries
.
length
-
1
).
forEach
(
function
(
query
)
{
chainer
.
add
(
this
.
sequelize
,
'query'
,
[
query
+
";"
,
null
,
{
raw
:
true
}])
}.
bind
(
this
))
return
chainer
.
runSerially
()
.
then
(
function
()
{
return
queryAndEmit
.
call
(
this
,
queries
.
splice
(
queries
.
length
-
1
)[
0
],
methodName
,
{},
emitter
)
}.
bind
(
this
))
},
dropAllTables
:
function
(
options
)
{
var
self
=
this
if
(
!
options
)
{
options
=
{}
}
var
skip
=
options
.
skip
||
[];
return
new
Utils
.
CustomEventEmitter
(
function
(
dropAllTablesEmitter
)
{
var
events
=
[]
,
chainer
=
new
Utils
.
QueryChainer
()
,
onError
=
function
(
err
)
{
self
.
emit
(
'dropAllTables'
,
err
)
dropAllTablesEmitter
.
emit
(
'error'
,
err
)
}
self
.
showAllTables
()
.
error
(
onError
)
.
success
(
function
(
tableNames
)
{
self
.
sequelize
.
query
(
'PRAGMA foreign_keys;'
)
.
proxy
(
dropAllTablesEmitter
,
{
events
:
[
'sql'
]
})
.
error
(
onError
)
.
success
(
function
(
result
)
{
var
foreignKeysAreEnabled
=
result
.
foreign_keys
===
1
if
(
foreignKeysAreEnabled
)
{
var
queries
=
[]
queries
.
push
(
'PRAGMA foreign_keys = OFF'
)
tableNames
.
forEach
(
function
(
tableName
)
{
// if tableName is not in the Array of tables names then dont drop it
if
(
skip
.
indexOf
(
tableName
)
===
-
1
)
{
queries
.
push
(
self
.
QueryGenerator
.
dropTableQuery
(
tableName
).
replace
(
';'
,
''
))
}
})
queries
.
push
(
'PRAGMA foreign_keys = ON'
)
QueryInterface
.
execMultiQuery
.
call
(
self
,
queries
,
'dropAllTables'
,
dropAllTablesEmitter
,
self
.
queryAndEmit
)
}
else
{
// add the table removal query to the chainer
tableNames
.
forEach
(
function
(
tableName
)
{
chainer
.
add
(
self
,
'dropTable'
,
[
tableName
,
{
cascade
:
true
}
])
})
chainer
.
runSerially
()
.
proxy
(
dropAllTablesEmitter
,
{
events
:
[
'sql'
]
})
.
error
(
onError
)
.
success
(
function
()
{
self
.
emit
(
'dropAllTables'
,
null
)
dropAllTablesEmitter
.
emit
(
'success'
,
null
)
})
}
})
})
}).
run
()
}
}
}
lib/query-chainer.js
View file @
85b9a56
...
@@ -127,10 +127,6 @@ module.exports = (function() {
...
@@ -127,10 +127,6 @@ module.exports = (function() {
if
(
options
.
skipOnError
&&
(
self
.
fails
.
length
>
0
))
{
if
(
options
.
skipOnError
&&
(
self
.
fails
.
length
>
0
))
{
onError
(
'Skipped due to earlier error!'
)
onError
(
'Skipped due to earlier error!'
)
}
else
{
}
else
{
if
(
typeof
serial
.
options
===
"object"
&&
Object
.
keys
(
serial
.
options
).
length
>
0
&&
serial
.
method
===
"queryAndEmit"
)
{
serial
.
params
.
push
(
serial
.
options
)
}
var
emitter
=
serial
.
klass
[
serial
.
method
].
apply
(
serial
.
klass
,
serial
.
params
)
var
emitter
=
serial
.
klass
[
serial
.
method
].
apply
(
serial
.
klass
,
serial
.
params
)
emitter
.
success
(
function
(
result
)
{
emitter
.
success
(
function
(
result
)
{
...
...
lib/query-interface.js
View file @
85b9a56
...
@@ -17,7 +17,6 @@ module.exports = (function() {
...
@@ -17,7 +17,6 @@ module.exports = (function() {
this
.
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
this
.
QueryGenerator
.
_dialect
=
this
.
sequelize
.
dialect
this
.
QueryGenerator
.
sequelize
=
this
.
sequelize
this
.
QueryGenerator
.
sequelize
=
this
.
sequelize
}
}
Utils
.
addEventEmitter
(
QueryInterface
)
QueryInterface
.
prototype
.
createSchema
=
function
(
schema
)
{
QueryInterface
.
prototype
.
createSchema
=
function
(
schema
)
{
var
sql
=
this
.
QueryGenerator
.
createSchema
(
schema
)
var
sql
=
this
.
QueryGenerator
.
createSchema
(
schema
)
...
@@ -164,7 +163,7 @@ module.exports = (function() {
...
@@ -164,7 +163,7 @@ module.exports = (function() {
// enum type within the table and attribute
// enum type within the table and attribute
if
(
self
.
sequelize
.
options
.
dialect
===
"postgres"
)
{
if
(
self
.
sequelize
.
options
.
dialect
===
"postgres"
)
{
// Find the table that we're trying to drop
// Find the table that we're trying to drop
daoTable
=
self
.
sequelize
.
daoFactoryManager
.
getDAO
(
tableName
,
'tableName'
)
var
daoTable
=
self
.
sequelize
.
daoFactoryManager
.
getDAO
(
tableName
,
'tableName'
)
if
(
!!
daoTable
)
{
if
(
!!
daoTable
)
{
var
getTableName
=
(
!
options
||
!
options
.
schema
||
options
.
schema
===
"public"
?
''
:
options
.
schema
+
'_'
)
+
tableName
var
getTableName
=
(
!
options
||
!
options
.
schema
||
options
.
schema
===
"public"
?
''
:
options
.
schema
+
'_'
)
+
tableName
...
@@ -188,48 +187,52 @@ module.exports = (function() {
...
@@ -188,48 +187,52 @@ module.exports = (function() {
QueryInterface
.
prototype
.
dropAllTables
=
function
(
options
)
{
QueryInterface
.
prototype
.
dropAllTables
=
function
(
options
)
{
var
self
=
this
var
self
=
this
if
(
!
options
)
{
options
=
options
||
{}
options
=
{}
var
dropAllTables
=
function
(
tableNames
)
{
tableNames
.
unshift
(
null
)
return
Utils
.
Promise
.
reduce
(
tableNames
,
function
(
total
,
tableName
)
{
// if tableName is not in the Array of tables names then dont drop it
if
(
skip
.
indexOf
(
tableName
)
===
-
1
)
{
return
self
.
dropTable
(
tableName
,
{
cascade
:
true
})
}
})
}
}
var
skip
=
options
.
skip
||
[];
var
skip
=
options
.
skip
||
[];
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
return
self
.
showAllTables
().
then
(
function
(
tableNames
)
{
// sqlite needs some special treatment as it cannot drop a column
if
(
self
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
return
SQLiteQueryInterface
.
dropAllTables
.
call
(
this
,
options
)
return
self
.
sequelize
.
query
(
'PRAGMA foreign_keys;'
).
then
(
function
(
result
)
{
}
else
{
var
foreignKeysAreEnabled
=
result
.
foreign_keys
===
1
return
new
Utils
.
CustomEventEmitter
(
function
(
dropAllTablesEmitter
)
{
var
events
=
[]
if
(
foreignKeysAreEnabled
)
{
,
chainer
=
new
Utils
.
QueryChainer
()
return
self
.
sequelize
.
query
(
'PRAGMA foreign_keys = OFF'
).
then
(
function
()
{
,
onError
=
function
(
err
)
{
return
dropAllTables
(
tableNames
).
then
(
function
(){
self
.
emit
(
'dropAllTables'
,
err
)
return
self
.
sequelize
.
query
(
'PRAGMA foreign_keys = ON'
)
dropAllTablesEmitter
.
emit
(
'error'
,
err
)
}
self
.
showAllTables
().
success
(
function
(
tableNames
)
{
self
.
getForeignKeysForTables
(
tableNames
).
success
(
function
(
foreignKeys
)
{
// add the foreign key removal query to the chainer
Object
.
keys
(
foreignKeys
).
forEach
(
function
(
tableName
)
{
foreignKeys
[
tableName
].
forEach
(
function
(
foreignKey
)
{
var
sql
=
self
.
QueryGenerator
.
dropForeignKeyQuery
(
tableName
,
foreignKey
)
chainer
.
add
(
self
.
sequelize
,
'query'
,
[
sql
])
})
})
})
})
}
else
{
return
dropAllTables
(
tableNames
)
}
})
}
else
{
return
self
.
getForeignKeysForTables
(
tableNames
).
then
(
function
(
foreignKeys
)
{
var
promises
=
[]
// add the table removal query to the chainer
tableNames
.
forEach
(
function
(
tableName
)
{
tableNames
.
forEach
(
function
(
tableName
)
{
foreignKeys
[
tableName
].
forEach
(
function
(
foreignKey
)
{
// if tableName is not in the Array of tables names then dont drop it
var
sql
=
self
.
QueryGenerator
.
dropForeignKeyQuery
(
tableName
,
foreignKey
)
if
(
skip
.
indexOf
(
tableName
)
===
-
1
)
{
promises
.
push
(
self
.
sequelize
.
query
(
sql
))
chainer
.
add
(
self
,
'dropTable'
,
[
tableName
,
{
cascade
:
true
}
])
}
})
})
})
chainer
return
Utils
.
Promise
.
all
(
promises
).
then
(
function
()
{
.
runSerially
()
return
dropAllTables
(
tableNames
)
.
proxy
(
dropAllTablesEmitter
,
{
proxy
:
[
'success'
,
'error'
,
'sql'
]})
})
}).
error
(
onError
)
})
}).
error
(
onError
)
}
}).
run
()
})
}
}
}
QueryInterface
.
prototype
.
dropAllEnums
=
function
(
options
)
{
QueryInterface
.
prototype
.
dropAllEnums
=
function
(
options
)
{
...
@@ -276,30 +279,12 @@ module.exports = (function() {
...
@@ -276,30 +279,12 @@ module.exports = (function() {
if
(
typeof
options
===
"string"
)
{
if
(
typeof
options
===
"string"
)
{
schema
=
options
schema
=
options
}
}
else
if
(
typeof
options
===
"object"
)
{
else
if
(
typeof
options
===
"object"
)
{
schema
=
options
.
schema
||
null
schema
=
options
.
schema
||
null
schemaDelimiter
=
options
.
schemaDelimiter
||
null
schemaDelimiter
=
options
.
schemaDelimiter
||
null
}
}
var
sql
;
var
sql
=
this
.
QueryGenerator
.
describeTableQuery
(
tableName
,
schema
,
schemaDelimiter
)
if
(
this
.
QueryGenerator
.
describeTableQuery
)
{
sql
=
this
.
QueryGenerator
.
describeTableQuery
(
tableName
,
schema
,
schemaDelimiter
)
}
else
{
// TODO move this to abstract query gen.
var
table
=
this
.
QueryGenerator
.
quoteTable
(
this
.
QueryGenerator
.
addSchema
({
tableName
:
tableName
,
options
:
{
schema
:
schema
,
schemaDelimiter
:
schemaDelimiter
}
})
)
sql
=
'DESCRIBE '
+
table
+
';'
}
return
this
.
sequelize
.
query
(
sql
,
null
,
{
raw
:
true
})
return
this
.
sequelize
.
query
(
sql
,
null
,
{
raw
:
true
})
}
}
...
@@ -316,14 +301,13 @@ module.exports = (function() {
...
@@ -316,14 +301,13 @@ module.exports = (function() {
var
options
=
this
.
QueryGenerator
.
attributesToSQL
(
attributes
)
var
options
=
this
.
QueryGenerator
.
attributesToSQL
(
attributes
)
,
sql
=
this
.
QueryGenerator
.
addColumnQuery
(
tableName
,
options
)
,
sql
=
this
.
QueryGenerator
.
addColumnQuery
(
tableName
,
options
)
return
this
.
sequelize
.
query
(
sql
,
null
,
{
logging
:
this
.
sequelize
.
options
.
logging
})
return
this
.
sequelize
.
query
(
sql
,
null
,
{
logging
:
this
.
sequelize
.
options
.
logging
})
}
}
QueryInterface
.
prototype
.
removeColumn
=
function
(
tableName
,
attributeName
)
{
QueryInterface
.
prototype
.
removeColumn
=
function
(
tableName
,
attributeName
)
{
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
// sqlite needs some special treatment as it cannot drop a column
// sqlite needs some special treatment as it cannot drop a column
return
SQLiteQueryInterface
.
removeColumn
.
call
(
this
,
tableName
,
attributeName
,
null
,
queryAndEmit
)
return
SQLiteQueryInterface
.
removeColumn
.
call
(
this
,
tableName
,
attributeName
)
}
else
{
}
else
{
var
sql
=
this
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
attributeName
)
var
sql
=
this
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
attributeName
)
return
this
.
sequelize
.
query
(
sql
,
null
,
{
logging
:
this
.
sequelize
.
options
.
logging
})
return
this
.
sequelize
.
query
(
sql
,
null
,
{
logging
:
this
.
sequelize
.
options
.
logging
})
...
@@ -341,7 +325,7 @@ module.exports = (function() {
...
@@ -341,7 +325,7 @@ module.exports = (function() {
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
// sqlite needs some special treatment as it cannot change a column
// sqlite needs some special treatment as it cannot change a column
return
SQLiteQueryInterface
.
changeColumn
.
call
(
this
,
tableName
,
attributes
,
null
,
queryAndEmit
)
return
SQLiteQueryInterface
.
changeColumn
.
call
(
this
,
tableName
,
attributes
)
}
else
{
}
else
{
var
options
=
this
.
QueryGenerator
.
attributesToSQL
(
attributes
)
var
options
=
this
.
QueryGenerator
.
attributesToSQL
(
attributes
)
,
sql
=
this
.
QueryGenerator
.
changeColumnQuery
(
tableName
,
options
)
,
sql
=
this
.
QueryGenerator
.
changeColumnQuery
(
tableName
,
options
)
...
@@ -370,9 +354,10 @@ module.exports = (function() {
...
@@ -370,9 +354,10 @@ module.exports = (function() {
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
// sqlite needs some special treatment as it cannot rename a column
// sqlite needs some special treatment as it cannot rename a column
return
SQLiteQueryInterface
.
renameColumn
.
call
(
this
,
tableName
,
attrNameBefore
,
attrNameAfter
,
null
,
queryAndEmit
)
return
SQLiteQueryInterface
.
renameColumn
.
call
(
this
,
tableName
,
attrNameBefore
,
attrNameAfter
)
}
else
{
}
else
{
var
sql
=
this
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
var
sql
=
this
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
attrNameBefore
,
attrNameBefore
,
this
.
QueryGenerator
.
attributesToSQL
(
options
)
this
.
QueryGenerator
.
attributesToSQL
(
options
)
)
)
...
@@ -761,68 +746,5 @@ module.exports = (function() {
...
@@ -761,68 +746,5 @@ module.exports = (function() {
return
{
limit
:
this
.
scopeObj
.
limit
||
null
,
offset
:
this
.
scopeObj
.
offset
||
null
,
where
:
smart
,
order
:
(
this
.
scopeObj
.
order
||
[]).
join
(
', '
)}
return
{
limit
:
this
.
scopeObj
.
limit
||
null
,
offset
:
this
.
scopeObj
.
offset
||
null
,
where
:
smart
,
order
:
(
this
.
scopeObj
.
order
||
[]).
join
(
', '
)}
}
}
var
queryAndEmit
=
QueryInterface
.
prototype
.
queryAndEmit
=
function
(
sqlOrQueryParams
,
methodName
,
options
,
emitter
)
{
options
=
Utils
.
_
.
extend
({
success
:
function
(){},
error
:
function
(){},
transaction
:
null
,
logging
:
this
.
sequelize
.
options
.
logging
},
options
||
{})
var
execQuery
=
function
(
emitter
)
{
var
query
;
if
(
Array
.
isArray
(
sqlOrQueryParams
))
{
if
(
sqlOrQueryParams
.
length
===
1
)
{
sqlOrQueryParams
.
push
(
null
)
}
if
(
sqlOrQueryParams
.
length
===
2
)
{
sqlOrQueryParams
.
push
(
typeof
options
===
"object"
?
options
:
{})
}
query
=
this
.
sequelize
.
query
.
apply
(
this
.
sequelize
,
sqlOrQueryParams
)
}
else
{
query
=
this
.
sequelize
.
query
(
sqlOrQueryParams
,
null
,
options
)
}
if
(
!
emitter
)
{
return
query
.
then
(
function
(
result
)
{
if
(
options
.
success
)
options
.
success
(
result
);
return
result
;
}
/*, function (err) {
if (options.error) options.error(err);
}*/
);
}
emitter
.
query
=
query
;
emitter
.
query
.
success
(
function
(
obj
)
{
if
(
options
.
success
)
{
options
.
success
(
obj
)
}
this
.
emit
(
methodName
,
null
)
emitter
.
emit
(
'success'
,
obj
)
}.
bind
(
this
))
.
error
(
function
(
err
)
{
if
(
options
.
error
)
{
options
.
error
(
err
)
}
this
.
emit
(
methodName
,
err
)
emitter
.
emit
(
'error'
,
err
)
}.
bind
(
this
))
.
proxy
(
emitter
,
{
events
:
[
'sql'
]
})
return
emitter
;
}.
bind
(
this
)
if
(
!!
emitter
)
{
execQuery
(
emitter
)
}
else
{
return
execQuery
();
}
}
return
QueryInterface
return
QueryInterface
})()
})()
lib/utils.js
View file @
85b9a56
...
@@ -52,9 +52,6 @@ var Utils = module.exports = {
...
@@ -52,9 +52,6 @@ var Utils = module.exports = {
return
_
return
_
})(),
})(),
addEventEmitter
:
function
(
_class
)
{
util
.
inherits
(
_class
,
require
(
'events'
).
EventEmitter
)
},
format
:
function
(
arr
,
dialect
)
{
format
:
function
(
arr
,
dialect
)
{
var
timeZone
=
null
;
var
timeZone
=
null
;
// Make a clone of the array beacuse format modifies the passed args
// Make a clone of the array beacuse format modifies the passed args
...
...
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