fhir-persistence 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5212,31 +5212,38 @@ function buildTokenColumnFragmentV2(impl, param, dialect) {
5212
5212
  if (param.modifier === "text") {
5213
5213
  return buildLikeFragmentV2(sortCol, param.values, "", "%");
5214
5214
  }
5215
- const needsLike = param.values.some((v) => v.endsWith("|"));
5216
- if (needsLike) {
5217
- const conds = [];
5218
- const vals = [];
5219
- for (const value of param.values) {
5215
+ const exactValues = [];
5216
+ const likePatterns = [];
5217
+ for (const value of param.values) {
5218
+ if (value.includes("|")) {
5220
5219
  if (value.endsWith("|")) {
5221
- const frag = arrayContainsLikeV2(textCol, value + "%", dialect);
5222
- conds.push(frag.sql);
5223
- vals.push(...frag.values);
5220
+ likePatterns.push(value + "%");
5224
5221
  } else {
5225
- const resolved = value.startsWith("|") ? value.slice(1) : value;
5226
- const frag = arrayContainsV2(textCol, [resolved], dialect);
5227
- conds.push(frag.sql);
5228
- vals.push(...frag.values);
5222
+ exactValues.push(value);
5229
5223
  }
5224
+ } else {
5225
+ likePatterns.push(`%|${value}`);
5230
5226
  }
5231
- const inner = conds.length === 1 ? conds[0] : `(${conds.join(" OR ")})`;
5232
- const sql = param.modifier === "not" ? `NOT (${inner})` : inner;
5233
- return { sql, values: vals };
5234
5227
  }
5235
- const resolvedValues = param.values.map((v) => v.startsWith("|") ? v.slice(1) : v);
5236
- if (param.modifier === "not") {
5237
- return arrayNotContainsV2(textCol, resolvedValues, dialect);
5238
- }
5239
- return arrayContainsV2(textCol, resolvedValues, dialect);
5228
+ const conds = [];
5229
+ const vals = [];
5230
+ if (exactValues.length > 0) {
5231
+ const frag = param.modifier === "not" ? arrayNotContainsV2(textCol, exactValues, dialect) : arrayContainsV2(textCol, exactValues, dialect);
5232
+ conds.push(frag.sql);
5233
+ vals.push(...frag.values);
5234
+ }
5235
+ for (const pattern of likePatterns) {
5236
+ const frag = arrayContainsLikeV2(textCol, pattern, dialect);
5237
+ const sql = param.modifier === "not" ? `NOT (${frag.sql})` : frag.sql;
5238
+ conds.push(sql);
5239
+ vals.push(...frag.values);
5240
+ }
5241
+ if (conds.length === 0) {
5242
+ return { sql: "1=1", values: [] };
5243
+ }
5244
+ const joiner = param.modifier === "not" ? " AND " : " OR ";
5245
+ const inner = conds.length === 1 ? conds[0] : `(${conds.join(joiner)})`;
5246
+ return { sql: inner, values: vals };
5240
5247
  }
5241
5248
  function buildDefaultFragmentV2(impl, param) {
5242
5249
  const col = quoteColumn(impl.columnName);