-
Notifications
You must be signed in to change notification settings - Fork 186
Fix skiptoken paging edge case when combined with involving nullable datetime property #872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -266,7 +266,7 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| directionMap = new Dictionary<string, OrderByDirection>(); | ||
| } | ||
|
|
||
| IDictionary<string, Tuple<object, Type>> propertyValuePairs = PopulatePropertyValuePairs(skipTokenRawValue, context); | ||
| IDictionary<string, (object PropertyValue, Type PropertyType)> propertyValuePairs = PopulatePropertyValuePairs(skipTokenRawValue, context); | ||
|
|
||
| if (propertyValuePairs.Count == 0) | ||
| { | ||
|
|
@@ -286,14 +286,14 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| Expression lastEquality = null; | ||
| bool firstProperty = true; | ||
|
|
||
| foreach (KeyValuePair<string, Tuple<object, Type>> item in propertyValuePairs) | ||
| foreach (KeyValuePair<string, (object PropertyValue, Type PropertyType)> item in propertyValuePairs) | ||
| { | ||
| string key = item.Key; | ||
| MemberExpression property = Expression.Property(param, key); | ||
|
|
||
| object value = item.Value.Item1; | ||
| object value = item.Value.PropertyValue; | ||
|
|
||
| Type propertyType = item.Value.Item2 ?? value.GetType(); | ||
| Type propertyType = item.Value.PropertyType ?? value.GetType(); | ||
| bool propertyIsNullable = propertyType.IsNullable(); | ||
|
|
||
| Expression compare = null; | ||
|
|
@@ -305,6 +305,7 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| else if (value is ODataNullValue) | ||
| { | ||
| value = null; | ||
| propertyType = property.Type; | ||
| } | ||
|
|
||
| Expression constant = parameterizeConstant ? LinqParameterContainer.Parameterize(propertyType, value) : Expression.Constant(value); | ||
|
|
@@ -316,7 +317,7 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| binaryOperator: BinaryOperatorKind.LessThan, | ||
| left: property, | ||
| right: constant, | ||
| liftToNull: propertyIsNullable ? false : true, | ||
| liftToNull: !propertyIsNullable, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the meaning of this or why do we use the opposite of what the propertyIsNullable value is?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use in the BinaryExpression.IsLiftedToNull A lifted operator allows an operator on a non-nullable type to be used with the nullable equivalent as well. See example here. What we are doing here is setting |
||
| querySettings: querySettings); | ||
|
|
||
| if (propertyIsNullable && value != null) | ||
|
|
@@ -329,7 +330,7 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| Expression condition = ExpressionBinderHelper.CreateBinaryExpression( | ||
| binaryOperator: BinaryOperatorKind.Equal, | ||
| left: property, | ||
| right: parameterizeConstant ? LinqParameterContainer.Parameterize(propertyType, null) : Expression.Constant(null), | ||
| right: parameterizeConstant ? LinqParameterContainer.Parameterize(property.Type, null) : Expression.Constant(null), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You reset propertyType using why do you use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xuzhg Since the Edm doesn't support Now, when the value is of type
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ElizabethOkerio Use of |
||
| liftToNull: false, | ||
| querySettings: querySettings); | ||
|
|
||
|
|
@@ -364,7 +365,7 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| binaryOperator: BinaryOperatorKind.GreaterThan, | ||
| left: property, | ||
| right: constant, | ||
| liftToNull: propertyIsNullable ? false : true, | ||
| liftToNull: !propertyIsNullable, | ||
| querySettings: querySettings); | ||
| } | ||
| } | ||
|
|
@@ -375,7 +376,7 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| binaryOperator: BinaryOperatorKind.Equal, | ||
| left: property, | ||
| right: constant, | ||
| liftToNull: propertyIsNullable ? false : true, | ||
| liftToNull: !propertyIsNullable, | ||
| querySettings: querySettings); | ||
| where = compare; | ||
| firstProperty = false; | ||
|
|
@@ -390,7 +391,7 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| binaryOperator: BinaryOperatorKind.Equal, | ||
| left: property, | ||
| right: constant, | ||
| liftToNull: propertyIsNullable ? false : true, | ||
| liftToNull: !propertyIsNullable, | ||
| querySettings: querySettings)); | ||
| } | ||
| } | ||
|
|
@@ -405,11 +406,11 @@ private static IQueryable ApplyToCore(IQueryable query, ODataQuerySettings query | |
| /// <param name="value">The skiptoken string value.</param> | ||
| /// <param name="context">The <see cref="ODataQueryContext"/> which contains the <see cref="IEdmModel"/> and some type information</param> | ||
| /// <returns>Dictionary with property name and property value in the skiptoken value.</returns> | ||
| internal static IDictionary<string, Tuple<object, Type>> PopulatePropertyValuePairs(string value, ODataQueryContext context) | ||
| internal static IDictionary<string, (object PropertyValue, Type PropertyType)> PopulatePropertyValuePairs(string value, ODataQueryContext context) | ||
| { | ||
| Contract.Assert(context != null); | ||
|
|
||
| IDictionary<string, Tuple<object, Type>> propertyValuePairs = new Dictionary<string, Tuple<object, Type>>(); | ||
| IDictionary<string, (object PropertyValue, Type PropertyType)> propertyValuePairs = new Dictionary<string, (object PropertyValue, Type PropertyType)>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KenitoInc |
||
| IList<string> keyValuesPairs = ParseValue(value, CommaDelimiter); | ||
|
|
||
| IEdmStructuredType type = context.ElementType as IEdmStructuredType; | ||
|
|
@@ -432,7 +433,7 @@ internal static IDictionary<string, Tuple<object, Type>> PopulatePropertyValuePa | |
| } | ||
|
|
||
| propValue = ODataUriUtils.ConvertFromUriLiteral(pieces[1], ODataVersion.V401, context.Model, propertyType); | ||
| propertyValuePairs.Add(pieces[0], Tuple.Create(propValue, propertyClrType)); | ||
| propertyValuePairs.Add(pieces[0], (propValue, propertyClrType)); | ||
| } | ||
| else | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.