     if @sessionClient
       return callback null, @sessionClient
 
-    @pg.connect @connectionUrl, (err, client) =>
+    @pg.connect @connectionUrl, (err, client, done) =>
+      client.done = done
       callback err, client
 
   # Creates a session with a new or nested transaction.

    @client (err, client) =>
      return callback err if err

      transaction = new Transaction client, @transaction
      transaction.start (err) =>
        return callback err if err


    @client (err, client) ->
      return callback err if err
      client.query args..., callback
      client.done() unless @transaction

  # Runs queries within a nested transaction, rolling back on any error.
  #
