Code coverage report for upstream/lib/dialects/mysql/query.js

Statements: 95.24% (20 / 21)      Branches: 66.67% (4 / 6)      Functions: 100% (4 / 4)      Lines: 95.24% (20 / 21)     

All files » upstream/lib/dialects/mysql/ » query.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 41 42 431     1 1 2569 2569 2569 2569           2569     1 1 2569   2569       2569 2568   2568 6 6   2562     2569     1        
var Utils         = require("../../utils")
  , AbstractQuery = require('../abstract/query')
 
module.exports = (function() {
  var Query = function(client, sequelize, callee, options) {
    this.client    = client
    this.callee    = callee
    this.sequelize = sequelize
    this.options   = Utils._.extend({
      logging: console.log,
      plain: false,
      raw: false
    }, options || {})
 
    this.checkLoggingOption()
  }
 
  Utils.inherit(Query, AbstractQuery)
  Query.prototype.run = function(sql) {
    this.sql = sql
 
    Iif (this.options.logging !== false) {
      this.options.logging('Executing (' + this.options.uuid + '): ' + this.sql)
    }
 
    this.client.query(this.sql, function(err, results, fields) {
      this.emit('sql', this.sql)
 
      if (err) {
        err.sql = sql
        this.emit('error', err, this.callee)
      } else {
        this.emit('success', this.formatResults(results))
      }
    }.bind(this)).setMaxListeners(100)
    return this
  }
 
  return Query
})()