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

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

Open
bennsimon opened this issue Nov 29, 2021 · 0 comments · May be fixed by opensrp/opensrp-server-core#617 or #1187
Assignees
Labels
good first issue Good for newcomers

Comments

@bennsimon
Copy link
Member

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment