Skip to content

Error when trying to use relations through edges #191

Open
@avengerweb

Description

@avengerweb

I got errors when trying to use edges. Interesting that ->toSql() produce correct query but when I try to use get any relation it fails with incorrect query.

<?php

namespace App\Models\Arango;


use LaravelFreelancerNL\Aranguent\Eloquent\Concerns\HasAranguentRelationships;
use LaravelFreelancerNL\Aranguent\Eloquent\Model;

class ComponentReview extends Model
{
    use HasAranguentRelationships;

    protected $connection = 'arangodb';

    public function component()
    {
        return $this->hasOneThrough(
            Component::class,
            Review::class,
            '_to',
            '_id',
            '_id',
            '_from',
        );
    }
}
<?php

namespace App\Models\Arango;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use LaravelFreelancerNL\Aranguent\Eloquent\Concerns\HasAranguentRelationships;
use LaravelFreelancerNL\Aranguent\Eloquent\Relations\Pivot;

class Review extends Pivot
{
    use HasAranguentRelationships;

    protected $connection = 'arangodb';
    protected $table = 'reviews';
}
<?php

namespace App\Models\Arango;


use LaravelFreelancerNL\Aranguent\Eloquent\Concerns\HasAranguentRelationships;
use LaravelFreelancerNL\Aranguent\Eloquent\Model;

class ComponentReview extends Model
{
    use HasAranguentRelationships;

    protected $connection = 'arangodb';

    public function component()
    {
        return $this->hasOneThrough(
            Component::class,
            Review::class,
            '_to',
            '_id',
            '_id',
            '_from',
        );
    }
}
   LaravelFreelancerNL\Aranguent\Exceptions\QueryException 

  400 - syntax error, unexpected "," near ', {`laravel_through_key`: `revie...' at position 1:173 (Connection: arangodb,AQL: FOR componentDoc IN components FOR reviewDoc IN `reviews` FILTER `reviewDoc`.`_from` == `componentDoc`.`_id` FILTER `reviewDoc`.`_to` == @2220_where_1 LIMIT 1 RETURN MERGE(, {`laravel_through_key`: `reviewDoc`.`_to`}) - Bindings: array (
  '2220_where_1' => 'component_reviews/33720473',
))

  at vendor/laravel-freelancer-nl/aranguent/src/Concerns/RunsQueries.php:334
    330$e,
    331▕                 );
    332▕             }
    333▕ 
  ➜ 334▕             throw new QueryException(
    335▕                 (string) $this->getName(),
    336$query,
    337$this->prepareBindings($bindings),
    338$e,

      +24 vendor frames 

  25  app/Console/Commands/Demo.php:33
      Illuminate\Database\Eloquent\Model::__get()
      +13 vendor frames 

  39  artisan:13
      Illuminate\Foundation\Application::handleCommand()

Metadata

Metadata

Labels

bugSomething isn't workingpre-v1Functionality to implement for v1.0

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions