不要怂,就是干,撸起袖子干!

Commit 53007f22 by Jan Aagaard Meier

Merge pull request #1051 from elliotf/elliotf_stop_global_leak_smart

Stop leaking "smart" variable
2 parents ff71e03e f4394311
...@@ -13,9 +13,9 @@ teaser: ...@@ -13,9 +13,9 @@ teaser:
test: test:
@if [ "$$GREP" ]; then \ @if [ "$$GREP" ]; then \
make teaser && ./node_modules/mocha/bin/mocha --colors -t 10000 --reporter $(REPORTER) -g "$$GREP" $(TESTS); \ make teaser && ./node_modules/mocha/bin/mocha --check-leaks --colors -t 10000 --reporter $(REPORTER) -g "$$GREP" $(TESTS); \
else \ else \
make teaser && ./node_modules/mocha/bin/mocha --colors -t 10000 --reporter $(REPORTER) $(TESTS); \ make teaser && ./node_modules/mocha/bin/mocha --check-leaks --colors -t 10000 --reporter $(REPORTER) $(TESTS); \
fi fi
......
...@@ -10,7 +10,9 @@ module.exports = (function() { ...@@ -10,7 +10,9 @@ module.exports = (function() {
} }
HasManyDoubleLinked.prototype.injectGetter = function(options) { HasManyDoubleLinked.prototype.injectGetter = function(options) {
var self = this, _options = options var self = this
, _options = options
, smart
var customEventEmitter = new Utils.CustomEventEmitter(function() { var customEventEmitter = new Utils.CustomEventEmitter(function() {
var where = {} var where = {}
......
...@@ -9,6 +9,7 @@ module.exports = (function() { ...@@ -9,6 +9,7 @@ module.exports = (function() {
HasManySingleLinked.prototype.injectGetter = function(options) { HasManySingleLinked.prototype.injectGetter = function(options) {
var self = this var self = this
, where = {} , where = {}
, smart
options = options || {} options = options || {}
var primaryKey = Object.keys(this.instance.rawAttributes).filter(function(k) { return self.instance.rawAttributes[k].primaryKey === true }) var primaryKey = Object.keys(this.instance.rawAttributes).filter(function(k) { return self.instance.rawAttributes[k].primaryKey === true })
......
...@@ -45,6 +45,7 @@ module.exports = (function() { ...@@ -45,6 +45,7 @@ module.exports = (function() {
HasOne.prototype.injectGetter = function(obj) { HasOne.prototype.injectGetter = function(obj) {
var self = this var self = this
, smart
obj[this.accessors.get] = function(params) { obj[this.accessors.get] = function(params) {
var primaryKeys = Object.keys(this.daoFactory.primaryKeys) var primaryKeys = Object.keys(this.daoFactory.primaryKeys)
......
...@@ -248,6 +248,7 @@ module.exports = (function() { ...@@ -248,6 +248,7 @@ module.exports = (function() {
, i , i
, scope , scope
, scopeName , scopeName
, scopeOptions
, argLength = arguments.length , argLength = arguments.length
, lastArg = arguments[argLength-1] , lastArg = arguments[argLength-1]
......
...@@ -133,6 +133,7 @@ module.exports = (function() { ...@@ -133,6 +133,7 @@ module.exports = (function() {
, isEnum = definition.type && (definition.type.toString() === DataTypes.ENUM.toString()) , isEnum = definition.type && (definition.type.toString() === DataTypes.ENUM.toString())
, isMySQL = ['mysql', 'mariadb'].indexOf(self.daoFactory.daoFactoryManager.sequelize.options.dialect) !== -1 , isMySQL = ['mysql', 'mariadb'].indexOf(self.daoFactory.daoFactoryManager.sequelize.options.dialect) !== -1
, ciCollation = !!self.daoFactory.options.collate && self.daoFactory.options.collate.match(/_ci$/i) , ciCollation = !!self.daoFactory.options.collate && self.daoFactory.options.collate.match(/_ci$/i)
, valueOutOfScope
// Unfortunately for MySQL CI collation we need to map/lowercase values again // Unfortunately for MySQL CI collation we need to map/lowercase values again
if (isEnum && isMySQL && ciCollation && (attrName in values) && values[attrName]) { if (isEnum && isMySQL && ciCollation && (attrName in values) && values[attrName]) {
......
...@@ -32,6 +32,8 @@ module.exports = (function() { ...@@ -32,6 +32,8 @@ module.exports = (function() {
.on('result', function(results) { .on('result', function(results) {
results results
.on('row', function(row, metadata) { .on('row', function(row, metadata) {
var type
for (var prop in row) { for (var prop in row) {
if (row.hasOwnProperty(prop)) { if (row.hasOwnProperty(prop)) {
if (row[prop] === null) { if (row[prop] === null) {
......
...@@ -145,10 +145,14 @@ module.exports = (function() { ...@@ -145,10 +145,14 @@ module.exports = (function() {
}, },
arrayValue: function(value, key, _key, factory){ arrayValue: function(value, key, _key, factory){
var col = null
, coltype = null
, _realKey = key.split('.').pop()
, _value
if (value.length === 0) { value = [null] } if (value.length === 0) { value = [null] }
var col = null, coltype = null
// Special conditions for searching within an array column type // Special conditions for searching within an array column type
var _realKey = key.split('.').pop()
if (!!factory && !!factory.rawAttributes[_realKey]) { if (!!factory && !!factory.rawAttributes[_realKey]) {
col = factory.rawAttributes[_realKey] col = factory.rawAttributes[_realKey]
coltype = col.type coltype = col.type
......
...@@ -35,8 +35,13 @@ module.exports = (function() { ...@@ -35,8 +35,13 @@ module.exports = (function() {
self.database[getDatabaseMethod.call(self)](self.sql, function(err, results) { self.database[getDatabaseMethod.call(self)](self.sql, function(err, results) {
// allow clients to listen to sql to do their own logging or whatnot // allow clients to listen to sql to do their own logging or whatnot
self.emit('sql', self.sql) self.emit('sql', self.sql)
this.columnTypes = columnTypes;
err ? onFailure.call(self, err) : onSuccess.call(self, results, this) if (err) {
onFailure.call(self, err)
} else {
this.columnTypes = columnTypes
onSuccess.call(self, results, this)
}
}) })
}; };
......
...@@ -6087,6 +6087,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -6087,6 +6087,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}) })
it('on success', function(done) { it('on success', function(done) {
var beforeHook
, afterHook
this.User.beforeDelete(function(user, fn) { this.User.beforeDelete(function(user, fn) {
beforeHook = true beforeHook = true
fn() fn()
...@@ -6107,6 +6110,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -6107,6 +6110,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}) })
it('on error', function(done) { it('on error', function(done) {
var beforeHook
, afterHook
this.User.beforeDelete(function(user, fn) { this.User.beforeDelete(function(user, fn) {
beforeHook = true beforeHook = true
fn() fn()
...@@ -6142,6 +6148,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -6142,6 +6148,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}) })
it('on success', function(done) { it('on success', function(done) {
var beforeHook
, afterHook
this.User.hook('beforeDelete', function(user, fn) { this.User.hook('beforeDelete', function(user, fn) {
beforeHook = true beforeHook = true
fn() fn()
...@@ -6162,6 +6171,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -6162,6 +6171,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}) })
it('on error', function(done) { it('on error', function(done) {
var beforeHook
, afterHook
this.User.hook('beforeDelete', function(user, fn) { this.User.hook('beforeDelete', function(user, fn) {
beforeHook = true beforeHook = true
fn() fn()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!