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

[9.x] InteractsWithDatabase::castAsJson($value) incorrectly handles SQLite Database #44196

Merged
merged 8 commits into from
Sep 19, 2022
Merged

[9.x] InteractsWithDatabase::castAsJson($value) incorrectly handles SQLite Database #44196

merged 8 commits into from
Sep 19, 2022

Conversation

stevebauman
Copy link
Contributor

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 👍

Copy link
Contributor

@browner12 browner12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on all the Nowdocs in the test.

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.

[9.x] InteractsWithDatabase::castAsJson($value) incorrectly handles SQLite Database
3 participants