feat: Port `whereJsonContainsKey` methods + `CompilesJsonPaths` from Laravel by binaryfire · Pull Request #7699 · hyperf/hyperf
added 10 commits
January 18, 2026 14:55Add whereJsonContainsKey, orWhereJsonContainsKey, whereJsonDoesntContainKey, and orWhereJsonDoesntContainKey methods to Query Builder.
Add compileJsonContainsKey method to base Grammar (throws by default) and implement for MySQL, PostgreSQL, and SQLite drivers.
Add tests for MySQL, PostgreSQL, and SQLite grammars covering whereJsonContainsKey, orWhereJsonContainsKey, whereJsonDoesntContainKey, and orWhereJsonDoesntContainKey methods.
- Rename ContainerStub to SwooleExtContainerStub (tests deprecated extension) - Rename DatabasePostgresBuilderTest to DatabasePostgresSwooleExtQueryBuilderTest - Create new ContainerStub for PDO driver - Create new DatabasePostgresQueryBuilderTest for PDO driver tests - Rename DatabaseSQLiteQueryGrammarTest to DatabaseSQLiteQueryBuilderTest The old names were inconsistent with the database package naming. Schema Builder tests use "BuilderTest", Query Builder tests use "QueryBuilderTest".
Rename query builder test classes to match SchemaBuilderTest naming: - DatabasePostgresQueryBuilderTest → QueryBuilderTest - DatabasePostgresSwooleExtQueryBuilderTest → SwooleExtQueryBuilderTest - DatabaseSQLiteQueryBuilderTest → QueryBuilderTest
binaryfire
changed the title
feat: Port
feat: Port whereJsonContainsKey methods from Laravel + fix PostgreSQL / SQLite test structurewhereJsonContainsKey methods from Laravel + fix wrapJsonPath
…dex support - Update Grammar::wrapJsonPath() + add wrapJsonPathSegment() to properly parse array indices (e.g., `foo[0]` → `"foo"[0]` instead of `"foo[0]"`) - Update PostgresGrammar::wrapJsonPathAttributes() + add parseJsonPathArrayKeys() - Fix incorrect test expectation for array indices to match Laravel behavior - Add array index tests for MySQL, PostgreSQL, and SQLite Reference: laravel/framework DatabaseQueryBuilderTest.php:6682-6683
binaryfire
changed the title
feat: Port
feat: Port whereJsonContainsKey methods from Laravel + fix wrapJsonPathwhereJsonContainsKey methods + CompilesJsonPaths from Laravel
…pilation Port Laravel's CompilesJsonPaths trait pattern to eliminate code duplication between Query Grammar and Schema Grammar classes. - Create CompilesJsonPaths trait with wrapJsonFieldAndPath, wrapJsonPath, and wrapJsonPathSegment methods - Use trait in Query Grammar (removes 51 lines of duplicated code) - Use trait in Schema Grammar base class - Remove duplicated methods from SQLite Schema Grammar (46 lines) - Remove unused Str import from SQLite Schema Grammar
…ssing tests - Fix compileJsonUpdateColumn to use wrapJsonPathAttributes for proper array index parsing in UPDATE queries - Cast $i to int in compileJsonContainsKey for strict_types compatibility - Add testMySqlUpdateWrappingJsonPathArrayIndex test - Add testJsonPathEscaping test - Add testPostgresUpdateWrappingJsonPathArrayIndex test - Add testSQLiteUpdateWrappingJsonPathArrayIndex test - Add PostgreSQL negative array index tests ([-1]) for whereJsonContainsKey and whereJsonDoesntContainKey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters