Pull.
J'ai juste update le cutie.js, CONNARD Ah oui, j'ai aussi add le info.js, qui est merdique d'ailleurs
This commit is contained in:
77
node_modules/mysql2/lib/commands/query.js
generated
vendored
77
node_modules/mysql2/lib/commands/query.js
generated
vendored
@@ -271,30 +271,67 @@ class Query extends Command {
|
||||
}
|
||||
|
||||
stream(options) {
|
||||
options = options || {};
|
||||
options = options || Object.create(null);
|
||||
options.objectMode = true;
|
||||
const stream = new Readable(options);
|
||||
stream._read = () => {
|
||||
this._connection && this._connection.resume();
|
||||
};
|
||||
this.on('result', (row, resultSetIndex) => {
|
||||
if (!stream.push(row)) {
|
||||
this._connection.pause();
|
||||
|
||||
const stream = new Readable({
|
||||
...options,
|
||||
emitClose: true,
|
||||
autoDestroy: true,
|
||||
read: () => {
|
||||
this._connection && this._connection.resume();
|
||||
},
|
||||
});
|
||||
|
||||
// Prevent a breaking change for users that rely on `end` event
|
||||
stream.once('close', () => {
|
||||
if (!stream.readableEnded) {
|
||||
stream.emit('end');
|
||||
}
|
||||
stream.emit('result', row, resultSetIndex); // replicate old emitter
|
||||
});
|
||||
this.on('error', (err) => {
|
||||
stream.emit('error', err); // Pass on any errors
|
||||
});
|
||||
this.on('end', () => {
|
||||
stream.push(null); // pushing null, indicating EOF
|
||||
});
|
||||
this.on('fields', (fields) => {
|
||||
|
||||
const onResult = (row, index) => {
|
||||
if (stream.destroyed) return;
|
||||
|
||||
if (!stream.push(row)) {
|
||||
this._connection && this._connection.pause();
|
||||
}
|
||||
|
||||
stream.emit('result', row, index); // replicate old emitter
|
||||
};
|
||||
|
||||
const onFields = (fields) => {
|
||||
if (stream.destroyed) return;
|
||||
|
||||
stream.emit('fields', fields); // replicate old emitter
|
||||
});
|
||||
stream.on('end', () => {
|
||||
stream.emit('close');
|
||||
});
|
||||
};
|
||||
|
||||
const onEnd = () => {
|
||||
if (stream.destroyed) return;
|
||||
|
||||
stream.push(null); // pushing null, indicating EOF
|
||||
};
|
||||
|
||||
const onError = (err) => {
|
||||
stream.destroy(err);
|
||||
};
|
||||
|
||||
stream._destroy = (err, cb) => {
|
||||
this._connection && this._connection.resume();
|
||||
|
||||
this.removeListener('result', onResult);
|
||||
this.removeListener('fields', onFields);
|
||||
this.removeListener('end', onEnd);
|
||||
this.removeListener('error', onError);
|
||||
|
||||
cb(err); // Pass on any errors
|
||||
};
|
||||
|
||||
this.on('result', onResult);
|
||||
this.on('fields', onFields);
|
||||
this.on('end', onEnd);
|
||||
this.on('error', onError);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user