[11.x] Adds support for using castAsJson with a MariaDb connection #51963
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.
Hey Laravel team, hope you're doing well 🙂.
This PR implements
compileJsonValueCast
method for MariaDbGrammar and adds some test cases forcastAsJson
using MariaDbGrammar (related to #43863).More explanation:
While running some tests on a json column using a MariaDb connection faced an issue with castAsJson method.
Currently the method tries to run
cast(? as json)
on MariaDb which at the moment doesn't support casting to json using cast function (MariaDb cast docs).It's returning this error:
Instead of using cast I've added JSON_QUERY which works as needed.
Tried to add it the same way as the related PR did for other databases.
Tested with MariaDb 10.6, 11.3, 11.4 and it works well.