[misc] changing stream event "columns" to "fields" for mysql compatibility

This commit is contained in:
rusher
2018-07-16 11:45:14 +02:00
parent 1635181be0
commit 62f1fcaaf7
5 changed files with 11 additions and 9 deletions

View File

@ -587,7 +587,7 @@ connection.queryStream("SELECT * FROM mysql.user")
.on("error", err => {
console.log(err); //if error
})
.on("columns", meta => {
.on("fields", meta => {
console.log(meta); // [ ...]
})
.on("data", row => {

View File

@ -210,7 +210,7 @@ connection.query("SELECT * FROM mysql.user")
.on("error", err => {
console.log(err); //if error
})
.on("columns", meta => {
.on("fields", meta => {
console.log(meta); // [ ... ]
})
.on("data", row => {

View File

@ -211,7 +211,7 @@ class ResultSet extends Command {
}
}
this.emit("columns", this._columns);
this.emit("fields", this._columns);
return (this.onPacketReceive = info.eofDeprecated
? this.readResultSetRow

View File

@ -18,8 +18,8 @@ class Stream extends Query {
}
});
this.on("columns", function(meta) {
this.inStream.emit("columns", meta);
this.on("fields", function(meta) {
this.inStream.emit("fields", meta);
});
this.on("end", function(err) {
@ -29,7 +29,9 @@ class Stream extends Query {
}
handleNewRows(row) {
if (!this.inStream.push(row)) this.socket.pause();
if (!this.inStream.push(row)) {
this.socket.pause();
}
}
}

View File

@ -40,7 +40,7 @@ describe("results-set streaming", () => {
.on("error", err => {
done(new Error("must not have thrown any error !"));
})
.on("columns", meta => {
.on("fields", meta => {
assert.equal(meta.length, 1);
metaReceived = true;
})
@ -67,7 +67,7 @@ describe("results-set streaming", () => {
.on("error", err => {
done(new Error("must not have thrown any error !"));
})
.on("columns", meta => {
.on("fields", meta => {
assert.equal(meta.length, 1);
metaReceived = true;
})
@ -92,7 +92,7 @@ describe("results-set streaming", () => {
.on("error", err => {
done(new Error("must not have thrown any error !"));
})
.on("columns", meta => {
.on("fields", meta => {
assert.equal(meta.length, 1);
metaReceived = true;
})