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

Cannot search by username (checked out to) in 4.0.3

Open diekmanu opened this issue 9 years ago • 6 comments

Expected Behavior (or desired behavior if a feature request)

When I enter a well-known username in 'All assets' or in other views I would like to see all the assets checked out to this particular user.


Actual Behavior

The query results in 'No matching records found'


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


Please provide answers to these questions before posting your bug report:

  • Version of Snipe-IT you're running: v4.0.3 build 8 (gb354ca8)
  • What OS and web server you're running Snipe-IT on: nginx, win7x64
  • 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: YES
  • 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

diekmanu avatar Sep 26 '17 12:09 diekmanu

Old working v3 query: select count(*) as aggregate from assetsinner joinmodelsonassets.model_id=models.idwherephysical= '1' and (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 * 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 * fromuserswhereassets.assigned_to=users.id and (users.first_nameLIKE '%diekmanu%' orusers.last_nameLIKE '%diekmanu%' or (exists (select * fromlocationswhereusers.location_id=locations.idandlocations.nameLIKE '%diekmanu%'))))) orassets.nameLIKE '%diekmanu%' orassets.asset_tagLIKE '%diekmanu%' orassets.serialLIKE '%diekmanu%' orassets.order_numberLIKE '%diekmanu%' orassets.notesLIKE '%diekmanu%' or_snipeit_mac_addressLIKE '%diekmanu%' or_snipeit_ip_adresseLIKE '%diekmanu%' or_snipeit_lan_portLIKE '%diekmanu%' or_snipeit_raumLIKE '%diekmanu%' or_snipeit_dsm_rc_viewerLIKE '%diekmanu%') andassets.deleted_atis null order bymodels.name` asc

select assets.* from assets inner join models on assets.model_id = models.id where physical = '1' and (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 '%diekmanu%' or models.name LIKE '%diekmanu%' or models.model_number LIKE '%diekmanu%') 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 '%diekmanu%') and manufacturers.deleted_at is null)) or (exists (select * from status_labels where assets.status_id = status_labels.id and status_labels.name LIKE '%diekmanu%' and status_labels.deleted_at is null)) or (exists (select * from companies where assets.company_id = companies.id and companies.name LIKE '%diekmanu%')) or (exists (select * from locations where assets.rtd_location_id = locations.id and locations.name LIKE '%diekmanu%' and locations.deleted_at is null)) or (exists (select * from users where assets.assigned_to = users.id and (users.first_name LIKE '%diekmanu%' or users.last_name LIKE '%diekmanu%' or (exists (select * from locations where users.location_id = locations.id and locations.name LIKE '%diekmanu%'))))) or assets.name LIKE '%diekmanu%' or assets.asset_tag LIKE '%diekmanu%' or assets.serial LIKE '%diekmanu%' or assets.order_number LIKE '%diekmanu%' or assets.notes LIKE '%diekmanu%' or _snipeit_mac_address LIKE '%diekmanu%' or _snipeit_ip_adresse LIKE '%diekmanu%' or _snipeit_lan_port LIKE '%diekmanu%' or _snipeit_raum LIKE '%diekmanu%' or _snipeit_dsm_rc_viewer LIKE '%diekmanu%') and assets.deleted_at is null order by models.name asc limit 200 offset 0`

Non-working v4 query: select count(*) as aggregate from assetswhere (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)) orassets.nameLIKE '%diekmanu%' orassets.asset_tagLIKE '%diekmanu%' orassets.serialLIKE '%diekmanu%' orassets.order_numberLIKE '%diekmanu%' orassets.notesLIKE '%diekmanu%' or_snipeit_mac_address_1LIKE '%diekmanu%' or_snipeit_ip_adresse_2LIKE '%diekmanu%' or_snipeit_lan_port_3LIKE '%diekmanu%' or_snipeit_raum_6LIKE '%diekmanu%' or_snipeit_dsm_rc_viewer_7LIKE '%diekmanu%') andassets.deleted_atis null order byassets.created_at` asc

select assets.* from assets 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 '%diekmanu%' or models.name LIKE '%diekmanu%' or models.model_number LIKE '%diekmanu%') 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 '%diekmanu%') and manufacturers.deleted_at is null)) or (exists (select * from status_labels where assets.status_id = status_labels.id and status_labels.name LIKE '%diekmanu%' and status_labels.deleted_at is null)) or (exists (select * from suppliers where assets.supplier_id = suppliers.id and suppliers.name LIKE '%diekmanu%' and suppliers.deleted_at is null)) or (exists (select * from companies where assets.company_id = companies.id and companies.name LIKE '%diekmanu%')) or (exists (select * from locations where assets.rtd_location_id = locations.id and locations.name LIKE '%diekmanu%' and locations.deleted_at is null)) or assets.name LIKE '%diekmanu%' or assets.asset_tag LIKE '%diekmanu%' or assets.serial LIKE '%diekmanu%' or assets.order_number LIKE '%diekmanu%' or assets.notes LIKE '%diekmanu%' or _snipeit_mac_address_1 LIKE '%diekmanu%' or _snipeit_ip_adresse_2 LIKE '%diekmanu%' or _snipeit_lan_port_3 LIKE '%diekmanu%' or _snipeit_raum_6 LIKE '%diekmanu%' or _snipeit_dsm_rc_viewer_7 LIKE '%diekmanu%') and assets.deleted_at is null order by assets.created_at asc limit 200 offset 0`


So I guess the whole part starting with select * from users where assets.assigned_to = users.id and (users.first_name LIKE '%diekmanu%' or users.last_name LIKE '%diekmanu%' or is missing in v4.

diekmanu avatar Sep 27 '17 10:09 diekmanu

Anyone? Is this addressed in 4.0.5/develop? #4021

diekmanu avatar Sep 29 '17 06:09 diekmanu

Please be patient. When this is resolved, the issue will be updated.

snipe avatar Sep 29 '17 06:09 snipe

Can you pull the latest from the develop branch and tell me if this fixes your issue?

snipe avatar Sep 29 '17 08:09 snipe

Works for me now. Thanks so much @snipe

diekmanu avatar Sep 29 '17 09:09 diekmanu

Hey. I just updated to 4.0.6 and it is still not possible to search by user name. Cache etc was cleaned.

L3nny5 avatar Oct 02 '17 15:10 L3nny5