Missing items in listing - unexpected behaviour?

Post Reply
antevasin
Posts: 121
Joined: 24 Mar 2020, 08:57
Name: Spencer Crocker
Location: Corby, UK
Company Name: Unicloud
Contact:

Missing items in listing - unexpected behaviour?

Post by antevasin »

In this demo there are 7 projects created but only the first is showing. It is showing there are 7 at the bottom of the report Displaying 1 to 7 (of 7 items) when in table and list view
https://pdemo.rukovoditel.pro/3.4/index ... mo_id=2809
This seems to be down to field 217 in entity 21 which is set to MIN( [159] ). If you remove the MIN then it will display all of the items. I realise that MIN on one date is a bit meaningless but is this expected behaviour?
User avatar
support
Site Admin
Posts: 6215
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Missing items in listing - unexpected behaviour?

Post by support »

When you use MIN(e.field_159) then mysql try to group data by this field. This is not correct to use this function directly in main query. The correct way is:

Code: Select all

(select MIN(e.field_159) from app_entity_21) as min_value
antevasin
Posts: 121
Joined: 24 Mar 2020, 08:57
Name: Spencer Crocker
Location: Corby, UK
Company Name: Unicloud
Contact:

Re: Missing items in listing - unexpected behaviour?

Post by antevasin »

That snippet you posted generates an error in the demo
Database Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as min_value) as field_217 from app_entity_21 e where e.id>0 limit 0, 10' at line 1
Query: select e.* , ((select MIN(e.field_159) from app_entity_21) as min_value) as field_217 from app_entity_21 e where e.id>0 limit 0, 10
Page: /3.4/index.php?module=items/listing&demo_id=2809
#0 includes/functions/database.php(99): mysqli_query()
#1 modules/items/actions/listing.php(207): db_query()
#2 index.php(31): require('/home/admin/web...')
#3 {main}
User avatar
support
Site Admin
Posts: 6215
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Missing items in listing - unexpected behaviour?

Post by support »

It was just example in pure sql. For the field query the correct sql is:
Attachments
screenshot-pdemo.rukovoditel.pro-2024.01.26-08_01_12.png
Post Reply