laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

Column not found: 1054 Unknown column 'categories.deleted_at' in 'where clause'

Open michaelqxd opened this issue 9 years ago • 11 comments

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'categories.deleted_at' in 'where clause' (SQL: select (select count(1) from categories as c1, categories c2 where categories.deleted_at is null and c1.id < c2.id and (c1._lft=c2._lft or c1._rgt=c2._rgt or c1._lft=c2._rgt or c1._rgt=c2._lft)) as duplicates limit 1) D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Connection.php:750 D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Connection.php:706 D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Connection.php:349 D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:1614 D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:1600 D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:1583 D:\wamp64\www\app\app\src\Model\nestedset\QueryBuilder.php:611 D:\wamp64\www\app\app\src\Model\nestedset\QueryBuilder.php:742 D:\wamp64\www\app\app\src\Model\nestedset\QueryBuilder.php:754 D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:3489 D:\wamp64\www\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:3503 D:\wamp64\www\app\app\test\src\nestedset\NodeTest.php:122 D:\wamp64\www\app\app\test\src\nestedset\NodeTest.php:122

michaelqxd avatar Jul 19 '16 02:07 michaelqxd

the issue is : assign an alias to the the orignal table name "categories " , but eloquent use it in the deleted_at check,

michaelqxd avatar Jul 19 '16 04:07 michaelqxd

This looks like an issue with the way the SoftDeletes global query scope gets the fully qualified table name. See https://github.com/laravel/framework/issues/13567

jimrobinson-croud avatar Jul 21 '16 13:07 jimrobinson-croud

@jimrobinson-croud do you konw how to fix it?

michaelqxd avatar Jul 22 '16 02:07 michaelqxd

@michaelqxd Not at the moment unfortunately. I'll comment with a solution if/when I find one.

jimrobinson-croud avatar Jul 22 '16 07:07 jimrobinson-croud

@lazychaser I supposed it used to work? Otherwise it would not advertise as support softdelete. Do you have an idea up to which Laravel version that it's working?

justinmoh avatar Jul 26 '16 17:07 justinmoh

Just for your information, the issue is with package Illuminate/Database as @jimrobinson-croud mentioned.

At the time of writing, the latest stable version available on Packagist is v5.2.37. The release before it is v5.2.32.

I used phpunit test case came with this package, and it failed with Illuminate/Database v5.2.37, but passed with v5.2.32.

At the moment I'll just limit "laravel/framework": "5.2.32", in my project's composer.json. @michaelqxd

P/S: FWIW, phpunit.php does not work out of the box either....

justinmoh avatar Jul 26 '16 18:07 justinmoh

@justinmoh sorry, I'm not able to do any work on the package right now

lazychaser avatar Jul 27 '16 05:07 lazychaser

@justinmoh Thanks, i will try v5.2.32

michaelqxd avatar Jul 27 '16 05:07 michaelqxd

This should be fixed as of v4.1.4

oddvalue avatar Aug 04 '16 09:08 oddvalue

Still not fixed in 5.4.27 :(

techouse avatar Jul 17 '17 14:07 techouse

Actually I just added a new column deleted_at to resolve this issue.

8deline avatar Feb 14 '25 01:02 8deline