Skip to content

Commit af5eeb2

Browse files
committed
AI review fixes
1 parent 01fb5ee commit af5eeb2

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/FSharp.Data.GraphQL.Server.Middleware/ObjectListFilter.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ open System.Text.Json
77
/// A filter definition for a field value.
88
type FieldFilter<'Val> = { FieldName : string; Value : 'Val }
99

10+
/// <summary>
1011
/// A filter definition for an object list.
1112
/// </summary>
1213
/// <remarks>

src/FSharp.Data.GraphQL.Server.Middleware/ObjectListFilterModule.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ module ObjectListFilter =
246246
| NonEnumerableCast ``type`` -> Expression.LessThanOrEqual ((unsafeConvertTo ``type`` ``member``), Expression.Constant f.Value)
247247
| StartsWith (f, comparer) ->
248248
let ``member`` = Expression.PropertyOrField (param, f.FieldName)
249-
let comparison = comparerToStringComparison comparer |> ValueOption.defaultValue StringComparison.Ordinal
249+
let comparison = comparerToStringComparison comparer |> ValueOption.defaultValue StringComparison.CurrentCulture
250250
Expression.Call (normalizeStringMemberExpr ``member``, StringStartsWithMethod, Expression.Constant f.Value, Expression.Constant comparison)
251251
| EndsWith (f, comparer) ->
252252
let ``member`` = Expression.PropertyOrField (param, f.FieldName)
253-
let comparison = comparerToStringComparison comparer |> ValueOption.defaultValue StringComparison.Ordinal
253+
let comparison = comparerToStringComparison comparer |> ValueOption.defaultValue StringComparison.CurrentCulture
254254
Expression.Call (normalizeStringMemberExpr ``member``, StringEndsWithMethod, Expression.Constant f.Value, Expression.Constant comparison)
255255

256256
| Contains (f, comparer) ->
@@ -289,7 +289,7 @@ module ObjectListFilter =
289289
| :? FieldInfo as field when field.FieldType |> isEnumerable -> callContains field.FieldType
290290
| _ ->
291291
let unwrappedValue = Helpers.unwrap f.Value
292-
let comparison = comparerToStringComparison comparer |> ValueOption.defaultValue StringComparison.Ordinal
292+
let comparison = comparerToStringComparison comparer |> ValueOption.defaultValue StringComparison.CurrentCulture
293293
Expression.Call (normalizeStringMemberExpr ``member``, StringContainsMethod, Expression.Constant (unwrappedValue :?> string, stringType), Expression.Constant comparison)
294294
| In f when not (f.Value.IsEmpty) ->
295295
let ``member`` = Expression.PropertyOrField (param, f.FieldName)
@@ -404,4 +404,4 @@ module ObjectListFilterExtensions =
404404
/// </code>
405405
/// </example>
406406
member inline query.Apply (filter : ObjectListFilter, [<Optional>] options : ObjectListFilterLinqOptions<'T, 'D> | null) =
407-
apply options filter query
407+
filter.ApplyTo (query, options)

src/FSharp.Data.GraphQL.Server.Middleware/TypeCoercion.fs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ module TypeCoercion =
174174
let unwrapped = unwrapOption prop.PropertyType
175175
match tryCoerceValue jsonOptions unwrapped (box ff.Value) with
176176
| ValueNone -> filter
177-
| ValueSome coerced -> Equals ({ ff with Value = coerced :?> IComparable }, cmp)
177+
| ValueSome (:? IComparable as coerced) -> Equals ({ ff with Value = coerced }, cmp)
178+
| ValueSome _ -> filter
178179
| GreaterThan ff
179180
| GreaterThanOrEqual ff
180181
| LessThan ff
@@ -185,14 +186,15 @@ module TypeCoercion =
185186
let unwrapped = unwrapOption prop.PropertyType
186187
match tryCoerceValue jsonOptions unwrapped (box ff.Value) with
187188
| ValueNone -> filter
188-
| ValueSome coerced ->
189-
let coercedField = { ff with Value = coerced :?> IComparable }
189+
| ValueSome (:? IComparable as coerced) ->
190+
let coercedField = { ff with Value = coerced }
190191
match originalFilter with
191192
| GreaterThan _ -> GreaterThan coercedField
192193
| GreaterThanOrEqual _ -> GreaterThanOrEqual coercedField
193194
| LessThan _ -> LessThan coercedField
194195
| LessThanOrEqual _ -> LessThanOrEqual coercedField
195196
| _ -> filter
197+
| ValueSome _ -> filter
196198
| In ff ->
197199
match entityType.GetProperty (stripOperatorSuffix ff.FieldName, propertyBindFlags) with
198200
| null -> filter
@@ -224,7 +226,8 @@ module TypeCoercion =
224226
| ValueNone -> stringType
225227
match tryCoerceValue jsonOptions coercionTarget (box ff.Value) with
226228
| ValueNone -> filter
227-
| ValueSome coerced -> Contains ({ ff with Value = coerced :?> IComparable }, cmp)
229+
| ValueSome (:? IComparable as coerced) -> Contains ({ ff with Value = coerced }, cmp)
230+
| ValueSome _ -> filter
228231
| FilterField ff ->
229232
match entityType.GetProperty (ff.FieldName, propertyBindFlags) with
230233
| null -> filter

0 commit comments

Comments
 (0)