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

Trim the mapping store type base name #30593

Merged
1 commit merged into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EFCore.Relational/Storage/RelationalTypeMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static string GetBaseName(string storeType)
var openParen = storeType.IndexOf("(", StringComparison.Ordinal);
if (openParen >= 0)
{
storeType = storeType[..openParen];
storeType = storeType[..openParen].TrimEnd();
}

return storeType;
Expand Down
15 changes: 15 additions & 0 deletions test/EFCore.Relational.Tests/Storage/RelationalTypeMapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,21 @@ public void Does_type_mapping_from_decimal_type_with_configuration()
Assert.False(mapping.IsFixedLength);
}

[ConditionalFact]
public void StoreTypeNameBase_is_trimmed()
{
var mapping = GetTypeMapping(
typeof(string),
storeTypeName: "ansi_string_fixed (666)",
useConfiguration: true);

Assert.Equal("ansi_string_fixed (666)", mapping.StoreType);
Assert.Equal("ansi_string_fixed", mapping.StoreTypeNameBase);
Assert.Equal(666, mapping.Size);
Assert.False(mapping.IsUnicode);
Assert.False(mapping.IsFixedLength);
}

protected override IRelationalTypeMappingSource CreateRelationalTypeMappingSource()
=> new TestRelationalTypeMappingSource(
TestServiceFactory.Instance.Create<TypeMappingSourceDependencies>(),
Expand Down