Skip to content

Commit

Permalink
fix: quotations in vals (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkozyura authored Jul 24, 2024
1 parent 3f3fd61 commit 94d8e97
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db-service/lib/cql-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const StandardFunctions = {
search: function (ref, arg) {
if (!('val' in arg)) throw new Error(`Only single value arguments are allowed for $search`)
// only apply first search term, rest is ignored
arg.val = arg.__proto__.val = arg.val.split(' ')[0].replace(/"/g, '')
const sub= /("")|("(?:[^"]|\\")*(?:[^\\]|\\\\)")|(\S*)/.exec(arg.val)
arg.val = arg.__proto__.val = (sub[2] ? JSON.parse(sub[2]) : sub[3]) || ''
const refs = ref.list || [ref],
{ toString } = ref
return '(' + refs.map(ref2 => this.contains(this.tolower(toString(ref2)), this.tolower(arg))).join(' or ') + ')'
Expand Down

0 comments on commit 94d8e97

Please sign in to comment.