Repository navigation
Escape [ in vocabulary search terms only on SQL Server dialects - #2603
chenyangsu wants to merge 1 commit into
Conversation
The search term had every [ replaced with [[], which is the T-SQL way to match a literal bracket in LIKE. Other dialects read [[] literally, so on PostgreSQL a search such as "tablet [lipitor]" matched no concept names.
|
I believe this is an issue that should be handled in OHDSI/SqlRender? |
|
Thanks for looking. As far as I can tell SqlRender never sees the search term. |
|
Hmmm not going to be handleable in sql render if it's a prepared statement issue: the ? isn't going to match on any rules. Hmmmmmmmmmmm (thinking) hmmmmmmmm Ok, short term this might be the way we go, longer term, i think SqlRender needs a subset of functionality to manage like-search term transform, then we can mutate the value from sqlserver to whatever underlying dilects understand the escape. |
prepareExecuteSearchreplaces every[in the search term with[[]before binding it intoLIKE '%...%'. That is how T-SQL matches a literal bracket, but PostgreSQL's LIKE gives[no special meaning, so there the pattern looks for the three characters[[]. RxNorm branded drug names carry the brand in brackets, and on PostgreSQL a search fortablet [lipitor]returns[]for the conceptatorvastatin 10 MG Oral Tablet [Lipitor].This change applies the escape only when the source dialect is
sql server,pdworsynapse, the dialects that read[as the start of a character class, and leaves the term as typed for the others. The lexical search uses the same term, so it is covered too. AnESCAPEclause in the search SQL would be another way to do this; I can switch if you prefer that.Testing: the new
VocabularySearchBracketTestruns the standard and lexical search on the embedded PostgreSQL (both return[]on master) and checks that a SQL Server source still binds%tablet [[]lipitor]%../mvnw test: 179 unit tests, 0 failures, 5 skipped; 35 integration tests, 0 failures, 3 skipped.