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 1cd73a5e
authored
May 18, 2013
by
reedog117
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolved error trying to retrieve insertId
1 parent
95df903a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
33 deletions
lib/dialects/mariadb/connector-manager.js
lib/dialects/mariadb/query.js
lib/dialects/mysql/query.js
spec/config/config.js
lib/dialects/mariadb/connector-manager.js
View file @
1cd73a5
...
@@ -208,14 +208,12 @@ module.exports = (function() {
...
@@ -208,14 +208,12 @@ module.exports = (function() {
var
disconnect
=
function
(
client
)
{
var
disconnect
=
function
(
client
)
{
var
self
=
this
;
var
self
=
this
;
if
(
client
.
connected
)
client
.
on
(
'close'
,
function
()
{
self
.
client
=
null
self
.
isConnecting
=
false
})
client
.
end
()
client
.
end
()
self
.
client
=
null
self
.
isConnecting
=
false
/* if (!this.useQueue) {
/* if (!this.useQueue) {
this.client = null;
this.client = null;
...
@@ -253,7 +251,10 @@ module.exports = (function() {
...
@@ -253,7 +251,10 @@ module.exports = (function() {
var
connect
=
function
(
done
,
config
)
{
var
connect
=
function
(
done
,
config
)
{
config
=
config
||
this
.
config
config
=
config
||
this
.
config
var
connection
=
new
mariasql
();
var
connection
=
new
mariasql
()
,
self
=
this
this
.
isConnecting
=
true
this
.
isConnecting
=
true
connection
.
connect
({
connection
.
connect
({
host
:
config
.
host
,
host
:
config
.
host
,
...
@@ -271,6 +272,10 @@ module.exports = (function() {
...
@@ -271,6 +272,10 @@ module.exports = (function() {
this
.
isConnecting
=
false
this
.
isConnecting
=
false
done
(
null
,
connection
)
done
(
null
,
connection
)
}).
on
(
'error'
,
function
()
{
disconnect
.
call
(
self
,
connection
)
}).
on
(
'close'
,
function
()
{
disconnect
.
call
(
self
,
connection
)
})
})
}
}
...
...
lib/dialects/mariadb/query.js
View file @
1cd73a5
...
@@ -23,14 +23,12 @@ module.exports = (function() {
...
@@ -23,14 +23,12 @@ module.exports = (function() {
this
.
options
.
logging
(
'Executing: '
+
this
.
sql
)
this
.
options
.
logging
(
'Executing: '
+
this
.
sql
)
}
}
var
query
=
this
.
client
.
query
(
this
.
sql
),
var
resultSet
=
[],
resultSet
=
[],
errorDetected
=
false
,
errorDetected
=
false
,
temp
=
1
self
=
this
query
.
on
(
'result'
,
function
(
results
)
{
this
.
client
.
query
(
this
.
sql
)
.
on
(
'result'
,
function
(
results
)
{
var
resultStream
=
results
;
results
.
on
(
'row'
,
function
(
row
)
{
results
.
on
(
'row'
,
function
(
row
)
{
resultSet
.
push
(
row
);
resultSet
.
push
(
row
);
...
@@ -38,37 +36,52 @@ module.exports = (function() {
...
@@ -38,37 +36,52 @@ module.exports = (function() {
.
on
(
'error'
,
function
(
err
)
{
.
on
(
'error'
,
function
(
err
)
{
//console.log('error in result-loop for: ' + self.sql)
//console.log('error in result-loop for: ' + self.sql)
errorDetected
=
true
errorDetected
=
true
this
.
emit
(
'sql'
,
this
.
sql
)
self
.
emit
(
'sql'
,
this
.
sql
)
console
.
log
(
'Failed query : '
+
this
.
sql
)
console
.
log
(
'Failed query : '
+
this
.
sql
)
console
.
log
(
err
)
console
.
log
(
err
)
resultStream
.
abort
()
self
.
emit
(
'error'
,
err
,
this
.
callee
)
this
.
emit
(
'error'
,
err
,
this
.
callee
)
}.
bind
(
this
))
}.
bind
(
this
))
.
on
(
'end'
,
function
(
info
)
{
.
on
(
'end'
,
function
(
info
)
{
//console.log(info)
// nothing needs to be done at this point
if
(
errorDetected
)
if
(
errorDetected
)
{
return
return
//this.emit('sql', this.sql)
}
//this.emit('success', this.formatResults(resultSet))
self
.
emit
(
'sql'
,
this
.
sql
)
console
.
log
(
'Successful query : '
+
this
.
sql
)
// we need to figure out whether to send the result set
// or info depending upon the type of query
if
(
/^show/
.
test
(
this
.
sql
.
toLowerCase
())
||
/^select/
.
test
(
this
.
sql
.
toLowerCase
())
||
/^describe/
.
test
(
this
.
sql
.
toLowerCase
())
)
{
console
.
log
(
'results : '
)
console
.
log
(
resultSet
)
//console.log('formatted resultset: ' + JSON.stringify(this.formatResults(resultSet)))
self
.
emit
(
'success'
,
this
.
formatResults
(
resultSet
))
}
else
{
console
.
log
(
'results : '
)
info
=
JSON
.
parse
(
JSON
.
stringify
(
info
))
console
.
log
(
info
)
//console.log('formatted resultset: ' + JSON.stringify(this.formatResults(info)))
self
.
emit
(
'success'
,
this
.
formatResults
(
info
))
}
}.
bind
(
this
));
}.
bind
(
this
));
}.
bind
(
this
))
}.
bind
(
this
))
.
on
(
'error'
,
function
(
err
)
{
.
on
(
'error'
,
function
(
err
)
{
//console.log( err )
//console.log( err )
//console.log('error in query: ' + this.sql)
//console.log('error in query: ' + this.sql)
// if(errorDetected)
if
(
errorDetected
)
{
// return
return
// errorDetected = true
}
// this.emit('sql', this.sql)
errorDetected
=
true
// this.emit('error', err, this.callee)
self
.
emit
(
'sql'
,
this
.
sql
)
self
.
emit
(
'error'
,
err
,
this
.
callee
)
console
.
log
(
'query error'
)
console
.
log
(
'query error'
)
}.
bind
(
this
))
}.
bind
(
this
))
.
on
(
'end'
,
function
()
{
.
on
(
'end'
,
function
(
info
)
{
if
(
errorDetected
)
// nothing here yet
return
this
.
emit
(
'sql'
,
this
.
sql
)
console
.
log
(
'Successful query : '
+
this
.
sql
)
console
.
log
(
resultSet
)
this
.
emit
(
'success'
,
this
.
formatResults
(
resultSet
))
}.
bind
(
this
)).
setMaxListeners
(
100
)
}.
bind
(
this
)).
setMaxListeners
(
100
)
return
this
return
this
...
...
lib/dialects/mysql/query.js
View file @
1cd73a5
...
@@ -29,6 +29,9 @@ module.exports = (function() {
...
@@ -29,6 +29,9 @@ module.exports = (function() {
if
(
err
)
{
if
(
err
)
{
this
.
emit
(
'error'
,
err
,
this
.
callee
)
this
.
emit
(
'error'
,
err
,
this
.
callee
)
}
else
{
}
else
{
console
.
log
(
'sql : '
+
this
.
sql
)
console
.
log
(
'resultset : '
+
JSON
.
stringify
(
results
))
console
.
log
(
'formatted resultset: '
+
JSON
.
stringify
(
this
.
formatResults
(
results
)))
this
.
emit
(
'success'
,
this
.
formatResults
(
results
))
this
.
emit
(
'success'
,
this
.
formatResults
(
results
))
}
}
}.
bind
(
this
)).
setMaxListeners
(
100
)
}.
bind
(
this
)).
setMaxListeners
(
100
)
...
...
spec/config/config.js
View file @
1cd73a5
...
@@ -25,7 +25,7 @@ module.exports = {
...
@@ -25,7 +25,7 @@ module.exports = {
database
:
'sequelize_test'
,
database
:
'sequelize_test'
,
host
:
'127.0.0.1'
,
host
:
'127.0.0.1'
,
port
:
3306
,
port
:
3306
,
pool
:
{
maxConnections
:
1
,
maxIdleTime
:
30
}
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30
}
},
},
sqlite
:
{
sqlite
:
{
...
...
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