Skip to content

[5.x] Prepare value & operator before passing to Eloquent Query Builder #11805

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

Merged
merged 1 commit into from
May 19, 2025

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented May 19, 2025

This pull request partially fixes statamic/eloquent-driver#424, by ensuring that the value and operator are handled properly before being passed to the Eloquent Query Builder.

The Problem

Currently, when you're storing entries in the database, attempting to query a column with a value matching an operator will result in an error:

Entry::query()->where('site', 'is')->get();
InvalidArgumentException 
Illegal operator and value combination. 
at vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:945

The query works as expected when querying the model directly, or when using the Stache query builder. is simply becomes the value when a third argument hasn't been provided.

This fix goes alongside statamic/eloquent-driver#425 which adjusts how the EloquentQueryBuilder::where() method is called.

@duncanmcclean duncanmcclean changed the title Prepare value & operator before passing to Eloquent Query Builder [5.x] Prepare value & operator before passing to Eloquent Query Builder May 19, 2025
@duncanmcclean duncanmcclean marked this pull request as ready for review May 19, 2025 15:39
@jasonvarga jasonvarga merged commit 4a797bb into 5.x May 19, 2025
26 of 27 checks passed
@jasonvarga jasonvarga deleted the where-condition-arguments branch May 19, 2025 19:34
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.

InvalidArgumentException thrown when site handle matches condition operator
2 participants