pg_builder 2.0.0 and pg_wrapper 2.0.0 packages for PHP released

From: Alexey Borzov via PostgreSQL Announce <announce-noreply(at)postgresql(dot)org>
To: PostgreSQL Announce <pgsql-announce(at)lists(dot)postgresql(dot)org>
Subject: pg_builder 2.0.0 and pg_wrapper 2.0.0 packages for PHP released
Date: 2022-01-02 21:25:11
Message-ID: 164115871141.21660.4321623406828097270@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce

I'm pleased to announce the new releases of [pg_builder](https://github.com/sad-spirit/pg-builder) and [pg_wrapper](https://github.com/sad-spirit/pg-wrapper) packages. The main topic of these releases is support for Postgres 14 and PHP 8.1

## pg_builder version 2.0.0

pg_builder is a query builder for Postgres backed by a partial PHP reimplementation of PostgreSQL's own SQL parser. It supports almost all syntax available in Postgres 14 for `SELECT` (and `VALUES`), `INSERT`, `UPDATE`, and `DELETE` queries.

With pg_builder it is possible to start with a manually written query, parse it into an Abstract Syntax Tree, add query parts (either as `Node` objects or as strings) to this tree or remove them, and finally convert the tree back to an SQL string.

Release highlights

* Support for new syntax of Postgres 14: most of the keywords can be used as column aliases without `AS`; `DISTINCT` clause for `GROUP BY`; `SEARCH` and `CYCLE` clauses for Common Table Expressions; alias for `USING` clause of `JOIN` expressions.
* SQL functions with custom argument format (arguments separated by keywords, keywords as arguments, etc) are now parsed to specialized `Node`s and will appear in generated SQL the same way they did in source: `trim(trailing 'o' from 'foo')` rather than `pg_catalog.rtrim('foo', 'o')`. This follows the changes done in Postgres 14 itself.
* No `E_DEPRECATED` errors when running under PHP 8.1

[Full release notes](https://github.com/sad-spirit/pg-builder/blob/v2.0.0/Changelog.md)

The package can be [downloaded from Github](https://github.com/sad-spirit/pg-builder/releases/tag/v2.0.0) or installed with Composer:

```$ composer require sad_spirit/pg_builder```

pg_builder can be used on its own, using it together with pg_wrapper allows to run the built queries with transparent conversion of query parameters to Postgres types.

## pg_wrapper version 2.0.0

pg_wrapper provides converters for PostgreSQL data types and an OO wrapper around PHP's native pgsql extension that uses these converters. Conversion of query result fields is done automatically using database metadata, query parameters may require specifying type.

For those types where a corresponding native PHP type or class is available it is used (text -> string, timestamp -> DateTimeImmutable, hstore -> associative array, etc.). For other types (geometric types, ranges) the package provides custom classes.

Release highlights

* Full support for multirange types added in Postgres 14, with `types\Multirange` and its descendants to represent the values on PHP side and `converters\containers\MultiRangeConverter` to transform the values to and from DB string representation.
* Support changes to pgsql extension done in PHP 8.1: objects are used instead of resources for connection and query results.

[Full release notes](https://github.com/sad-spirit/pg-wrapper/blob/v2.0.0/Changelog.md)

The package can be [downloaded from Github](https://github.com/sad-spirit/pg-wrapper/releases/tag/v2.0.0) or installed with Composer:

```$ composer require sad_spirit/pg_wrapper```

Browse pgsql-announce by date

  From Date Subject
Next Message PWN via PostgreSQL Announce 2022-01-05 12:42:27 PostgreSQL Weekly News - January 2, 2022
Previous Message Toshiba via PostgreSQL Announce 2022-01-02 17:22:50 DynamoDB FDW 1.1.0 released