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

[Bug + fix] Last MongoDB : toMql() instead >toSql() in CrudPanel/Traits/Query.php #5460

Open
elgrosboub opened this issue Mar 2, 2024 · 1 comment
Assignees
Labels

Comments

@elgrosboub
Copy link

Bug report

Installed a fresh Laravel 10+ Last Backpack V6 + Last MongoDB Package (https://www.mongodb.com/compatibility/mongodb-laravel-integration)

What I expected to happen

Work.

What happened

When I change connection :

use MongoDB\Laravel\Eloquent\Model;
protected $connection = 'mongodb';

I have error :

This method is not supported by MongoDB. Try "toMql()" instead. {"userId":1,"exception":"[object] (BadMethodCallException(code: 0): This method is not supported by MongoDB. Try "toMql()" instead. at //vendor/mongodb/laravel-mongodb/src/Query/Builder.php:1442)
[stacktrace] #0 /
/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/Query.php(220): MongoDB\Laravel\Query\Builder->toSql()

What I've already tried to fix it

When i change by ->toMql() instead >toSql() that work !

public function getFilteredQueryCount()
{
    // check if the filtered query is different from total query, in case they are the same, skip the count
    $filteredQuery = $this->query->toBase()->cloneWithout(['orders', 'limit', 'offset']);

    return $filteredQuery->toMql() !== $this->totalQuery->toMql() ? $this->getQueryCount() : null;
}

Is it a bug in the latest version of Backpack?

Yes

@jcastroa87
Copy link
Member

Hello @elgrosboub, thanks for bringing us this report about the issue; we will check about this change on the last version of MongoDB package and fix it.

I will ask the wise @pxpm to check this compatibility.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

3 participants