sgpatil / oriquent

Orientdb Eloquent driver for Laravel 5
MIT License
47 stars 15 forks source link

Can't create relation #7

Closed Dalamar closed 8 years ago

Dalamar commented 8 years ago

I get the error in OrientDB server console (see in the bottom) when trying to create relation between country and city. Relation is not created as the result.

Country:

<?php

namespace App;

use Sgpatil\Orientdb\Eloquent\Model;

class Country extends Model
{
    protected $guarded = [];

    public function cities()
    {
        return $this->hasMany('App\City');
    }

    public function has_city()
    {
        return $this->hasOne('App\City', 'Has');
    }
}

City:

<?php

namespace App;

use Sgpatil\Orientdb\Eloquent\Model;

class City extends Model
{
    protected $guarded = [];

    public function country()
    {
        return $this->belongsTo('App\Country');
    }
}

Seeding DB and creating relation in Tinker:

☁  laravel  php artisan tinker
Psy Shell v0.5.2 (PHP 5.5.20 — cli) by Justin Hileman
>>> $country = App\Country::create(['id' => 100, 'name' => 'Cyprus']);
=> App\Country {#776
     id: "#13:0",
     name: "Cyprus",
     updated_at: "2015-11-01 10:40:07",
     created_at: "2015-11-01 10:40:07",
   }
>>> $city = new App\City(['id' => 10, 'name' => 'Limassol']);
=> App\City {#789
     id: 10,
     name: "Limassol",
   }
>>> $relation = $country->has_city()->save($city);
=> Sgpatil\Orientdb\Eloquent\Edges\EdgeOut {#797}

OrientDB server console error:

2015-11-01 12:40:16:994 SEVER Internal server error:
com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.test [ONetworkProtocolHttpDb]
2015-11-01 12:40:17:064 SEVER Internal server error:
java.lang.IllegalArgumentException: source record is not a vertex [ONetworkProtocolHttpDb]
Dalamar commented 8 years ago

upd: This issue is reproducible in orientdb-community-2.2-alpha version. In orientdb-community-2.0 it works fine. Btw in orientdb-community-2.0 batch name for migration versioning works fine as well. The problem is that orientdb-community-2.0 is outdated as it was released in January 2015. So, @sgpatil maybe it's better idea to test it against current stable version? For instance current version is 2.1.3.

sgpatil commented 8 years ago

Hi @Dalamar , you are right. batch keyword is giving problem in version above 2.0. So I have decided to rename it to version. Hope this will solve the problem.

Dalamar commented 8 years ago

Hi @sgpatil, thanks for the update! Confirm, now migration versioning works well. However, the problem with relation creating as I described above still remains.

sgpatil commented 8 years ago

Hi @Dalamar, The problem is related with vertex. As orientdb supports document and graph, I am trying to find an easy way to switch between both. will update it soon

sgpatil commented 8 years ago

branch has been updated. please try with new code.