Sync Laravel updates: test transactions, PostgreSQL schemas and strict input

Merged
BI
2d ago
+4697-2076

Laravel Updates

  • #62194, #62201 — Roll back every open transaction level after each RefreshDatabase test, so a test that leaves a transaction open no longer leaks it. Add the WithoutMigrationEvents attribute for classes or methods whose test connections should not dispatch database events, such as executed queries, while the database is migrated, and document it.
  • #62213 — Qualify dropped and renamed PostgreSQL indexes with their table's schema, so indexes on schema-qualified tables are found regardless of the search path.
  • #62215 — Flush Redis cache tags one tag at a time in both tagging modes. Each chunk of entries is removed only from the tag it was read from, so the work per script no longer grows with the number of tags being flushed.
  • #62217, #62254, facade update — Add a strict flag to str(), string(), integer(), float() and boolean(), which returns the default for values that are not valid for the type instead of coercing them. array() now converts object values with Arr::from(). Run the shared input tests against requests, fluents, validated input, component attributes, URIs and command input. Document strict retrieval and regenerate the Request facade.
  • #62179 — Add between, exactly, max and min to the array rule builder, with documentation. The parser takes the builder's rules as a list, so quoted keys may contain pipes.
  • #62178 — Compare values that are not valid UTF-8 case-sensitively in distinct:ignore_case instead of throwing.
  • #62225 — Convert collections to arrays when updating JSON paths, so MySQL and MariaDB store them as JSON like arrays.
  • #62204 — Add restoreOrCreate() and createOrRestore() to has-one-through and has-many-through relations.
  • #62210 — Accept armenian, basque, catalan, greek, hindi, serbian and yiddish as PostgreSQL full text languages.
  • #62208 — Return non-integer failed job IDs as strings from the database provider, and document the ID types each provider returns.
  • #62183 — Make schedule:interrupt fail when interruption polling is disabled, as schedule:pause does.
  • #62200 — Accept exit code and exception shorthands for faked processes that are started, matching run().
  • #62182 — Read bus job attributes through ReadsClassAttributes directly.
  • #62202 — Port the install:broadcasting tests for the React app.tsx and app.jsx entry files. Record in the foundation README that the command configures Echo in the application file only for React apps.
  • #62176 — Port ApiAuthenticationWithEloquentTest and run it in the MySQL CI jobs.
  • #62190, #62175, #62203, #62206, #62205, #62211, #62226 — Add the upstream tests for behavior Hypervel already had: GMT down --retry dates, unencodable JSON in JSON paths and object casts, transaction manager rollback after a failed commit, models with a disabled primary key, reconnecting after a connection is lost during rollback, and the Paginator::links() return type.

Additional Hypervel changes

  • Roll back every open transaction level after each DatabaseTransactions test too. It rolled back one level and, unlike Laravel, does not disconnect, so a leaked transaction stayed open until the connection returned to the pool.
  • Report a failed reconnect before a query as a QueryException, as Laravel does, instead of letting the raw PDOException escape. This covers lost-connection retries and missing connections in buffered and streaming queries. Custom drivers identify their own exceptions through the protected isDriverError method, which is documented with the other driver extension points.
  • Treat a schema named 0 as a schema. PostgreSQL index qualification, the PostgreSQL and MySQL metadata queries, the PostgreSQL, MySQL and SQLite schema filters, SQLite index creation, index drops and truncation, DatabaseTruncation and db:show labels had ignored it and acted on the default schema instead.
  • Follow the PostgreSQL connector's search_path, schema, public precedence when listing current schemas, so an explicitly empty search path lists none. Dropping all tables, views and types, and DatabaseTruncation, then do nothing instead of acting on every schema. hasView() returns false when there is no current schema instead of searching every schema.
  • Resolve a closure default once in strict string(), integer() and float(), and return the filtered number when strict integer() or float() receives a numeric Stringable instead of casting the object. The cache repository's integer() and float() and the pagination page resolver had the same Stringable cast and now use the filtered value too.
  • Report later case-insensitive duplicates in distinct:ignore_case when an earlier value is not valid UTF-8, and keep a value with a trailing newline distinct from the same value without one.
  • Read objects assigned to built-in class casts back in the cast's own form. Eloquent caches an assigned object and returns it on later reads, so a Collection assigned to AsArrayObject, a LazyCollection assigned to AsCollection, arrays assigned to a mapped collection, a plain object assigned to AsFluent or a Uuid assigned to AsBinary read back unchanged, and some broke toArray() or later writes. Casts can now decline to cache an assigned object through an optional shouldCacheObject() method, and the next read builds the value from the stored attributes. Objects already in the cast's form keep their identity and in-place edits. Generators assigned to collection and array object casts are now stored with their items instead of as {}. The enum casts' write types include the string and integer values they accept, and AsFluent accepts arrays or objects.
  • Remove the ComponentAttributeBag::array() override, which existed only for the old cast; the bag keeps the inherited array() method. Remove unreachable fallbacks for test methods that do not exist, and name the query-count test cases after their real method.
  • Create the SQLite test database file only when tests run on SQLite. MySQL, MariaDB and PostgreSQL runs left an empty file named after the server database in the working directory.

Formatting, source and type-fixture analysis, affected tests and Testbench package checks pass. The database changes were also tested on SQLite, MySQL, MariaDB and PostgreSQL, and the Redis tag flushing against a live Redis server. CI runs the full suite on every supported database.

[!NOTE]

Sync Laravel updates: test transactions, PostgreSQL schemas, and strict input

  • Adds strict-mode options to InteractsWithData string, boolean, integer, and float accessors; strict mode returns the resolved default for invalid or unrecognized values instead of coercing them
  • Makes connection reconnects query-aware via Connection.reconnectForQuery and PdoConnection.isDriverError: reconnect failures classified as driver errors become QueryExceptions tied to the failed query, while other reconnect exceptions rethrow
  • Fixes schema handling across MySQL, PostgreSQL, and SQLite grammars plus PostgresBuilder and DatabaseTruncation: empty-string and "0" schemas are treated as explicit schema values, empty search paths skip drop-all and truncation operations, and schema-qualified index drop/rename SQL qualifies the index name
  • Adds size constraints (min, max, between, exactly) to Rule::array(), restoreOrCreate/createOrRestore on HasOneOrManyThrough, a WithoutMigrationEvents attribute, and per-tag chunk flushing in Redis tag cache (AllTag/Flush.php, AnyTag/Flush.php) so each chunk is removed only from the tag it was scanned from
  • Eloquent object casts gain a shouldCacheObject hook (HasAttributes.php); many test suites are consolidated onto a shared TestsInteractsWithDataContract trait
  • Behavioral Change: strict-mode accessors return the default for booleans and other invalid values while non-strict accessors keep coercing, ComponentAttributeBag drops its array() override and inherits InteractsWithData::array(), Redis flush script payloads drop the tag-count argument, and TestCase unit-test attribute reflection failures now propagate instead of returning false

Macroscope summarized 7431126.

Summary by CodeRabbit

  • New Features

    • Added strict input conversion options for strings, booleans, integers, and floats, with support for custom defaults.
    • Added size constraints to fluent array validation rules and restore-or-create options for through relationships.
    • Added an option to suppress migration events during test database refreshes.
    • Expanded PostgreSQL full-text language support.
  • Bug Fixes

    • Improved Redis tag flushing so shared entries are handled separately for each tag.
    • Improved database reconnection and query error handling, schema handling, and object casting.
    • Corrected numeric conversion and pagination for numeric string-like values.
    • Prevented scheduling interrupts when interruption is disabled.
  • Documentation

    • Expanded guidance for strict input conversion, array validation, migration events, database drivers, and broadcasting setup.