Repository navigation
Only match a numeric vocabulary search against concept_id when it fits in an INT - #2602
Open
chenyangsu wants to merge 1 commit into
Open
chenyangsu wants to merge 1 commit into
chenyangsu wants to merge 1 commit into
Conversation
…s in an INT A numeric search term is also compared with CAST(@query as int). A term longer than an INT, such as an 11-digit NDC code, made the cast fail, so the search returned an error (POST) or no rows (GET) instead of matching the code by name and concept_code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the vocabulary search term is all digits,
prepareExecuteSearchaddsor CONCEPT_ID = CAST(@query as int). A term longer than an INT, such as the 11-digit NDC code50090347201, makes that cast fail on PostgreSQL:The GET form (
/search?query=50090347201), which ATLAS uses for a search without filters, runs the same SQL throughDatabaseSearchProvider, and its handler logs the exception and returns[]. Either way the concept with thatconcept_codeis not found.This change adds the concept_id clause only when the term parses as an int, so a longer number is still matched against
concept_nameandconcept_code. If you would rather cast to BIGINT in the SQL, I can switch; that version still fails for terms of 20 or more digits.Testing: the new
VocabularySearchNumericQueryTestruns the search SQL on the embedded PostgreSQL; 2 of its 3 tests fail on master with the error above../mvnw test: 179 unit tests, 0 failures, 5 skipped; 35 integration tests, 0 failures, 3 skipped.