Code coverage report for upstream/lib/transaction-manager.js

Statements: 95.45% (21 / 22)      Branches: 80% (8 / 10)      Functions: 100% (3 / 3)      Lines: 95.45% (21 / 22)     

All files » upstream/lib/ » transaction-manager.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 411   1 7 7   7 7           1 2581   2581 13   13 12 12     13     2581     1 2569 2569   2569 79     2569    
var 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._.extend({ uuid: uuid }, this.sequelize.config)
 
    if (uuid !== 'default') {
      config.pool                = { maxConnections: 0, useReplicaton: false }
      config.keepDefaultTimezone = true
    }
 
    this.connectorManagers[uuid] = new this.ConnectorManager(this.sequelize, config)
  }
 
  return this.connectorManagers[uuid]
}
 
TransactionManager.prototype.query = function(sql, callee, options) {
  options      = options || {}
  options.uuid = 'default'
 
  if (options.transaction) {
    options.uuid = options.transaction.id
  }
 
  return this.getConnectorManager(options.uuid).query(sql, callee, options)
}