[9.x] InteractsWithDatabase::castAsJson($value)
incorrectly handles SQLite Database
#44196
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.
Closes #43863
This PR implements a
compileJsonCast()
method on the base query grammar instance to allow the transformation of a raw JSON string into a "cast" operation compatible with its database.This new method is then called in the
castAsJson
test utility method to generate a proper raw query expression into its compatible operation. Previously,castAsJson
would only work with MySQL, as other databases do not have the same operation and will either fail, or (in SQLite's case) simply query for the whole operation's text.I've tested these cast functions in where clauses using SQL Fiddle. SQLite and Postgres do not appear to require cast functions to be called on the raw JSON to properly query.
@browner12 Let me know your thoughts on this implementation 👍