Skip to content

fix(database): check explicit relation attributes after singularizing property names#2090

Merged
brendt merged 1 commit intotempestphp:3.xfrom
laylatichy:fix-naming-singularizaton
Mar 31, 2026
Merged

fix(database): check explicit relation attributes after singularizing property names#2090
brendt merged 1 commit intotempestphp:3.xfrom
laylatichy:fix-naming-singularizaton

Conversation

@laylatichy
Copy link
Copy Markdown
Contributor

second half fix for #2086

check if singularized property exists

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 29, 2026

Benchmark Results

Comparison of fix-naming-singularizaton against 3.x (ba925951610e8987599a77663e7d8e779b8af89d).

Open to see the benchmark results

No benchmark changes above ±5%.

Generated by phpbench against commit 207fb04

@laylatichy laylatichy force-pushed the fix-naming-singularizaton branch from dd5f596 to 7ca5292 Compare March 29, 2026 15:32
@laylatichy laylatichy marked this pull request as ready for review March 29, 2026 15:51
@laylatichy laylatichy force-pushed the fix-naming-singularizaton branch from 7ca5292 to 7d45b78 Compare March 30, 2026 21:40
…g property names

getBelongsTo(), getHasOne(), and getHasOneThrough() singularized the
property name before checking for explicit relation attributes. This
broke any property whose last word is a Latin plural (metadata, data,
criteria, media) because singularization produced a non-existent name
(e.g. product_metadata → product_metadatum) and the method returned
null without ever checking the original property.

Now each method checks if the original property has an explicit
attribute before recursing with the singularized name.
@laylatichy laylatichy force-pushed the fix-naming-singularizaton branch from 7d45b78 to 207fb04 Compare March 30, 2026 22:32
@brendt brendt merged commit ccd398f into tempestphp:3.x Mar 31, 2026
76 checks passed
@brendt
Copy link
Copy Markdown
Member

brendt commented Mar 31, 2026

Perfect :)

regnerisch pushed a commit to regnerisch/tempest-framework that referenced this pull request Mar 31, 2026
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.

2 participants