Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove queued query #1316

Open
martinmacko47 opened this issue Apr 14, 2021 · 0 comments
Open

Remove queued query #1316

martinmacko47 opened this issue Apr 14, 2021 · 0 comments

Comments

@martinmacko47
Copy link

martinmacko47 commented Apr 14, 2021

Would it be possible to add a connection method that would remove a queued (waiting) query from the connection queue? It would take a single parameter the query object as returned from connection.query() and it would remove the query from the queue if the query is waiting. It should respond with one of three states: query removed, query currently executing (can't be removed), query not found (probably already executed).

A rough pseudocode what it would do (specific implementation details will need to be refined):

class Connection extends EventEmitter {
  ...
  remove (query) {
    if (query === this._command) {
      return false; // Query currently executing
    }
    var idx = this._commands.toArray().indexOf(query)
    if (idx < 0) {
      return false; // Query not found
    }
    this._commands.removeOne(idx)
    return true;
  }
  ...
}

We need this feature for implementing timeouts in Knex.js, see this discussion knex/knex#4416 (comment). We don't want to hack the driver internals and we would prefer to use a supported feature. I'm willing to create a PR with the implementation if the feature would be accepted.

I'm filing a symmetric feature request to mysql driver mysqljs/mysql#2478. It would be good to implement it in a compatible way in both drivers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant