Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Nested relationship unknown column , Laravel Prefix Table problem #2024

Closed
kouloughli-hemza opened this issue Mar 17, 2019 · 2 comments

Comments

@kouloughli-hemza
Copy link

kouloughli-hemza commented Mar 17, 2019

Prefix problem not yet fixed in relationship

i created custom dropdown to filter using aganecy name;
in global search it was working but when i added custom filter i get the following error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'table.name' in 'where clause'
in matter of sql it expected error because Yajra not adding PREFIX to this table,
not sure why , only in where clause the table not getting prefixed

$data =  $model->with([
                'Table',
                'Table1.relation_1',
                'Table1.relation_2',
                'Table1.relation_3'
            ])->orderBy('table0.id','desc')->select();
            return $data;

This is the generated Sql query :

select * from `prefix_table0` left join `prefix_table1` on `prefix_table0`.`id_application` = `prefix_table1`.`id` left join `prefix_table2` on `prefix_table1`.`created_by_agency` = `prefix_tbale2`.`id` where `prefix_table1`.`deleted_at` is null and LOWER(table2.name) REGEXP 88 order by `dz_table0`.`id` desc

as you can see the table2 is not getting prefixed ,
this is commun problem in yajra
im not sure if there is a solution to this

System details

  • Operating System: ubuntu
  • PHP Version : 7.2
  • Laravel Version : Laravel Framework 5.6.11
@kouloughli-hemza kouloughli-hemza changed the title Filter Nested relationship unknown column Filter Nested relationship unknown column , Laravel Prefix Table problem Mar 18, 2019
@yajra
Copy link
Owner

yajra commented Apr 10, 2019

It seems like you are using a self join relationship and it is currently not supported by the package. You need to use join statements for this to work on self joins.

@yajra
Copy link
Owner

yajra commented Apr 24, 2019

Fixed via #2051.

@yajra yajra closed this as completed Apr 24, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants