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 a9b6d98c
authored
Oct 18, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the connector manager is now a part of the transaction manager
1 parent
bccd3a0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
17 deletions
lib/sequelize.js
lib/transaction-manager.js
lib/sequelize.js
View file @
a9b6d98
var
url
=
require
(
"url"
)
var
url
=
require
(
"url"
)
,
Path
=
require
(
"path"
)
,
Path
=
require
(
"path"
)
,
Utils
=
require
(
"./utils"
)
,
Utils
=
require
(
"./utils"
)
,
DAOFactory
=
require
(
"./dao-factory"
)
,
DAOFactory
=
require
(
"./dao-factory"
)
,
DataTypes
=
require
(
'./data-types'
)
,
DataTypes
=
require
(
'./data-types'
)
,
DAOFactoryManager
=
require
(
"./dao-factory-manager"
)
,
DAOFactoryManager
=
require
(
"./dao-factory-manager"
)
,
QueryInterface
=
require
(
"./query-interface"
)
,
QueryInterface
=
require
(
"./query-interface"
)
,
Transaction
=
require
(
"./transaction"
)
,
Transaction
=
require
(
"./transaction"
)
,
TransactionManager
=
require
(
'./transaction-manager'
)
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
/**
/**
...
@@ -73,6 +74,7 @@ module.exports = (function() {
...
@@ -73,6 +74,7 @@ module.exports = (function() {
dialect
:
'mysql'
,
dialect
:
'mysql'
,
dialectModulePath
:
null
,
dialectModulePath
:
null
,
host
:
'localhost'
,
host
:
'localhost'
,
port
:
3306
,
protocol
:
'tcp'
,
protocol
:
'tcp'
,
define
:
{},
define
:
{},
query
:
{},
query
:
{},
...
@@ -110,14 +112,8 @@ module.exports = (function() {
...
@@ -110,14 +112,8 @@ module.exports = (function() {
dialectOptions
:
this
.
options
.
dialectOptions
,
dialectOptions
:
this
.
options
.
dialectOptions
,
}
}
try
{
this
.
daoFactoryManager
=
new
DAOFactoryManager
(
this
)
var
ConnectorManager
=
require
(
"./dialects/"
+
this
.
options
.
dialect
+
"/connector-manager"
)
this
.
transactionManager
=
new
TransactionManager
(
this
)
}
catch
(
err
)
{
throw
new
Error
(
"The dialect "
+
this
.
options
.
dialect
+
" is not supported."
)
}
this
.
daoFactoryManager
=
new
DAOFactoryManager
(
this
)
this
.
connectorManager
=
new
ConnectorManager
(
this
,
this
.
config
)
this
.
importCache
=
{}
this
.
importCache
=
{}
}
}
...
@@ -132,6 +128,24 @@ module.exports = (function() {
...
@@ -132,6 +128,24 @@ module.exports = (function() {
}
}
/**
/**
* Polyfill for the default connector manager.
*/
Object
.
defineProperty
(
Sequelize
.
prototype
,
'connectorManager'
,
{
get
:
function
()
{
return
this
.
transactionManager
.
getConnectorManager
()
}
})
/**
* Returns the specified dialect.
*
* @return {String} The specified dialect.
*/
Sequelize
.
prototype
.
getDialect
=
function
()
{
return
this
.
options
.
dialect
}
/**
Returns an instance of QueryInterface.
Returns an instance of QueryInterface.
@method getQueryInterface
@method getQueryInterface
...
@@ -288,7 +302,7 @@ module.exports = (function() {
...
@@ -288,7 +302,7 @@ module.exports = (function() {
type
:
(
sql
.
toLowerCase
().
indexOf
(
'select'
)
===
0
)
?
'SELECT'
:
false
type
:
(
sql
.
toLowerCase
().
indexOf
(
'select'
)
===
0
)
?
'SELECT'
:
false
})
})
return
this
.
connector
Manager
.
query
(
sql
,
callee
,
options
)
return
this
.
transaction
Manager
.
query
(
sql
,
callee
,
options
)
}
}
Sequelize
.
prototype
.
createSchema
=
function
(
schema
)
{
Sequelize
.
prototype
.
createSchema
=
function
(
schema
)
{
...
...
lib/transaction-manager.js
0 → 100644
View file @
a9b6d98
Utils
=
require
(
'./utils'
)
var
TransactionManager
=
module
.
exports
=
function
(
sequelize
)
{
this
.
sequelize
=
sequelize
this
.
connectorManagers
=
{}
try
{
this
.
ConnectorManager
=
require
(
"./dialects/"
+
sequelize
.
getDialect
()
+
"/connector-manager"
)
}
catch
(
err
)
{
throw
new
Error
(
"The dialect "
+
sequelize
.
getDialect
()
+
" is not supported."
)
}
}
TransactionManager
.
prototype
.
getConnectorManager
=
function
(
uuid
)
{
uuid
=
uuid
||
'default'
if
(
!
this
.
connectorManagers
.
hasOwnProperty
(
uuid
))
{
var
config
=
Utils
.
_
.
clone
(
this
.
sequelize
.
config
)
if
(
uuid
!==
'default'
)
{
config
.
pool
=
{
maxConnections
:
1
,
useReplicaton
:
false
}
}
this
.
connectorManagers
[
uuid
]
=
new
this
.
ConnectorManager
(
this
.
sequelize
,
config
)
}
return
this
.
connectorManagers
[
uuid
]
}
TransactionManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
var
uuid
=
'default'
if
(
options
&&
options
.
transaction
)
{
uuid
=
options
.
transaction
.
id
}
return
this
.
getConnectorManager
(
uuid
).
query
(
sql
,
callee
,
options
)
}
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