Skip to content
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

[3.1] Fix to #19128 - Query: Error for queries with enum parameters whose value is of underlying type but the value expected by type mapping is the actual enum type #20365

Merged
merged 2 commits into from
Apr 4, 2020

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Mar 20, 2020

Description
Problem was that we were not correctly compensating for type differences between parameter value and the DbParameter type (determined from type mapping). This can happen when the parameter is explicitly typed as the underlying type, but in the query the type is inferred from other side of binary expression etc.

Fix is to detect the case when expected parameter value is Enum, but the actual type is the underlying type and convert the value back to the enum type, just like we do for constants.

Customer Impact
Error for some queries using enum parameters. There are several workarounds, depending on which "flavor" of the issue customer experiences, but it is hard to understand which workaround works for which case.

How found
Reported by multiple customers.

Test coverage
We have added test to cover this scenario.

Regression?
No.

Risk
Low. Fix only affects queries with enums, also the logic in the fix has already been used for case with constants. Fix applies the same logic to parameters.

@maumar maumar requested a review from ajcvickers March 20, 2020 21:48
@maumar maumar added this to the 3.1.x milestone Mar 20, 2020
@ajcvickers ajcvickers modified the milestones: 3.1.x, 3.1.4 Mar 24, 2020
@bricelam bricelam changed the base branch from release/3.1.4 to release/3.1 March 30, 2020 18:34
maumar and others added 2 commits April 4, 2020 13:15
…alue is of underlying type but the value expected by type mapping is the actual enum type

Problem was that we were not correctly compensating for type differences between parameter value and the DbParameter type (determined from type mapping). This can happen when the parameter is explicitly typed as the underlying type, but in the query the type is inferred from other side of binary expression etc.

Fix is to detect the case when expected parameter value is Enum, but the actual type is the underlying type and convert the value back to the enum type, just like we do for constants.
@ajcvickers ajcvickers merged commit aa9e1fe into release/3.1 Apr 4, 2020
@ajcvickers ajcvickers deleted the fix19128_31 branch April 4, 2020 20:34
@ajcvickers ajcvickers removed this from the 3.1.4 milestone Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants