I
I
Ivan Ivanov2021-04-25 15:04:25
Laravel
Ivan Ivanov, 2021-04-25 15:04:25

Why does the column name become lowercase when querying (nicolaslopezj/searchable)?

I use laravel and the nicolaslopezj/searchable package, after reading the documentation I decided to get down to business, set up the model:

protected $searchable = [
            'columns' => [
                'products.clientArticle' => 10,
            ],
        ];

Applied the search: $products = Product::search($query)->get();
And then an error pops up:
SQLSTATE[42703]: Undefined column: 7 ERROR:  column products.clientarticle

Why is the field name now in lower case? Here is the request:
select * from (select "products".*, max((case when LOWER(products.clientArticle) ILIKE ? then 150 else 0
end) + (case when LOWER(products.clientArticle) ILIKE ? then 50 else 0 end) + (case when LOWER(products.clientArticle)
ILIKE ? then 10 else 0 end)) as relevance from "products" where "products"."deletedAt" is null group by "products"."id"
having (case when LOWER(products.clientArticle) ILIKE ? then 150 else 0 end) + (case when LOWER(products.clientArticle)
ILIKE ? then 50 else 0 end) + (case when LOWER(products.clientArticle) ILIKE ? then 10 else 0 end) >= 10.00 order by
"relevance" desc) as products

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question