Fix: no enviar parámetros opcionales vacíos a Metabase
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 45s

Problema:
- Al enviar parámetros con valores vacíos (""), Metabase los expandía
- Filtros opcionales [[AND ...]] se convertían en filtros obligatorios
- Resultado: queries retornaban 0 registros en lugar de aplicar filtros opcionales

Solución:
- Solo enviar parámetros si son requeridos O tienen valor no vacío
- Verificar que el valor no sea null, "", undefined o array vacío
- Los parámetros opcionales sin valor no se incluyen en el request

Afecta: MetabaseCardDisplay.vue executeQuery() líneas 345-360
This commit is contained in:
2025-10-29 17:46:36 -06:00
parent 20d71ba47a
commit e25a0c6b76

View File

@@ -342,12 +342,23 @@ async function executeQuery() {
paramValue = parameterValues.value[tagName] || ''
}
// Only add parameter if:
// 1. It's required, OR
// 2. It has a non-empty value (not null, not empty string, not empty array)
const isRequired = config.required === true
const hasValue = paramValue !== null &&
paramValue !== '' &&
paramValue !== undefined &&
(!Array.isArray(paramValue) || paramValue.length > 0)
if (isRequired || hasValue) {
parameters.push({
type: paramType,
target: ['variable', ['template-tag', tagName]],
value: paramValue
})
}
}
const result = await $fetch(`/api/metabase/cards/${props.card.id}/query`, {
method: 'POST',