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 e6aefa7d
authored
Oct 12, 2012
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made abstract query more generic
1 parent
f23b4dee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
lib/dialects/abstract/query.js
lib/dialects/abstract/query.js
View file @
e6aefa7
...
@@ -118,6 +118,15 @@ module.exports = (function() {
...
@@ -118,6 +118,15 @@ module.exports = (function() {
return
eval
(
fctName
).
apply
(
this
,
args
)
return
eval
(
fctName
).
apply
(
this
,
args
)
}
}
/**
* Get the attributes of an insert query, which contains the just inserted id.
*
* @return {String} The field name.
*/
AbstractQuery
.
prototype
.
getInsertIdField
=
function
()
{
return
'insertId'
}
/////////////
/////////////
// private //
// private //
/////////////
/////////////
...
@@ -155,19 +164,30 @@ module.exports = (function() {
...
@@ -155,19 +164,30 @@ module.exports = (function() {
return
false
return
false
}
}
var
isInsertQuery
=
function
(
results
)
{
var
isInsertQuery
=
function
(
results
,
metaData
)
{
var
result
=
true
var
result
=
true
// is insert query if sql contains insert into
result
=
result
&&
(
this
.
sql
.
toLowerCase
().
indexOf
(
'insert into'
)
===
0
)
result
=
result
&&
(
this
.
sql
.
toLowerCase
().
indexOf
(
'insert into'
)
===
0
)
result
=
result
&&
(
!
results
||
results
.
hasOwnProperty
(
'insertId'
))
// is insert query if no results are passed or if the result has the inserted id
result
=
result
&&
(
!
results
||
results
.
hasOwnProperty
(
this
.
getInsertIdField
()))
// is insert query if no metadata are passed or if the metadata has the inserted id
result
=
result
&&
(
!
metaData
||
metaData
.
hasOwnProperty
(
this
.
getInsertIdField
()))
return
result
return
result
}
}
var
handleInsertQuery
=
function
(
results
)
{
var
handleInsertQuery
=
function
(
results
,
metaData
)
{
// add the inserted row id to the instance
// add the inserted row id to the instance
var
autoIncrementField
=
this
.
callee
.
__factory
.
autoIncrementField
var
autoIncrementField
=
this
.
callee
.
__factory
.
autoIncrementField
this
.
callee
[
autoIncrementField
]
=
results
.
insertId
,
id
=
null
id
=
id
||
(
results
&&
results
[
this
.
getInsertIdField
()])
id
=
id
||
(
metaData
&&
metaData
[
this
.
getInsertIdField
()])
this
.
callee
[
autoIncrementField
]
=
id
}
}
var
isShowTableQuery
=
function
()
{
var
isShowTableQuery
=
function
()
{
...
...
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