snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Filtering not working on different views except all

Open diekmanu opened this issue 9 years ago • 5 comments

Expected Behavior (or desired behavior if a feature request)

When I enter different search strings in the search box filtering should work in all views including "Pending", "Deployed", "RTD", "Activity Report', etc.

Advanced search works in these views, but not all the expected results are displayed.


Actual Behavior

When I enter different search strings in the search box filtering is only working in the "ALL" view.


Please confirm you have done the following before posting your bug report:


Provide answers to these questions:

  • Is this a fresh install or an upgrade? Upgrade
  • Version of Snipe-IT you're running: v4.0.9 build 189 (g907b909) / develop
  • Version of PHP you're running: 5.6.29
  • Version of MySQL/MariaDB you're running: MariaDB 10.1.3
  • What OS and web server you're running Snipe-IT on: win7x64, nginx
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc): manual
  • WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error
  • If a stacktrace is provided in the error, include that too.
  • Any errors that appear in your browser's error console.
  • Confirm whether the error is reproduceable on the demo: https://snipeitapp.com/demo.
  • Include any additional information you can find in app/storage/logs and your webserver's logs.
  • Include what you've done so far in the installation, and if you got any error messages along the way.
  • Indicate whether or not you've manually edited any data directly in the database

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

diekmanu avatar Oct 02 '17 06:10 diekmanu

laravel.log (Deployed/RTD view):

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'assigned_to' in where clause is ambiguous (SQL: select count(*) as aggregate from assetsleft joinusersonusers.id=assets.assigned_toandassets.assigned_type= App\Models\User left joinlocationsonlocations.id=assets.assigned_toandassets.assigned_type= App\Models\Location left joinassetsasassigned_assetsonassigned_assets.id=assets.assigned_toandassets.assigned_type= App\Models\Asset where (exists (select * frommodelswhereassets.model_id=models.idand exists (select * fromcategorieswheremodels.category_id=categories.id and (categories.nameLIKE %diekmanu% ormodels.nameLIKE %diekmanu% ormodels.model_numberLIKE %diekmanu%) andcategories.deleted_atis null)) or exists (select * frommodelswhereassets.model_id=models.idand exists (select * frommanufacturerswheremodels.manufacturer_id=manufacturers.id and (manufacturers.nameLIKE %diekmanu%) andmanufacturers.deleted_atis null)) or (exists (select * fromstatus_labelswhereassets.status_id=status_labels.idandstatus_labels.nameLIKE %diekmanu% andstatus_labels.deleted_atis null)) or (exists (select * fromsupplierswhereassets.supplier_id=suppliers.idandsuppliers.nameLIKE %diekmanu% andsuppliers.deleted_atis null)) or (exists (select * fromcompanieswhereassets.company_id=companies.idandcompanies.nameLIKE %diekmanu%)) or (exists (select * fromlocationswhereassets.rtd_location_id=locations.idandlocations.nameLIKE %diekmanu% andlocations.deleted_atis null)) or (exists (select * fromassetsaslaravel_reserved_0wherelaravel_reserved_0.id=laravel_reserved_0.assigned_to and (users.first_nameLIKE %diekmanu% orusers.last_nameLIKE %diekmanu% orusers.usernameLIKE %diekmanu% orlocations.nameLIKE %diekmanu% orassigned_assets.nameLIKE %diekmanu%) andlaravel_reserved_0.deleted_atis null)) orassets.nameLIKE %diekmanu% orassets.asset_tagLIKE %diekmanu% orassets.serialLIKE %diekmanu% orassets.order_numberLIKE %diekmanu% orassets.notesLIKE %diekmanu% orassets._snipeit_mac_address_1LIKE %diekmanu% orassets._snipeit_ip_adresse_2LIKE %diekmanu% orassets._snipeit_lan_port_3LIKE %diekmanu% orassets._snipeit_raum_6LIKE %diekmanu% orassets._snipeit_dsm_rc_viewer_7LIKE %diekmanu%) andassets.deleted_atis null andassigned_to> 0)' in D:\SYSTEM\WPN-XM\www\snipe-it_v4\vendor\laravel\framework\src\Illuminate\Database\Connection.php:647

Looks like ...and assigned_to> 0)'misses the table name.

The remaining views throw exceptions similar to this:

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'laravel_reserved_0.status_id' in 'where clause' (SQL: select count(*) as aggregate from assets left join users on users.id = assets.assigned_to and assets.assigned_type = App\Models\User left join locations on locations.id = assets.assigned_to and assets.assigned_type = App\Models\Location left join assets as assigned_assets on assigned_assets.id = assets.assigned_to and assets.assigned_type = App\Models\Asset where (exists (select * from models where assets.model_id = models.id and exists (select * from categories where models.category_id = categories.id and (categories.name LIKE %diek% or models.name LIKE %diek% or models.model_number LIKE %diek%) and categories.deleted_at is null)) or exists (select * from models where assets.model_id = models.id and exists (select * from manufacturers where models.manufacturer_id = manufacturers.id and (manufacturers.name LIKE %diek%) and manufacturers.deleted_at is null)) or (exists (select * from status_labels where assets.status_id = status_labels.id and status_labels.name LIKE %diek% and status_labels.deleted_at is null)) or (exists (select * from suppliers where assets.supplier_id = suppliers.id and suppliers.name LIKE %diek% and suppliers.deleted_at is null)) or (exists (select * from companies where assets.company_id = companies.id and companies.name LIKE %diek%)) or (exists (select * from locations where assets.rtd_location_id = locations.id and locations.name LIKE %diek% and locations.deleted_at is null)) or (exists (select * from assets as laravel_reserved_0 where laravel_reserved_0.id = laravel_reserved_0.assigned_to and (users.first_name LIKE %diek% or users.last_name LIKE %diek% or users.username LIKE %diek% or locations.name LIKE %diek% or assigned_assets.name LIKE %diek%) and laravel_reserved_0.deleted_at is null)) or assets.name LIKE %diek% or assets.asset_tag LIKE %diek% or assets.serial LIKE %diek% or assets.order_number LIKE %diek% or assets.notes LIKE %diek% or assets._snipeit_mac_address_1 LIKE %diek% or assets._snipeit_ip_adresse_2 LIKE %diek% or assets._snipeit_lan_port_3 LIKE %diek% or assets._snipeit_raum_6 LIKE %diek% or assets._snipeit_dsm_rc_viewer_7 LIKE %diek%) and assets.deleted_at is null and exists (select * from status_labels where laravel_reserved_0.status_id = status_labels.id and deployable = 0 and pending = 1 and archived = 0 and status_labels.deleted_at is null))' in D:\SYSTEM\WPN-XM\www\snipe-it_v4\vendor\laravel\framework\src\Illuminate\Database\Connection.php:647

Could be a similar problem:

and deployable= 0 andpending= 1 andarchived = 0

and status_labels.deployable= 0 andstatus_labels.pending= 1 andstatus_labels.archived = 0

??

This is also happening on the demo pages.

diekmanu avatar Oct 11 '17 15:10 diekmanu

Seems to be related to #4198

diekmanu avatar Oct 12 '17 13:10 diekmanu

Can you see if the latest release fixes this?

snipe avatar Oct 24 '17 08:10 snipe

This is working now in all views (v4.0.15)

diekmanu avatar Oct 24 '17 09:10 diekmanu

👍 thanks for confirming!

snipe avatar Oct 24 '17 09:10 snipe