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 33ba2927
authored
Sep 14, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
catch errors when connecting to non default mysql server fails
1 parent
2b635550
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
lib/sequelize/Sequelize.js
lib/sequelize/Sequelize.js
View file @
33ba292
...
...
@@ -167,39 +167,39 @@ Sequelize.prototype = {
query
:
function
(
queryString
,
callback
)
{
var
fields
=
[],
values
=
[],
self
=
this
require
(
__dirname
+
"/../nodejs-mysql-native/index"
).
createTCPClient
(
this
.
config
.
host
,
this
.
config
.
port
,
function
(
err
,
connection
)
{
if
(
err
)
callback
(
null
,
null
,
{
message
:
"Unable to establish a connection to "
+
[
self
.
config
.
host
,
self
.
config
.
port
].
join
(
":"
)
})
else
{
connection
.
auto_prepare
=
true
connection
.
auth
(
self
.
config
.
database
,
self
.
config
.
username
,
self
.
config
.
password
)
.
addListener
(
"error"
,
function
(
err
)
{
callback
(
null
,
null
,
err
)
})
.
addListener
(
'authorized'
,
function
()
{
if
(
!
self
.
options
.
disableLogging
)
Sequelize
.
Helper
.
log
(
"Executing the query: "
+
queryString
)
self
=
this
,
client
=
require
(
__dirname
+
"/../nodejs-mysql-native/index"
).
createTCPClient
(
this
.
config
.
host
,
this
.
config
.
port
)
client
.
connection
.
on
(
'error'
,
function
()
{
callback
(
null
,
null
,
{
message
:
"Unable to establish a connection to "
+
[
self
.
config
.
host
,
self
.
config
.
port
].
join
(
":"
)
})
})
client
.
auto_prepare
=
true
client
.
auth
(
self
.
config
.
database
,
self
.
config
.
username
,
self
.
config
.
password
)
.
on
(
'error'
,
function
(
err
)
{
callback
(
null
,
null
,
err
)
})
.
on
(
'authorized'
,
function
()
{
if
(
!
self
.
options
.
disableLogging
)
Sequelize
.
Helper
.
log
(
"Executing the query: "
+
queryString
)
connection
.
query
(
queryString
)
.
on
(
'row'
,
function
(
r
){
values
.
push
(
r
)
})
.
on
(
'field'
,
function
(
f
){
fields
.
push
(
f
)})
.
on
(
'end'
,
function
(
stats
)
{
if
(
callback
)
{
var
result
=
[]
values
.
forEach
(
function
(
valueArray
)
{
var
mapping
=
{}
for
(
var
i
=
0
;
i
<
fields
.
length
;
i
++
)
mapping
[
fields
[
i
].
name
]
=
valueArray
[
i
]
result
.
push
(
mapping
)
})
if
(
callback
)
callback
(
result
,
stats
)
}
client
.
query
(
queryString
)
.
on
(
'row'
,
function
(
r
){
values
.
push
(
r
)
})
.
on
(
'field'
,
function
(
f
){
fields
.
push
(
f
)})
.
on
(
'end'
,
function
(
stats
)
{
if
(
callback
)
{
var
result
=
[]
values
.
forEach
(
function
(
valueArray
)
{
var
mapping
=
{}
for
(
var
i
=
0
;
i
<
fields
.
length
;
i
++
)
mapping
[
fields
[
i
].
name
]
=
valueArray
[
i
]
result
.
push
(
mapping
)
})
connection
.
close
()
if
(
callback
)
callback
(
result
,
stats
)
}
})
}
})
client
.
close
()
})
}
}
...
...
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