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

SqlServerStringAggregateMethodTranslator.cs has Size backwards #29229

Closed
timschwallie opened this issue Sep 29, 2022 · 0 comments · Fixed by #29231
Closed

SqlServerStringAggregateMethodTranslator.cs has Size backwards #29229

timschwallie opened this issue Sep 29, 2022 · 0 comments · Fixed by #29231
Assignees
Labels
area-query area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@timschwallie
Copy link

File a bug

If it's unicode the size should be 4000.
This seems to set the size to 8000.
If it's not Unicode, the size should be 8000.
This code below appears to set the size to 4000.

    // STRING_AGG enlarges the return type size (e.g. for input VARCHAR(5), it returns VARCHAR(8000)).
    // See https://docs.microsoft.com/sql/t-sql/functions/string-agg-transact-sql#return-types
    var resultTypeMapping = sqlExpression.TypeMapping;
    if (resultTypeMapping?.Size != null)
    {
        if (**resultTypeMapping.IsUnicode** && resultTypeMapping.Size < 8000)
        {
            resultTypeMapping = _typeMappingSource.FindMapping(
                typeof(string),
                resultTypeMapping.StoreTypeNameBase,
                unicode: true,
                size: 8000);
        }
        else if (**!resultTypeMapping.IsUnicode** && resultTypeMapping.Size < 4000)
        {
            resultTypeMapping = _typeMappingSource.FindMapping(
                typeof(string),
                resultTypeMapping.StoreTypeNameBase,
                unicode: false,
                size: 4000);
        }
    }
@roji roji self-assigned this Sep 29, 2022
@roji roji added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels Sep 29, 2022
@roji roji added this to the 7.0.0 milestone Sep 30, 2022
@roji roji added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. area-sqlserver area-query labels Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants