Releases: rkrx/php-mysql-query-builder
Releases · rkrx/php-mysql-query-builder
Refined Query Builder Generics for RunnableSelect
This commit refines PHPDoc generics in the RunnableSelect interface to better align callback return types with the resulting collections and generators. Affected methods: fetchIndexedRows, fetchRows, fetchRowsLazy, and fetchRow.
Support for temporary tables and code modernization.
- Temporary Tables: A new
temporary()method allows materializing aSELECTstatement immediately into a temporary database table, including schema definitions and engine options. - Lifecycle Management: The new
RunnableTemporaryTableinterface and its implementation provide methods to retrieve the table name and explicitly delete it usingrelease(). - Integration: The
TableNameBuilderwas updated to allow temporary table instances to be used directly withinFROMorJOINclauses. - Refactoring: Several
switchstatements were replaced with modern PHPmatchexpressions, and code formatting was unified across the project with improved spacing and standardized lambda syntax. - Error Handling: The database exception interpretation was modernized, and
QueryStatementnow implementsStringableto facilitate easier debugging.
Documentation Expansion and Input Validation
This update expands the project documentation regarding insert operations and introduces stricter input validation for query building methods.
Documentation
- Renamed
INSTRUCTIONS.mdtoAGENTS.md. - Added comprehensive examples and usage guides for
INSERTandUPSERTstatements, including details on table aliases, mass inserts (INSERT INTO ... SELECT), field masking, andON DUPLICATE KEY UPDATEstrategies.
Source Code Changes
- Limit and Offset Validation: Added strict validation to ensure values passed to
LIMITandOFFSETclauses are numeric. The builder now explicitly casts these values and throws anInvalidValueExceptionif non-numeric values are provided. - Table Data Validation: Updated
TableNameBuilderto validate that data used for table generation is either scalar or iterable, ensuring unsupported types raise anInvalidArgumentException. - Type Hinting: Improved the PHPDoc return type annotation for
RunnableSelect::fetchKeyValuetoarray<array-key, mixed>to support better static analysis.
PHP 8.0 related improvements; added JsonTable-Class
0.5.0 Add JsonTable and related test
AliasReplacer: Also handle Table additions like `prefix#table FOR SYSTEM_TIME ALL`
Enhanced typing
0.4.4 Refactor type annotations for improved PHPStan compatibility
Enhanced typing
0.4.3.2 Enhanced typing
Enhanced typing
0.4.3.1 Updated typing
Enhanced typing
0.4.3 Enhanced typing
Fixed issues reported by phpstan
0.4.2 Fixed issues reported by phpstan