OBPIH-7441 refactor org identifier generation#5433
Conversation
grails-app/services/org/pih/warehouse/core/OrganizationIdentifierService.groovy
Show resolved
Hide resolved
| property('code') | ||
| } | ||
| like('code', identifier + '%') | ||
| } as List<String> |
There was a problem hiding this comment.
annoyingly unit tests don't natively support HQL. I get the following error with the executeQuery version:
java.lang.UnsupportedOperationException: String-based queries like [executeQuery] are currently not supported in this implementation of GORM. Use criteria instead.
at org.grails.datastore.gorm.GormStaticApi.unsupported(GormStaticApi.groovy:1179)
at org.grails.datastore.gorm.GormStaticApi.executeQuery(GormStaticApi.groovy:1062)
at org.grails.datastore.gorm.GormStaticApi.executeQuery(GormStaticApi.groovy:1057)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.executeQuery(GormEntity.groovy:1056)
It seems like there are some proposed solutions: https://stackoverflow.com/questions/50516956/grails-unit-test-fails-string-based-queries-like-executequery-are-currently-n but the mixins this one suggests are deprecated and I was having some issues getting the test dependency to resolve so I gave up on it and just changed this to a criteria query for now.
| } | ||
|
|
||
| expect: | ||
| assert service.generate("Big Bad") == "BB10" // Right now this returns "B:" which is bad! |
There was a problem hiding this comment.
oof. This actually generates "B:" instead of erroring or generating "B10". Is ':' the next char after '9'???
EDIT: to be clear, this is existing behaviour and is one of the things I left as a TODO item for a later task to resolve.
|
as a heads up, I intentionally put this PR against develop. We're going to change our settings on stage/prod which will fix the issue for the current release. This PR is a more "proper" fix for the next release |
✨ Description of Change
Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7441
Description:
This doesn't fix the issue on prod. I just wanted to create some tests so that we could better understand what the current behaviour is. We can add to this PR if we want to push a code fix to the identifier service, or we can leave the PR as is and just keep it as unit tests.EDIT: This now properly fixes organization identifier generation. There are still some cases that I opted not to solve in this PR that I left as TODOs instead.