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

browner12 commented Jan 6, 2020

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.

browner12 added 3 commits Dec 19, 2019
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
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@browner12 browner12 deleted the browner12:guess-matches branch Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.