Skip to content

Commit

Permalink
Merge pull request #158 from kant2002/kant/tolower
Browse files Browse the repository at this point in the history
Fix isNullTranstion which chokes if use ToLower
  • Loading branch information
simon-reynolds authored Nov 21, 2023
2 parents d5f86f0 + 7fb18fb commit 5bc850d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/EFCore.FSharp/Translations/IsNullTranslation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ let isNullMethodTranslator (sqlExp: ISqlExpressionFactory) =
if method.DeclaringType.IsValueType then
null
else
let expression = arguments |> Seq.head

match method.Name with
| "IsNull" -> sqlExp.IsNull(expression) :> _
let expression = arguments |> Seq.tryHead
match expression with
| Some expression when method.Name = "IsNull" -> sqlExp.IsNull(expression) :> _
| _ -> null }
15 changes: 15 additions & 0 deletions tests/EFCore.FSharp.Tests/Translations/IsNullTranslationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ let OptionTranslationQueryTests =
headOrDefault
}

Expect.equal blog blogWithContent "Record in context should match"
}

test "Do not break ToLower" {
use ctx = createContext ()
saveBlogs ctx

let blog =
query {
for blog in ctx.Blogs do
where (blog.Content.ToLower() = "some text")
select blog
headOrDefault
}

Expect.equal blog blogWithContent "Record in context should match"
} ]

Expand Down

0 comments on commit 5bc850d

Please sign in to comment.