Skip to content

Deprecated Pool.end to Pool.release#517

Closed
jbrooksuk wants to merge 2 commits intomysqljs:masterfrom
jbrooksuk:pool-release
Closed

Deprecated Pool.end to Pool.release#517
jbrooksuk wants to merge 2 commits intomysqljs:masterfrom
jbrooksuk:pool-release

Conversation

@jbrooksuk
Copy link

This is better.

@jbrooksuk
Copy link
Author

Just realised I forgot to add a test to ensure that release and end work. I'll add that now.

Also added test-connection-end.js to ensure it still works
@jbrooksuk
Copy link
Author

I've updated all of the pool tests, and also added test-connection-end to ensure that end still works as it should for now.

@felixge
Copy link
Collaborator

felixge commented Jun 18, 2013

LGTM. Anybody else who can review? cc @dresende @NateLillich ...

@jbrooksuk
Copy link
Author

Looks I like broke the tests, https://travis-ci.org/felixge/node-mysql/jobs/8197741

I thought:

pool.getConnection(function(err, connection) {
  if (err) throw err;
  pool.getConnection(function(err) {
    assert.ok(err);

    var shouldGetConnection        = false;
    pool.config.waitForConnections = true;
    pool.getConnection(function(err, connection2) {
      if (err) throw err;
      assert.ok(shouldGetConnection);
      assert.strictEqual(connection, connection2);

      pool.end();
    });

    shouldGetConnection = true;
    connection.release();
  });
});

Would work?

@tellnes
Copy link
Collaborator

tellnes commented Jun 18, 2013

Pool#release != pooled Connection#release
Take a look at the Pool#_createConnection implementation.

I could probably make a pull request if you don't want to fix it up @jbrooksuk?

@jbrooksuk
Copy link
Author

Ah balls, so I modified the wrong pool?

@jbrooksuk
Copy link
Author

What I should've modified was https://github.com/felixge/node-mysql/blob/master/lib/Pool.js#L147-151 ?

@tellnes
Copy link
Collaborator

tellnes commented Jun 18, 2013

@jbrooksuk yes. And you need to cleanup in Pool#_removeConnection also.

I think we should make the end method only print a deprecation warning and in the next version restore its default behavior.

@jbrooksuk
Copy link
Author

Okay, so if I go through and rename .end in regards to actual pool Connection#end do you want .end to not be an alias? Just simply warn that it's deprecated?

And could you quickly explain what you mean by tidy Pool#_removeConnection? I see it's using _realEnd etc, those will be renamed too right?

@tellnes
Copy link
Collaborator

tellnes commented Jun 18, 2013

The end method should print a warning and then call the release method. In the next version we should remove the custom end function so it will get back it's default behavior.

In Pool#_removeConnection you should cleanup the connection object like it was never used in the pool. Thus restor the orginal end method (like it does today) and remove the release method.

@dresende
Copy link
Collaborator

Yes, you should just rename .end to .release and add an .end that would throw the warning and call .release. (not actually throw, write to stderr..)

@tellnes tellnes closed this Jul 13, 2013
dveeden pushed a commit to dveeden/mysql that referenced this pull request Jan 31, 2023
* Update CHANGELOG
* README: Removed most recent version and build status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants