Skip to content

Commit d622deb

Browse files
committed
store: handle case insensitive array inputs in query
1 parent 97992cb commit d622deb

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

store/postgres/src/relational_queries.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,17 +1618,31 @@ impl<'a> Filter<'a> {
16181618
out.push_sql(") > 0");
16191619
}
16201620
}
1621-
SqlValue::List(_) | SqlValue::Numerics(_) => {
1622-
if op.negated() {
1623-
out.push_sql(" not ");
1624-
column.walk_ast(out.reborrow())?;
1625-
out.push_sql(" && ");
1626-
} else {
1621+
SqlValue::List(_) | SqlValue::Numerics(_) => match op {
1622+
// For case-insensitive operations
1623+
ContainsOp::ILike | ContainsOp::NotILike => {
1624+
if op.negated() {
1625+
out.push_sql(" not ");
1626+
}
1627+
out.push_sql("exists (select 1 from unnest(");
16271628
column.walk_ast(out.reborrow())?;
1628-
out.push_sql(" @> ");
1629+
out.push_sql(") as elem where elem ilike any(");
1630+
qv.walk_ast(out.reborrow())?;
1631+
out.push_sql("))");
16291632
}
1630-
qv.walk_ast(out)?;
1631-
}
1633+
_ => {
1634+
// For case-sensitive operations
1635+
if op.negated() {
1636+
out.push_sql(" not ");
1637+
column.walk_ast(out.reborrow())?;
1638+
out.push_sql(" && ");
1639+
} else {
1640+
column.walk_ast(out.reborrow())?;
1641+
out.push_sql(" @> ");
1642+
}
1643+
qv.walk_ast(out)?;
1644+
}
1645+
},
16321646
SqlValue::Null
16331647
| SqlValue::Bool(_)
16341648
| SqlValue::Numeric(_)

0 commit comments

Comments
 (0)