Skip to content

Commit eec58f6

Browse files
Fix the Dollar prefixed columns during serialization
1 parent 74e4320 commit eec58f6

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/Core/Services/MetadataProviders/Converters/DatabaseObjectConverter.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ public override DatabaseObject Read(ref Utf8JsonReader reader, Type typeToConver
3131

3232
DatabaseObject objA = (DatabaseObject)JsonSerializer.Deserialize(document, concreteType, options)!;
3333

34-
foreach (PropertyInfo prop in objA.GetType().GetProperties())
34+
foreach (PropertyInfo prop in objA.GetType().GetProperties().Where(IsSourceDefinitionProperty))
3535
{
36-
if (IsSourceDefinitionProperty(prop))
36+
SourceDefinition? sourceDef = (SourceDefinition?)prop.GetValue(objA);
37+
if (sourceDef is not null)
3738
{
38-
SourceDefinition? sourceDef = (SourceDefinition?)prop.GetValue(objA);
39-
if (sourceDef is not null)
40-
{
41-
UnescapeDollaredColumns(sourceDef);
42-
}
39+
UnescapeDollaredColumns(sourceDef);
4340
}
4441
}
4542

@@ -75,7 +72,8 @@ public override void Write(Utf8JsonWriter writer, DatabaseObject value, JsonSeri
7572
object? propVal = prop.GetValue(value);
7673
Type propType = prop.PropertyType;
7774

78-
// enforcing that we only escape columns for properties whose type is exactly SourceDefinition(DatabaseTables)
75+
// Only escape columns for properties whose type is exactly SourceDefinition (not subclasses).
76+
// This is because, we do not want unnecessary mutation of subclasses of SourceDefinition unless needed.
7977
if (IsSourceDefinitionProperty(prop) && propVal is SourceDefinition sourceDef && propVal.GetType() == typeof(SourceDefinition))
8078
{
8179
EscapeDollaredColumns(sourceDef);

0 commit comments

Comments
 (0)