You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Database Driver & Version: MongoDB 6.0.2 Community
Description:
It seems it's trying to get count from mysql instead of mongodb.
Steps to reproduce
I have User and Post class as below:
use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\HybridRelations;
class User extends Model
{
use HybridRelations;
public function posts()
{
return $this->hasMany('App\Models\Post');
}
}
use Jenssegers\Mongodb\Eloquent\Model;
class Post extends Model
{
protected $collection = 'posts';
protected $connection = 'mongodb';
public function user(){
return $this->belongsTo('App\Models\User');
}
}
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"testdb"."posts" where "user_id" exists ?) as `posts_count` f' at line 1 (SQL: select `users`.*, (select "user_id" from "testdb"."posts" where "user_id" exists 1) as `posts_count` from `users` where `users`.`id` = 462372 limit 1)
The text was updated successfully, but these errors were encountered:
@GromNaN I have been working on this one lately. I noticed there is no way to add an aggregation pipeline to the query instance.
I created this aggregation that can solve the problem.
I can run this using MongoDB/Collection class, but it's not what we want in this case. There is a problem in the select methods that leads us to an error.
That need the aggregation builder that we are adding in #2654. The Query builder will build an aggregation pipeline underneath so we can add $lookup + $addField stages.
Description:
It seems it's trying to get count from mysql instead of mongodb.
Steps to reproduce
I have User and Post class as below:
now when I try to get count with this :
it's work
but if I try this :
it fails and gives this error:
The text was updated successfully, but these errors were encountered: