From 20bcdb320ab13d507eac6dff1f17f71123279d27 Mon Sep 17 00:00:00 2001 From: Matt Beanland Date: Fri, 21 Aug 2026 22:17:09 +0930 Subject: [PATCH] fix: string_position is zero based, and nil when the substring is absent --- lib/expr.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/expr.ex b/lib/expr.ex index 4f86c90..d4ea67e 100644 --- a/lib/expr.ex +++ b/lib/expr.ex @@ -1462,11 +1462,11 @@ defmodule AshSql.Expr do %Fragment{ embedded?: pred_embedded?, arguments: [ - raw: "#{bindings.sql_behaviour.strpos_function()}((", + raw: "(NULLIF(#{bindings.sql_behaviour.strpos_function()}((", expr: left, raw: "), (", expr: right, - raw: "))" + raw: ")), 0) - 1)" ] }, bindings,