Skip to content

0.2.0

Compare
Choose a tag to compare
@trowski trowski released this 12 Dec 16:52
· 253 commits to 2.x since this release
d979278

This release adds some new features and bugfixes while mostly maintaining compatibility with the prior release. Parameter changes to execute() is the most notable API break that will require some minor updates to existing code using this library.

API Changes

  • Connection::execute() and Pool::execute() now use an array of query parameters as the second parameter instead of being variadic.
  • Statement::execute() also uses an array of query parameters instead of being variadic.
  • Pool no longer extends Connection. Instead Pool and Connection implement a new common interface, Link. Use Link if a pool or single connection may be used.
  • Abstract class TupleResult renamed to ResultSet and is now an interface. Result set classes have been renamed with ResultSet as a suffix (e.g.: PqUnbufferedResultSet).

New Features

  • Pool::extractConnection() added to extract a connection from a pool. Once extracted, the connection will not automatically re-added to the pool.
  • quoteString() and quoteName() added to Handle interface that quote value strings and identifier names respectively for safe insertion into query strings.
  • Added QueryExecutionError exception class extending QueryError, adding a getDiagnostics() method that returns an array of debug information. See PQresultErrorField docs.
  • Added isAlive() to Handle interface that returns false if the database connection has been closed. Connections in pool are automatically removed if isAlive() returns false.
  • Added getQuery() to Statement interface that returns the prepared SQL string.

Fixes

  • Preparing an invalid query with the pgsql extension will fail the promise returned from Executor::prepare() instead of failing when trying to use Statement::execute().
  • Prepared statements mark a pooled connection as busy to prevent unintentional query overlap. Avoid using a pool to generate a large number of long-held prepared statements.