SinergiaTIC / SinergiaDA

SinergiaDA is an open source analytics tool that fully integrates with SinergiaCRM
GNU Affero General Public License v3.0
4 stars 0 forks source link

Incidencia - EDA - Error paneles SQL si una lista tiene campos vacios. #196

Open PaulaaSTIC opened 1 month ago

PaulaaSTIC commented 1 month ago

Hemos observado que la siguiente consulta SQL produce un error. Al ejecutar la consulta en SDA, se genera el siguiente mensaje en el log: TypeError: Cannot read properties of undefined (reading '0'). Sin embargo, esta misma consulta no produce un error si la ejecutamos directamente en la base de datos. Haciendo pruebas, hemos identificado que esto se produce porque en el tipo de relación hay campos que no tienen valores, pero este error no debería producirse.

SELECT `sda_l_stic_accounts_relationships_relationship_type_stic_account`.`value` as `Tipo de relación`, 
sum(case when year(`sda_stic_accounts_relationships`.`start_date`) >= year(curdate()) then 1 else 0 end) as 'Altas año en curso', 
sum(case when year(`sda_stic_accounts_relationships`.`start_date`) < year(curdate()) then 1 else 0 end) as 'Altas anteriores',
count(`sda_stic_accounts_relationships`.`N`) as 'Total'

FROM sda_stic_accounts_relationships 

inner join `sda_l_stic_accounts_relationships_relationship_type_stic_account` on `sda_l_stic_accounts_relationships_relationship_type_stic_account`.`code` = `sda_stic_accounts_relationships`.`relationship_type`  

where  `sda_l_stic_accounts_relationships_relationship_type_stic_account`.`value` is not null AND `sda_stic_accounts_relationships`.`active` = '1'

group by `sda_l_stic_accounts_relationships_relationship_type_stic_account`.`value`