Skip to content

[9.x] Add is_string check to QueriesRelationships@requalifyWhereTables#42341

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
rodrigopedra:9.x
May 10, 2022
Merged

[9.x] Add is_string check to QueriesRelationships@requalifyWhereTables#42341
taylorotwell merged 2 commits into
laravel:9.xfrom
rodrigopedra:9.x

Conversation

@rodrigopedra

@rodrigopedra rodrigopedra commented May 10, 2022

Copy link
Copy Markdown
Contributor

Closes #42338

This PR:

  • Adds a is_string() check before a str_starts_with() on QueriesRelationships@requalifyWhereTables
  • Adds a test case which would fail without this patch

Notes:

  • The QueriesRelationships@requalifyWhereTables was added by PR [9.x] Add wherehas soft deleting scopes #42100 which tried to fix table prefixing issues when using self-referencing relations
  • There is no need to check non-string values, as the idea is to prefix values used in whereColumn, or other that could reference related tables
  • The added test case used a new stdClass as enums are not available in PHP 8. As it tests the generated SQL statement, the stdClass instance never acutually gets bound to PDO.

EDIT: added information about added test case. Please read 3rd note about it.

@rodrigopedra

rodrigopedra commented May 10, 2022

Copy link
Copy Markdown
Contributor Author

ping @driesvints , @taylorotwell

P.S.: I didn't add any tests as this is more like a patch bug-fix. I can try adding any later.

EDIT: added test case

@taylorotwell taylorotwell merged commit 25127ba into laravel:9.x May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[9.12.0] Enum bug within relationship

2 participants