Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Search for similar results #31042

Merged
merged 3 commits into from
Jan 13, 2020
Merged

[6.x] Search for similar results #31042

merged 3 commits into from
Jan 13, 2020

Conversation

browner12
Copy link
Contributor

This is a resubmission of #30886 with fixed tests.

When using the assertDatabaseHas() assertion, the failure method returns the first couple results out of the database. This is not incredibly useful since those results are not guaranteed to contain the row of our expected data.

This PR allow the failure message to make an educated guess on the DB row we are most likely trying to compare to. It gives priority to the first key/value pair in our expected data, and performs a query based solely on that 1 piece of information. If it finds rows matching this data, it will return them. If it doesn't find any results from its educated guess, it will fallback to the current method of returning results.

first we take the first key/value pair of the expected data, and look to see if that exists in the database. If that finds results, we'll send those back to the developer since they're easier to compare.

if we don't find any of those results, we'll fallback to the old way of just returning results from the table.
allow the builder to receive a `where` clause containing the first element of the data.
@taylorotwell taylorotwell merged commit 7fcf5a6 into laravel:6.x Jan 13, 2020
@browner12 browner12 deleted the guess-matches branch January 29, 2020 21:20
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