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

Fix result mapping string size in SQL Server string aggregate translator #29231

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

roji
Copy link
Member

@roji roji commented Sep 29, 2022

Fixes #29229

Description

When translating SQL Server aggregate string methods (string.Join, string.Concat), the maximum size for unicode/non-unicode strings is reversed, leading to an incorrect type mapping for the result

Customer impact

Reproducing an observable bug here isn't trivial (and may not be possible), since SqlServerStringTypeMapping has checks and doesn't take the incorrect size into account. However, the fix is trivial and ensures the correctness of the type mapping.

How found

Customer reported.

Regression

No, new feature (aggregate string function translation.

Testing

New testing added.

Risk

Very low; small self-evident fix in new code introduced for a new 7.0 feature only.

@roji roji requested a review from a team September 29, 2022 08:00
@@ -61,21 +61,21 @@ public class SqlServerStringAggregateMethodTranslator : IAggregateMethodCallTran
var resultTypeMapping = sqlExpression.TypeMapping;
if (resultTypeMapping?.Size != null)
{
if (resultTypeMapping.IsUnicode && resultTypeMapping.Size < 8000)
if (resultTypeMapping.IsUnicode && resultTypeMapping.Size < 4000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be <=

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if it's equal to 4000 (for unicode), it's OK to just retain the original mapping of the operand expression (assigned just above), bubbling it up, no?

@rbhanda rbhanda added this to the 7.0.0 milestone Sep 29, 2022
@roji roji merged commit b6ffd52 into dotnet:release/7.0 Sep 30, 2022
@roji roji deleted the StringSize branch September 30, 2022 07:32
@roji roji linked an issue Sep 30, 2022 that may be closed by this pull request
@ajcvickers ajcvickers removed this from the 7.0.0 milestone Oct 3, 2022
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.

SqlServerStringAggregateMethodTranslator.cs has Size backwards
3 participants