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

whereColumn feature missing #1651

Open
joseraul opened this issue Nov 25, 2018 · 5 comments
Open

whereColumn feature missing #1651

joseraul opened this issue Nov 25, 2018 · 5 comments

Comments

@joseraul
Copy link

Hi!

I think is not possible to use the whereColumn, right?
Is there any special reason because it is not implemented?
I will be happy to help :)

@jazz7381
Copy link

any update about this?

@joseraul
Copy link
Author

Not from my side.
I'm afraid I'm not using Mongo right now, so I don't have plans on working on this.

@peterlembke
Copy link

peterlembke commented Feb 7, 2024

Adding a use case for whereColumn.
We recalculate items every day that is within the period (date_first_in_period, date_last_in_period).

        $builder = BenchmarkCacheModel::query()
            ->where('filter_alias', $filterAlias)
            ->whereColumn('date_last_in_period', '>=', 'updated_at');

        $keyItemArray = $builder->get()->toArray();

Unfortunately this does not work since whereColumn is not implemented: "BadMethodCallException: This method is not supported by MongoDB"

MongoDb itself can do this with aggregations. I will have to solve this for now with a raw call.

        $aggregationArray = [
            [
                '$match' => [
                    'filter_alias' => $filterAlias,
                    '$expr' => [
                        '$gte' => [
                            '$date_last_in_period',
                            '$updated_at'
                        ]
                    ]
                ]
            ]
        ];

@bisht2050
Copy link
Contributor

Tracked with PHPORM-138.

@GromNaN
Copy link
Member

GromNaN commented Apr 4, 2024

This would be possible only if we convert Query Builder to Aggregation Builder. There is some limitation on the query operators that can be used, that's why we didn't implement it in #2738.

The solution would be to write an aggregation like mentioned by @peterlembke in the previous comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants