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 6436c021
authored
Dec 21, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed insertion id in sqlite
1 parent
10f291b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
lib/dialects/sqlite/query.js
lib/dialects/sqlite/query.js
View file @
6436c02
...
@@ -23,8 +23,12 @@ module.exports = (function() {
...
@@ -23,8 +23,12 @@ module.exports = (function() {
console
.
log
(
'Executing: '
+
this
.
sql
)
console
.
log
(
'Executing: '
+
this
.
sql
)
this
.
database
.
serialize
(
function
()
{
this
.
database
.
serialize
(
function
()
{
self
.
database
.
all
(
self
.
sql
,
function
(
err
,
results
)
{
var
isInsertCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'insert'
)
==
0
)
err
?
onFailure
.
call
(
self
,
err
)
:
onSuccess
.
call
(
self
,
results
)
,
isUpdateCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'update'
)
==
0
)
,
databaseMethod
=
(
isInsertCommand
||
isUpdateCommand
)
?
'run'
:
'all'
self
.
database
[
databaseMethod
](
self
.
sql
,
function
(
err
,
results
)
{
err
?
onFailure
.
call
(
self
,
err
)
:
onSuccess
.
call
(
self
,
results
,
this
)
})
})
})
})
...
@@ -43,13 +47,15 @@ module.exports = (function() {
...
@@ -43,13 +47,15 @@ module.exports = (function() {
//private
//private
var
onSuccess
=
function
(
results
)
{
var
onSuccess
=
function
(
results
,
metaData
)
{
var
result
=
this
.
callee
var
result
=
this
.
callee
,
self
=
this
,
self
=
this
// add the inserted row id to the instance
// add the inserted row id to the instance
if
(
this
.
callee
&&
(
this
.
sql
.
indexOf
(
'INSERT INTO'
)
==
0
)
&&
(
results
.
hasOwnProperty
(
'insertId'
)))
if
(
this
.
callee
&&
(
this
.
sql
.
indexOf
(
'INSERT INTO'
)
==
0
)
&&
metaData
.
hasOwnProperty
(
'lastID'
))
{
this
.
callee
[
this
.
callee
.
__definition
.
autoIncrementField
]
=
results
.
insertId
var
autoIncrementField
=
this
.
callee
.
__definition
.
autoIncrementField
this
.
callee
[
autoIncrementField
]
=
metaData
.
lastID
}
if
(
this
.
sql
.
indexOf
(
'sqlite_master'
)
!=
-
1
)
{
if
(
this
.
sql
.
indexOf
(
'sqlite_master'
)
!=
-
1
)
{
result
=
results
.
map
(
function
(
resultSet
){
return
resultSet
.
name
})
result
=
results
.
map
(
function
(
resultSet
){
return
resultSet
.
name
})
...
...
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