Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incidencia - EDA - TypeError en modo SQL #199

Open
PaulaaSTIC opened this issue Aug 13, 2024 · 6 comments
Open

Incidencia - EDA - TypeError en modo SQL #199

PaulaaSTIC opened this issue Aug 13, 2024 · 6 comments
Assignees
Labels
bug Something isn't working EDA Exclusivo de EDA

Comments

@PaulaaSTIC
Copy link
Collaborator

PaulaaSTIC commented Aug 13, 2024

La siguiente consulta SQL genera un error al ejecutarse en el modo SQL de SDA, aunque al ejecutarla directamente en la base de datos, devuelve el resultado esperado (como se muestra en la imagen). En el log, se registra el siguiente error: TypeError: Cannot read properties of undefined (reading '0').
image

SELECT
   CASE
        WHEN `sda_contacts`.`stic_age_c` BETWEEN 0 and 5 THEN '0 - 5 anys'
        WHEN `sda_contacts`.`stic_age_c` BETWEEN 6 and 10 THEN '6 - 10 anys'
        WHEN `sda_contacts`.`stic_age_c` BETWEEN 11 and 15 THEN '11 - 15 anys'
        WHEN `sda_contacts`.`stic_age_c` BETWEEN 16 and 20 THEN '16 - 20 anys'
        WHEN `sda_contacts`.`stic_age_c` > 20 THEN '21 o més anys'
        WHEN `sda_contacts`.`stic_age_c` IS NULL THEN ' '
    END as Rango_Edad,
   count(distinct `sda_contacts`.`id`) as "N"
FROM sda_contacts
inner JOIN `sda_stic_registrations` ON  `sda_contacts`.`id` = `sda_stic_registrations`.`stic_registrations_contactscontacts_ida`
inner JOIN `sda_stic_events` ON  `sda_stic_registrations`.`stic_registrations_stic_eventsstic_events_ida` = `sda_stic_events`.`id`
where  (`sda_stic_events`.`subevento2_c`  in ('ACTIVIDAD VERANO')  )
GROUP BY Rango_Edad
@PaulaaSTIC PaulaaSTIC added bug Something isn't working EDA Exclusivo de EDA labels Aug 13, 2024
@jortilles
Copy link
Collaborator

@ronaldchavezjortilles

@ronaldchavezjortilles
Copy link
Collaborator

La query es correcta y he verificado que con la ayuda de alias al momento de construir la query funciona adecuadamente.

Dejo la misma query con el alias "c" para la tabla sda_contacts.

SELECT
   CASE
        WHEN c.`stic_age_c` BETWEEN 0 and 5 THEN '0 - 5 anys'
        WHEN c.`stic_age_c` BETWEEN 6 and 10 THEN '6 - 10 anys'
        WHEN c.`stic_age_c` BETWEEN 11 and 15 THEN '11 - 15 anys'
        WHEN c.`stic_age_c` BETWEEN 16 and 20 THEN '16 - 20 anys'
        WHEN c.`stic_age_c` > 20 THEN '21 o més anys'
        WHEN c.`stic_age_c` IS NULL THEN ' '
    END as Rango_Edad,
   count(distinct c.`id`) as "N"
FROM sda_contacts c
inner JOIN `sda_stic_registrations` ON c.`id` = `sda_stic_registrations`.`stic_registrations_contactscontacts_ida`
inner JOIN `sda_stic_events` ON  `sda_stic_registrations`.`stic_registrations_stic_eventsstic_events_ida` = `sda_stic_events`.`id`
where  (`sda_stic_events`.`subevento2_c`  in ('ACTIVIDAD VERANO')  )
GROUP BY Rango_Edad

@jortilles
Copy link
Collaborator

En la actualidad si se puede filtrar en los paneles SQL poniendo alias y haciendo referencia a la tabla principal de la consulta.

Para los campos desplegables debemos definir el comportamiento. Actualmente tenemos dos opciones. Hacer referencia al campo principal o hacer referencia al campo de la tabla accesoria.

and ${c.stic_gender_c}

------------------------------- VS

left join sda_l_contacts_stic_gender_c_stic_genders_list ls on ls.code = c.stic_gender_c

and ${ls.value}

@ronaldchavezjortilles
Copy link
Collaborator

Hemos verificado con Juanjo y hemos agregado unos cambios para asegurar la query.

@ronaldchavezjortilles
Copy link
Collaborator

Aunque esto está cerrado nos gustaría hacer un pr relacionado con esto

@jortilles
Copy link
Collaborator

Se crea el pr #229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working EDA Exclusivo de EDA
Projects
None yet
Development

No branches or pull requests

3 participants