Skip to content

Commit bbf4d95

Browse files
authored
Trim the mapping store type base name (#30593)
Fixes #30592
1 parent 37a16e0 commit bbf4d95

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/EFCore.Relational/Storage/RelationalTypeMapping.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static string GetBaseName(string storeType)
298298
var openParen = storeType.IndexOf("(", StringComparison.Ordinal);
299299
if (openParen >= 0)
300300
{
301-
storeType = storeType[..openParen];
301+
storeType = storeType[..openParen].TrimEnd();
302302
}
303303

304304
return storeType;

test/EFCore.Relational.Tests/Storage/RelationalTypeMapperTest.cs

+15
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,21 @@ public void Does_type_mapping_from_decimal_type_with_configuration()
222222
Assert.False(mapping.IsFixedLength);
223223
}
224224

225+
[ConditionalFact]
226+
public void StoreTypeNameBase_is_trimmed()
227+
{
228+
var mapping = GetTypeMapping(
229+
typeof(string),
230+
storeTypeName: "ansi_string_fixed (666)",
231+
useConfiguration: true);
232+
233+
Assert.Equal("ansi_string_fixed (666)", mapping.StoreType);
234+
Assert.Equal("ansi_string_fixed", mapping.StoreTypeNameBase);
235+
Assert.Equal(666, mapping.Size);
236+
Assert.False(mapping.IsUnicode);
237+
Assert.False(mapping.IsFixedLength);
238+
}
239+
225240
protected override IRelationalTypeMappingSource CreateRelationalTypeMappingSource()
226241
=> new TestRelationalTypeMappingSource(
227242
TestServiceFactory.Instance.Create<TypeMappingSourceDependencies>(),

0 commit comments

Comments
 (0)