Open auxilioit opened 3 years ago
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
Can confirm.
Versions: snipeit 5.0.10; 5.1.3 OS: Debian 9 PHP version: 7.3.23
The above mentioned fix did fix it with v5.1.3.
Hi,
I am getting another issue that seems to be relating to this, when attempting to load Requestable assets from a Company assigned account.
Error: [2021-04-08 11:24:45] production.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'company_id' in where clause is ambiguous
Seems to be related to scopeCompanyable function.
Line I think maybe causing error in where:
and
snipe_assets
.assigned_type
= App\Models\Asset wherecompany_id
= 2
Expected Behavior (or desired behavior if a feature request)
For non-super user to be able to view assets assigned to their company.
Actual Behavior
No assets appear on load.
I have made changes to App\Models\Company Line 84; return $query->where($table.$column, '=', $company_id); > return $query->where($column, '=', $company_id);
Removing $table resolves the issue.
Please confirm you have done the following before posting your bug report:
Provide answers to these questions:
Received via API:
{ "message": "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'snipe_snipe_assets.company_id' in 'where clause' (SQL: select count(*) as aggregate from
snipe_assets
wheresnipe_snipe_assets
.company_id
= 3 andsnipe_assets
.deleted_at
is null)", "exception": "Illuminate\Database\QueryException", "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 669, "trace": [ { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 629, "function": "runQueryCallback", "class": "Illuminate\Database\Connection", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 338, "function": "run", "class": "Illuminate\Database\Connection", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php", "line": 2159, "function": "select", "class": "Illuminate\Database\Connection", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php", "line": 2147, "function": "runSelect", "class": "Illuminate\Database\Query\Builder", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php", "line": 2619, "function": "Illuminate\Database\Query\{closure}", "class": "Illuminate\Database\Query\Builder", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php", "line": 2148, "function": "onceWithColumns", "class": "Illuminate\Database\Query\Builder", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php", "line": 2546, "function": "get", "class": "Illuminate\Database\Query\Builder", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php", "line": 2474, "function": "aggregate", "class": "Illuminate\Database\Query\Builder", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php", "line": 1385, "function": "count", "class": "Illuminate\Database\Query\Builder", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/app/Http/Controllers/Api/AssetsController.php", "line": 147, "function": "__call", "class": "Illuminate\Database\Eloquent\Builder", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php", "line": 54, "function": "index", "class": "App\Http\Controllers\Api\AssetsController", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php", "line": 45, "function": "callAction", "class": "Illuminate\Routing\Controller", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 219, "function": "dispatch", "class": "Illuminate\Routing\ControllerDispatcher", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 176, "function": "runController", "class": "Illuminate\Routing\Route", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 681, "function": "run", "class": "Illuminate\Routing\Route", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 130, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php", "line": 43, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\Auth\Middleware\Authenticate", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 105, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 683, "function": "then", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 658, "function": "runRouteWithinStack", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 624, "function": "runRoute", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 613, "function": "dispatchToRoute", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 170, "function": "dispatch", "class": "Illuminate\Routing\Router", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 130, "function": "Illuminate\Foundation\Http\{closure}", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php", "line": 67, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Barryvdh\Debugbar\Middleware\InjectDebugbar", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/app/Http/Middleware/SecurityHeaders.php", "line": 26, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "App\Http\Middleware\SecurityHeaders", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/app/Http/Middleware/CheckForDebug.php", "line": 25, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "App\Http\Middleware\CheckForDebug", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/app/Http/Middleware/CheckForSetup.php", "line": 26, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "App\Http\Middleware\CheckForSetup", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Fideloper\Proxy\TrustProxies", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php", "line": 49, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\View\Middleware\ShareErrorsFromSession", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php", "line": 56, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\Session\Middleware\StartSession", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php", "line": 63, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/app/Http/Middleware/NoSessionStore.php", "line": 27, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "App\Http\Middleware\NoSessionStore", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/barryvdh/laravel-cors/src/HandlePreflight.php", "line": 29, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 171, "function": "handle", "class": "Barryvdh\Cors\HandlePreflight", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 105, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 145, "function": "then", "class": "Illuminate\Pipeline\Pipeline", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 110, "function": "sendRequestThroughRouter", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" }, { "file": "/var/www/ams.iprsapps.com/public/index.php", "line": 58, "function": "handle", "class": "Illuminate\Foundation\Http\Kernel", "type": "->" } ] }storage/logs
and your webserver's logs. [2021-02-26 20:54:58] production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'snipe_snipe_assets.company_id' in 'where clause' (SQL: select count() as aggregate fromsnipe_assets
wheresnipe_snipe_assets
.company_id
= 3 andsnipe_assets
.deleted_at
is null) {"userId":250,"exception":"[object] (Illuminate\Database\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'snipe_snipe_assets.company_id' in 'where clause' (SQL: select count() as aggregate fromsnipe_assets
wheresnipe_snipe_assets
.company_id
= 3 andsnipe_assets
.deleted_at
is null) at /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669) [stacktrace]0 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php(629): Illuminate\Database\Connection->runQueryCallback()
1 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php(338): Illuminate\Database\Connection->run()
2 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2159): Illuminate\Database\Connection->select()
3 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2147): Illuminate\Database\Query\Builder->runSelect()
4 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2619): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
5 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2148): Illuminate\Database\Query\Builder->onceWithColumns()
6 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2546): Illuminate\Database\Query\Builder->get()
7 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2474): Illuminate\Database\Query\Builder->aggregate()
8 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1385): Illuminate\Database\Query\Builder->count()
9 /var/www/ams.iprsapps.com/app/Http/Controllers/Api/AssetsController.php(147): Illuminate\Database\Eloquent\Builder->__call()
10 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\Api\AssetsController->index()
11 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction()
12 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch()
13 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
14 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\Routing\Route->run()
15 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Routing\Router->Illuminate\Routing\{closure}()
16 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
17 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Auth\Middleware\Authenticate->handle()
18 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
19 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\Pipeline\Pipeline->then()
20 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Router->runRouteWithinStack()
21 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\Routing\Router->runRoute()
22 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\Routing\Router->dispatchToRoute()
23 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\Routing\Router->dispatch()
24 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
25 /var/www/ams.iprsapps.com/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(60): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
26 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()
27 /var/www/ams.iprsapps.com/app/Http/Middleware/SecurityHeaders.php(26): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
28 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\Http\Middleware\SecurityHeaders->handle()
29 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
30 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
31 /var/www/ams.iprsapps.com/app/Http/Middleware/CheckForDebug.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
32 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\Http\Middleware\CheckForDebug->handle()
33 /var/www/ams.iprsapps.com/app/Http/Middleware/CheckForSetup.php(26): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
34 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\Http\Middleware\CheckForSetup->handle()
35 /var/www/ams.iprsapps.com/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
36 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle()
37 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
38 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
39 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
40 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Session\Middleware\StartSession->handle()
41 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
42 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
43 /var/www/ams.iprsapps.com/app/Http/Middleware/NoSessionStore.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
44 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\Http\Middleware\NoSessionStore->handle()
45 /var/www/ams.iprsapps.com/vendor/barryvdh/laravel-cors/src/HandlePreflight.php(29): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
46 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\Cors\HandlePreflight->handle()
47 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
48 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\Pipeline\Pipeline->then()
49 /var/www/ams.iprsapps.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
50 /var/www/ams.iprsapps.com/public/index.php(58): Illuminate\Foundation\Http\Kernel->handle()
51 {main}
Please do not post an issue without answering the related questions above. If you have opened a different issue and already answered these questions, answer them again, once for every ticket. It will be next to impossible for us to help you.
https://snipe-it.readme.io/docs/getting-help