staudenmeir / laravel-merged-relations

Merged Laravel Eloquent relationships
MIT License
178 stars 11 forks source link

createMergeViewWithoutDuplicates fails when a json column exists #13

Closed gerardnll closed 1 year ago

gerardnll commented 1 year ago

DB: PostgreSQL 13.6 Laravel: 9.38.0

When trying to create a merged view without duplicates on a table with json columns an error is thrown. If duplicates are allowed it works fine.

Schema::createMergeViewWithoutDuplicates(
    'business_all_gatherings',
    [(new \App\Models\Business())->productGatherings(), (new \App\Models\Business())->activityGatherings()]
);

Output:

SQLSTATE[42883]: Undefined function: 7 ERROR:  could not identify an equality operator for type json...
staudenmeir commented 1 year ago

Hi @gerardnll, I found this answer on Stack Overflow: https://stackoverflow.com/a/43719269/4848587

I tested converting the column from json to jsonb and the query worked. Is that an option for you?

gerardnll commented 1 year ago

Thanks Jason. Shouldn’t be a problem for me jsonb, I’ll try it.