pg-builder

Query builder for Postgres backed by SQL parser

BSD-2-CLAUSE License

Downloads
23.1K
Stars
50
Committers
2
pg-builder - Release 2.4.0 - upgraded for pg_wrapper 2.4.0 Latest Release

Published by sad-spirit 5 months ago

  • NativeStatement::prepare() and executePrepared() use the API introduced in pg_wrapper 2.4.0
  • No longer use names deprecated in pg_wrapper 2.4.0: ResultSet -> Result, Connection::getResource() ->
    Connection::getNative().
pg-builder - Release 2.3.1 - Additional PDO::prepare() compatibility

Published by sad-spirit 11 months ago

It is now possible to generate SQL suitable for PDO::prepare() even if a query does not contain placeholders, see #15

pg-builder - Release 2.3.0 - Postgres 16 syntax supported

Published by sad-spirit about 1 year ago

  • SQL/JSON functions and expressions: IS JSON predicate, aggregate functions json_arrayagg() and json_objectagg(), constructor functions json_array() and json_object().
  • Non-decimal integer literals and underscores as separators in numeric literals.
  • Aliases for subqueries in FROM are now optional.
  • SYSTEM_USER server variable.
  • [NO] INDENT option for XMLSERIALIZE() expression.
pg-builder - Release 2.3.0 - first beta

Published by sad-spirit about 1 year ago

Support for new syntax of PostgreSQL 16 (as of beta 3)

  • SQL/JSON functions and expressions: IS JSON predicate, aggregate functions json_arrayagg() and json_objectagg(), constructor functions json_array() and json_object().
  • Allow non-decimal integer literals and underscores as separators in numeric literals.
  • Aliases for subqueries in FROM are now optional.
  • SYSTEM_USER server variable.
  • [NO] INDENT option for XMLSERIALIZE() expression.
pg-builder - Release 2.2.0 - Better integration with pg_wrapper

Published by sad-spirit over 1 year ago

The new recommended way to enable pg_builder features in pg_wrapper's type conversion is to use a BuilderSupportDecorator which decorates an instance of DefaultTypeConverterFactory rather than ParserAwareTypeConverterFactory which is a subclass of DefaultTypeConverterFactory.

Both of these implement the new TypeNameNodeHandler interface which can be used in typehints instead of a specific class.

pg-builder - Release 2.1.0 - Postgres 15 syntax supported

Published by sad-spirit almost 2 years ago

Added support for new/changed syntax of Postgres 15:

  • Allow parsing and building MERGE statements. Backed by Merge class and StatementFactory::merge() helper method.
  • Reject numeric literals and positional parameters with trailing non-digits: previously SELECT 123abc was parsed as
    SELECT 123 AS abc, now it will throw a SyntaxException.
pg-builder - Release 2.1.0 (beta 2) - with support for Postgres 15 syntax

Published by sad-spirit about 2 years ago

Removed support for SQL/JSON syntax which had been removed in PostgreSQL 15 beta 4

pg-builder - Release 2.1.0 (beta) - with support for Postgres 15 syntax

Published by sad-spirit about 2 years ago

Added support for new syntax of Postgres 15:

  • MERGE statement
  • SQL/JSON functions
pg-builder - Release 2.0.1

Published by sad-spirit over 2 years ago

Bugfix release - Parser accepts SELECT queries with empty target lists (thanks to @rvanvelzen for PR #14).

pg-builder - Release 2.0.0 - Updated for Postgres 14 and PHP 8.1

Published by sad-spirit almost 3 years ago

New features

  • Added support for new syntax of Postgres 14
    • It is now possible to use most of the keywords as column aliases without AS.
    • DISTINCT clause for GROUP BY.
    • SEARCH and CYCLE clauses for Common Table Expressions.
    • Alias for USING clause of JOIN expression.
  • Package runs under PHP 8.1 without E_DEPRECATED errors
  • Represent SQL functions with non-standard argument syntax with separate Nodes, generated SQL is now closer to input

Major version is changed due to BC breaks mirroring those of Postgres 14:

  • Removed support for postfix operators and IS [NOT] OF clauses
pg-builder - Release 2.0.0 - first beta

Published by sad-spirit almost 3 years ago

Updated for Postgres 14 and PHP 8.1

  • Added support for new syntax of Postgres 14
  • Removed support for postfix operators and IS [NOT] OF clauses that were removed in Postgres 14
  • Represent SQL functions with non-standard argument syntax with separate Nodes
  • Package runs under PHP 8.1 without E_DEPRECATED errors
pg-builder - Release 1.0.2

Published by sad-spirit about 3 years ago

Bugfix release, space before NOT was missing when generating SQL for NOT BETWEEN expressions.

pg-builder - Release 1.0.1

Published by sad-spirit over 3 years ago

Bugfix release, recursive property of WithClause was not properly set when passing SQL strings to its merge() and replace() methods.

pg-builder - Release 1.0.0 - first stable release

Published by sad-spirit over 3 years ago

Focus of this major release is API refinement, performance improvements and removal of deprecated functionality.

  • Requires PHP 7.2 (uses strict_types) and Postgres 9.5 at least. Tested and supported on PHP 8.
  • Uses phpstan and psalm for static code analysis and implementing generics for Collection-like objects.
  • Added support for Unicode escapes in string literals and identifiers, support for function-like constructs in FROM clause.
  • 20-25% better performance across the board.
  • Easier generation of queries suitable for PDO.
  • Implemented more specific Nodes for various SQL constructs.

Consult changelog for the full list of changes and upgrade instructions for the means to automate the upgrade.

Support for postfix operators and undocumented IS [NOT] OF construct is deprecated. Those will be removed in Postgres 14 and in the future release of pg_builder supporting Postgres 14 syntax.