Skip to content

Commit 86cc581

Browse files
committed
Fixing issue where when on error event handler was attached, node-db fails horribly. Fixes mariano#38
1 parent 2d3f570 commit 86cc581

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ For more in depth changelog, check the Github Commits:
22

33
https://github.com/mariano/node-db-mysql/commits/master
44

5+
0.7.4
6+
-----
7+
* Fixing issue where when on error event handler was attached, node-db fails horribly
8+
59
0.7.3
610
-----
711
* Fixing issue when using the three-argument call on Query::execute()

db-mysql.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,15 @@ function extend(target, source) {
2525
return target;
2626
}
2727

28-
exports.Query = extend(binding.Query, EventEmitter);
29-
exports.Database = extend(binding.Mysql, EventEmitter);
28+
var BaseEventEmitter = extend(function() {}, EventEmitter);
29+
BaseEventEmitter.prototype.emit = function() {
30+
var type = arguments[0];
31+
if (type === 'error' && (!this._events || !this._events.error || (Array.isArray(this._events.error) && !this._events.error.length))) {
32+
// Silently allow unattached error events
33+
return;
34+
}
35+
return EventEmitter.prototype.emit.apply(this, arguments);
36+
}
37+
38+
exports.Query = extend(binding.Query, BaseEventEmitter);
39+
exports.Database = extend(binding.Mysql, BaseEventEmitter);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
, "description" : "MySQL database bindings for Node.JS"
33
, "keywords": ["database","db","native","binding","library","plugin","client","mysql","libmysql"]
44
, "homepage" : "http://nodejsdb.org/db-mysql"
5-
, "version" : "0.7.3"
5+
, "version" : "0.7.4"
66
, "engines" : { "node" : ">=0.4.1" }
77
, "maintainers" :
88
[ { "name": "Mariano Iglesias"

wscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from os.path import exists
1111

1212
srcdir = "."
1313
blddir = "build"
14-
VERSION = "0.7.3"
14+
VERSION = "0.7.4"
1515

1616
def set_options(opt):
1717
opt.tool_options("compiler_cxx")

0 commit comments

Comments
 (0)