From d622deb42ea88854df49714351082e17409b8c4e Mon Sep 17 00:00:00 2001 From: Shiyas Mohammed Date: Sun, 13 Jul 2025 09:23:51 +0530 Subject: [PATCH] store: handle case insensitive array inputs in query --- store/postgres/src/relational_queries.rs | 32 +++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/store/postgres/src/relational_queries.rs b/store/postgres/src/relational_queries.rs index 533990c42b9..554337446d2 100644 --- a/store/postgres/src/relational_queries.rs +++ b/store/postgres/src/relational_queries.rs @@ -1618,17 +1618,31 @@ impl<'a> Filter<'a> { out.push_sql(") > 0"); } } - SqlValue::List(_) | SqlValue::Numerics(_) => { - if op.negated() { - out.push_sql(" not "); - column.walk_ast(out.reborrow())?; - out.push_sql(" && "); - } else { + SqlValue::List(_) | SqlValue::Numerics(_) => match op { + // For case-insensitive operations + ContainsOp::ILike | ContainsOp::NotILike => { + if op.negated() { + out.push_sql(" not "); + } + out.push_sql("exists (select 1 from unnest("); column.walk_ast(out.reborrow())?; - out.push_sql(" @> "); + out.push_sql(") as elem where elem ilike any("); + qv.walk_ast(out.reborrow())?; + out.push_sql("))"); } - qv.walk_ast(out)?; - } + _ => { + // For case-sensitive operations + if op.negated() { + out.push_sql(" not "); + column.walk_ast(out.reborrow())?; + out.push_sql(" && "); + } else { + column.walk_ast(out.reborrow())?; + out.push_sql(" @> "); + } + qv.walk_ast(out)?; + } + }, SqlValue::Null | SqlValue::Bool(_) | SqlValue::Numeric(_)