Power-Components/livewire-powergrid

Global Search not respecting the connection property on model

Closed this issue · 0 comments

Have you searched through other issues to see if your problem is already reported or has been fixed?

Yes, I did not find it.

Did you read the documentation?

Yes, I did not find it.

Have you tried to publish the views?

Yes - I didn't work.

Is there an error in the console?

No

PHP Version

8.2

PowerGrid

6.1.6

Laravel

11.34.2

Livewire

3.5.16

Alpine JS

3.12.0

Theme

Bootstrap

Describe the bug.

When model has connection property defined the global search is not working for the model columns.

Laravel debugger bar show following function is not respecting the connection property of model.

vendor/power-components/livewire-powergrid/src/DataSource/Builder.php:259

Function:

private function getColumnList(string $modelTable): array
    {
        try {
            return PowerGridTableCache::getOrCreate(
                $modelTable,
                fn () => collect(Schema::getColumns($modelTable))
                    ->pluck('type', 'name')
                    ->toArray()
            );
        } catch (\Throwable $throwable) {
            logger()->warning('PowerGrid [getColumnList] warning: ', [
                'table'     => $modelTable,
                'throwable' => $throwable->getTrace(),
            ]);

            return Schema::getColumnListing($modelTable);
        }
    }

query:

select column_name as `name`, data_type as `type_name`, column_type as `type`, collation_name as `collation`, is_nullable as `nullable`, column_default as `default`, column_comment as `comment`, generation_expression as `expression`, extra as `extra` from information_schema.columns where table_schema = 'tgwa' and table_name = 'claims' order by ordinal_position asc

The query is going to wrong table schema but not to the schema defined in model connection property. which is claim_db

To Reproduce...

Put a different connection property on a model and make is searchable in columns and then search with the global search box.

Extra information

No response