Fix hasTable() returning stale results when mixing API and execute() #982
+44
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
hasTable()returning stale results when mixing API calls with raw SQL viaexecute()$this->table()->create()) and dropped viaexecute(),hasTable()would incorrectly returntruedue to an internal cacheProblem
The
$createdTablescache was being checked first inhasTable(), returningtruewithout querying the database.Solution
Only use the cache in dry-run mode. In normal execution, always query the database for accurate results.
Note:
There was also a 2nd issue in code.
The issue was a latent bug in SqlserverAdapter - it was passing the full nschema.ntable to dialect->hasTable() instead of just ntable. The cache was hiding this bug before.