Skip to content

Add checks to avoid exception on query execution if user is not mapped to location. #1017

@bennsimon

Description

@bennsimon

At the moment an exception is thrown when a user is not mapped to a location.

[REPORT] 23112021 13:58:59,910 ERROR [http-nio-8080-exec-4] [UserController] USER Location info not mapped to an organization
org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "AND"
  Position: 275
### The error may exist in URL [jar:file:/usr/local/tomcat/webapps/opensrp/WEB-INF/lib/opensrp-server-core-2.12.12-SNAPSHOT.jar!/org/opensrp/repository/postgres/mapper/custom/xml/CustomLocationMetadataMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select                      l.id, l.json - 'geometry' as json          from core.location l   Where l.id in   (   WITH RECURSIVE locations   AS   ( SELECT lm1.geojson_id, lm1.parent_id, lm1.location_id   FROM core.location_metadata lm1 WHERE    lm1.geojson_id IN            AND lm1.status IN ('ACTIVE', 'PENDING_REVIEW')   UNION   SELECT lm2.geojson_id, lm2.parent_id, lm2.location_id   FROM locations lm1   INNER JOIN core.location_metadata lm2 on lm2.parent_id = lm1.geojson_id AND status IN ('ACTIVE', 'PENDING_REVIEW') )   SELECT location_id FROM locations   )        LIMIT ? OFFSET ?
### Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "AND"
  Position: 275
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near "AND"
  Position: 275

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions