From 79dacbd94c6fec44ff6453600c807a7bdccd502b Mon Sep 17 00:00:00 2001 From: Joellensilva Date: Wed, 12 Feb 2025 10:32:38 -0300 Subject: [PATCH] agency cannot be empty --- repo/database/postgres.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/repo/database/postgres.go b/repo/database/postgres.go index 7d3b223..367498e 100644 --- a/repo/database/postgres.go +++ b/repo/database/postgres.go @@ -588,7 +588,12 @@ func (p *PostgresDB) GetNotices(agency string, year int, month int) ([]*string, params := []interface{}{} query := "atual = true AND avisos IS NOT NULL AND id_orgao = ?" - params = append(params, agency) + + if agency != "" { + params = append(params, agency) + } else { + return nil, fmt.Errorf("error agency cannot be empty") + } if year != 0 { query = query + " AND ano = ?"