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

[11.x] Adds support for using castAsJson with a MariaDb connection #51963

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

haniha
Copy link
Contributor

@haniha haniha commented Jun 30, 2024

Hey Laravel team, hope you're doing well 🙂.

This PR implements compileJsonValueCast method for MariaDbGrammar and adds some test cases for castAsJson 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:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;

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.

@taylorotwell taylorotwell merged commit 0de031f into laravel:11.x Jul 1, 2024
28 checks passed
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