diff --git a/src/libs/routes/idhmr.js b/src/libs/routes/idhmr.js index 48973ec6c32cae821528dae3f79f19d504a316d8..42b31c3c2541dfa7582fa8ee037289158ea90250 100644 --- a/src/libs/routes/idhmr.js +++ b/src/libs/routes/idhmr.js @@ -74,12 +74,12 @@ rqf.addField({ relation: '=', type: 'integer', field: 'estado_id', - table: 'adh_idh_uf' + table: '@' }, join: { primary: 'id', foreign: 'estado_id', - foreignTable: 'adh_idh_uf' + foreignTable: '@' } }).addValue({ name: 'min_year', @@ -114,7 +114,7 @@ idhmrApp.get('/', rqf.parse(), (req, res, next) => { message: 'Wrong/No filter specified' }); } - if ("state" in req.filter) { + if ("state" in req.filter && !("city" in req.filter)) { req.sql.from('adh_idh_uf') .field('adh_idh_uf.idhm_r', 'total') .field('adh_idh_uf.ano_censo', 'year') @@ -123,7 +123,8 @@ idhmrApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('adh_idh') .field('adh_idh.idhm_r', 'total') .field('adh_idh.ano_censo', 'year') - .field('adh_idh.municipio_id', 'city_id'); + .field('adh_idh.municipio_id', 'city_id') + .field('adh_idh.estado_id', 'estado_id'); } else { next({ status: 400,