lunarphp / lunar

An open-source package that brings the power of modern headless e-commerce functionality to Laravel.
https://lunarphp.io
MIT License
2.4k stars 299 forks source link

Customers Create page return error when using Postgres. #1823

Open samimhamza opened 1 week ago

samimhamza commented 1 week ago

Expected Behaviour:

On click to new Customer, it should return a form to create a customer, but it returns error.

Actual Behaviour:

It return this error : SQLSTATE[42883]: Undefined function: 7 ERROR: could not identify an equality operator for type json LINE 1: select distinct "lunar_customer_groups". from "lunar_custom... ^ (Connection: pgsql, SQL: select distinct "lunar_customer_groups". from "lunar_customer_groups" left join "lunar_customer_customer_group" on "lunar_customer_groups"."id" = "lunar_customer_customer_group"."customer_group_id" order by "lunar_customer_groups"."name" asc)

it works fine when using MySQL as database, but on Postgres it returns this error.

Steps To Reproduce:

Just change the database to Postgres and try to create a customer.

JustGAST commented 1 week ago

Getting the same error when trying to attach product to collection. Maybe it's important to note that I use two languages.

SQL:

select distinct "lunar_collections".*
from "lunar_collections"
         left join "lunar_collection_product" on "lunar_collections"."id" = "lunar_collection_product"."collection_id"
where "lunar_collections"."id" = 1
limit 1;

Error: [42883] ERROR: could not identify an equality operator for type json.

Postgres version: 16.3 Lunar version: 1.0.0-alpha.27 Laravel version: 11.11.1 PHP version: 8.3.7.

glennjacobs commented 1 week ago

I think this is a known issue with the search side of things, but I'd have to check.

JustGAST commented 1 week ago

I think this is a known issue with the search side of things, but I'd have to check.

I think so too. I even wasn't able to search for collections with SCOUT_DRIVER=database. But when I've switched to driver collection search results appeared. But not saving.

JustGAST commented 1 week ago

Same error appears with SCOUT_DRIVER=meilisearch.

JustGAST commented 1 week ago

Found solution here: modify field type from json to jsonb.

I've modified lunar_collections.attribute_data to jsonb and problem has gone.

alecritson commented 2 days ago

@glennjacobs Do you think this something we need to consider in the migrations or should we have a notice somewhere in the docs?