Open es-ka opened 3 years ago
Hello @es-ka
This issue is related to this line https://github.com/staudenmeir/laravel-adjacency-list/blob/3e7f2c2f44524127ca91a727c73307ea1714d42a/src/Eloquent/Builder.php#L84
both staudenmeir/laravel-adjacency-list
and belamov/postges-range
are extending default postgres grammar, but one of it is probably overwritten by another
you can try to add your own grammar to your project that combines both grammars of this packages and register it yourself, i really don't know what else is possible to do here
Thanks @belamov, your answer was really fast.
you can try to add your own grammar to your project that combines both grammars of this packages and register it yourself, i really don't know what else is possible to do here
OK. I've never done that before. Is there any good tutorial how to do this? Does @staudenmeir have any additional hints?
BTW, I didn't intend to use both packages on the same model. It would be great to install both packages at the same time without trouble or need for expert knowledge (extending the grammar).
Thanks a lot!
@es-ka unfortunately i cant come up with solution right now, maybe @staudenmeir could help me out. deferring is not gonna work, because we must register our grammar in both cases even if you don't use packages functionality on the same model
both packages extends postgresgramar in its own way, so conflict is inevitable
you can read read about service providers here
@es-ka btw your error SQLSTATE[42P01]: Undefined table: 7 ERROR: Relation »laravel_cte« doesn't exist
seems to not be related to any of packages, check your migrations and ensure that all needed tables are created and see if issue is persists
seems like packages shouldn't interfere with each other because override happens on different levels and staudenmeir/laravel-adjacency-list
should override any already existing grammar when its trait is used
btw your error
SQLSTATE[42P01]: Undefined table: 7 ERROR: Relation »laravel_cte« doesn't exist
seems to not be related to any of packages, check your migrations and ensure that all needed tables are created and see if issue is persists
It might be related somehow. All queries using staudenmeir/laravel-adjacency-list
did work just fine before installing postgres-range
. I checked the Migration (adding a single column for date range to a single model): it was successful. No queries using any range type columns were added yet.
After removing the package postgres-range
, the error immediately disappears.
So I think this issue should not be closed as the issue isn't resolved yet.
BTW staudenmeir/laravel-cte
is a composer dependency of staudenmeir/laravel-adjacency-list
, it might be a bug there.
I'll look into it.
@staudenmeir The query in question, just for reference:
// Only columns associated with this item's taxon or its descendants
$colmap = ColumnMapping::where('item_type_fk', $item->item_type_fk)
->where(function (Builder $query) use ($taxon_id) {
return $query->whereNull('taxon_fk')
->orWhereHas('taxon.descendants', function (Builder $query) use ($taxon_id) {
$query->where('taxon_id', $taxon_id);
});
})
->orderBy('column_order')->get();
The model ColumnMapping
has a relation to the Model Taxon
:
public function taxon()
{
return $this->belongsTo('App\Taxon', 'taxon_fk', 'taxon_id');
}
and vice versa:
public function column_mapping()
{
return $this->hasMany('App\ColumnMapping', 'column_fk', 'column_id');
}
It has been working well for months until installing the postgres-range
package.
Describe the bug After installation via composer, it seems to break the package laravel-adjacency-list. Even without using the postgres-range package, I get an
Illuminate\Database\QueryException
:SQLSTATE[42P01]: Undefined table: 7 ERROR: Relation »laravel_cte« doesn't exist
To Reproduce Steps to reproduce the behavior:
staudenmeir/laravel-adjacency-list
via composerstaudenmeir/laravel-adjacency-list
on model 'X'belamov/postges-range
Expected behavior Installation of postgres-range should not affect another package
Additional context I guess it might be related to hints on postgres grammar, but unfortunately I'm not familiar with CTE and don't know how to deal with it.
Any help and advice is very appreciated. Thanks in advance.