diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad90080..c00ef1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.3', '8.4', '8.5'] + php: ['8.4', '8.5'] services: mysql: image: mysql:8.4 diff --git a/CHANGELOG.md b/CHANGELOG.md index cae9572..5800422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ Unreleased +* Requires PHP 8.4 or newer (was 8.3). PHP 8.4's PDO understands PostgreSQL dollar-quoted strings, so a "?" or ":name" inside one no longer fails. CI tests PHP 8.4-8.5. * Added SQLite 3 support: Dialect::SQLite and SQLiteBindingFactory. With it, Statement::sql() reads '...' strings without backslash escapes, "...", `...` and [...] identifiers, "--" comments without a following space and non-nesting block comments, and "#" isn't a comment. * Added SQLiteNumericBindings: bUInt() and bUIntArray() stop at 9223372036854775807, SQLite's integer maximum, since SQLite reads larger numbers as floats and can't tell them apart. * MySQLNumericBindings' unsigned maximum is now the protected UINT_MAX constant, so subclasses can lower it. diff --git a/README.md b/README.md index 592bd9d..9a19ee3 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ With GLPDO2: composer require geeklab/glpdo2 ``` -Requires PHP 8.3 or newer, with the `pdo_mysql` extension for MySQL and MariaDB, `pdo_pgsql` for PostgreSQL, or `pdo_sqlite` for SQLite 3. PHP 8.4 or newer is recommended for PostgreSQL; see [PostgreSQL](#postgresql). +Requires PHP 8.4 or newer, with the `pdo_mysql` extension for MySQL and MariaDB, `pdo_pgsql` for PostgreSQL, or `pdo_sqlite` for SQLite 3. ## Quick start @@ -330,10 +330,7 @@ With it, `sql()` reads the text by PostgreSQL's rules rather than MySQL's: `#` isn't a comment in PostgreSQL, so operators like `#>` and `#>>` work. For the jsonb operators, write `??` where you mean a literal `?`: `"data" ?? ?` checks whether the bound key exists. PDO turns `??` back into `?`, and `getComputed()` shows it as `?`. -PDO scans the SQL again before sending it, and its scanner doesn't follow all of PostgreSQL's rules: - -- **PHP 8.3:** PDO doesn't recognise dollar-quoted strings, so a `?` or `:name` inside `$$...$$` fails with "mixed named and positional parameters". PHP 8.4 and newer handle them. -- **Nested comments:** PDO ends a comment at the first `*/`. Don't put `?`, `:name` or quotes in the outer comment after a nested one closes. +PDO scans the SQL again before sending it, and its scanner doesn't nest comments: it ends a comment at the first `*/`. Don't put `?`, `:name` or quotes in the outer comment after a nested one closes. The value bindings are the same as for MySQL. PostgreSQL is stricter about types, so add a cast where it can't infer one, such as `?::date`, `?::jsonb` or `?::int` in a select list. `bBoolInt()` binds `0` or `1`, which a PostgreSQL `boolean` column won't accept; use `bBool()` there. @@ -365,7 +362,7 @@ With it, `sql()` reads the text by SQLite's rules: `#` and `$` have no special meaning, and `??` is two placeholders, since SQLite has no `?` operator. -SQLite handles PDO placeholders itself, so none of the PDO limits described under [PostgreSQL](#postgresql) apply. SQLite has no boolean type: `bBool()` stores `1` or `0`. Dates from `bDate()` and `bDateTime()` are stored as text, which SQLite's date functions read. For unsigned integers above 2⁶³−1, see [Unsigned integers](#unsigned-integers). +SQLite handles PDO placeholders itself, so the PDO limit described under [PostgreSQL](#postgresql) doesn't apply. SQLite has no boolean type: `bBool()` stores `1` or `0`. Dates from `bDate()` and `bDateTime()` are stored as text, which SQLite's date functions read. For unsigned integers above 2⁶³−1, see [Unsigned integers](#unsigned-integers). ## Custom bindings @@ -406,7 +403,7 @@ $bindings = new Bindings( ## Limitations -- **MySQL, MariaDB, PostgreSQL and SQLite 3.** Other databases may work for simple queries, but aren't tested. See [PostgreSQL](#postgresql) for limits that come from PDO. +- **MySQL, MariaDB, PostgreSQL and SQLite 3.** Other databases may work for simple queries, but aren't tested. See [PostgreSQL](#postgresql) for a limit that comes from PDO. - **Invalid dates don't throw.** `bDate()` and `bDateTime()` bind `1970-01-01` (`1970-01-01 00:00:00`) for a value that isn't in the expected format, and only accept years 1900–2099. Validate dates first if that matters. - **`bLike()` doesn't escape wildcards.** A `%` or `_` in the value acts as a wildcard. - **`getComputed()` is approximate.** It shows string values in quotes without escaping them. @@ -430,7 +427,7 @@ docker run -d --rm --name glpdo2-mysql -p 3306:3306 \ MYSQLHOST=127.0.0.1 MYSQLDB=glpdo2 MYSQLUSER=root MYSQLPASS=root composer test ``` -[CI](.github/workflows/ci.yml) runs the tests on PHP 8.3–8.5 against MySQL 8.4. +[CI](.github/workflows/ci.yml) runs the tests on PHP 8.4–8.5 against MySQL 8.4, PostgreSQL 17 and SQLite. ## Changelog and license diff --git a/composer.json b/composer.json index d542649..65cc709 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require" : { - "php" : ">=8.3" + "php" : ">=8.4" }, "autoload" : { "psr-4" : { diff --git a/composer.lock b/composer.lock index 3874663..71e3415 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cd96fed5e5784f96206b15cb8955f1e5", + "content-hash": "766a664305c48ef01f1ca3a26ed37bf1", "packages": [], "packages-dev": [ { @@ -3866,7 +3866,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=8.3" + "php": ">=8.4" }, "platform-dev": {}, "plugin-api-version": "2.9.0" diff --git a/tests/GLPDO2PostgreSQLTest.php b/tests/GLPDO2PostgreSQLTest.php index 3eb7d47..8e72ebd 100644 --- a/tests/GLPDO2PostgreSQLTest.php +++ b/tests/GLPDO2PostgreSQLTest.php @@ -4,7 +4,6 @@ use GeekLab\GLPDO2\Bindings\PostgreSQL\PostgreSQLBindingFactory; use PDO; -use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\TestCase; /** @@ -111,10 +110,6 @@ public function testLiteralsAndCommentsKeepTheirQuestionMarks(): void $this->assertSame(['a' => 'Why?', 'b' => "it's?", 'c' => 1, 'd' => 7], $row); } - /** - * Before PHP 8.4, PDO's own scanner doesn't know dollar quoting and reads a "?" in one as a placeholder. - */ - #[RequiresPhp('>= 8.4.0')] public function testDollarQuotedStringKeepsItsQuestionMarks(): void { $row = $this->db->selectRow( @@ -124,7 +119,6 @@ public function testDollarQuotedStringKeepsItsQuestionMarks(): void $this->assertSame(['a' => 'ok? %%', 'b' => "it's? \$\$ ", 'c' => 7], $row); } - #[RequiresPhp('>= 8.4.0')] public function testDollarQuotedFunctionBody(): void { $this->db->queryUpdate(