Skip to content

Commit 6320a49

Browse files
Allow type change for static columns in CsvDataReader
Added logic to enable changing the DataType of static columns when setting a column type by name. Previously, only dynamic columns could have their type changed; now static columns are also supported.
1 parent ef6d31c commit 6320a49

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

project/dbatools/Csv/Reader/CsvDataReader.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3528,6 +3528,17 @@ public void SetColumnType(string columnName, Type type)
35283528
return;
35293529
}
35303530
}
3531+
3532+
// Also check static columns - they already have a type set, but allow changing it
3533+
for (int i = 0; i < _staticColumns.Count; i++)
3534+
{
3535+
if (string.Equals(_staticColumns[i].Name, columnName, StringComparison.OrdinalIgnoreCase))
3536+
{
3537+
_staticColumns[i].DataType = type;
3538+
return;
3539+
}
3540+
}
3541+
35313542
throw new ArgumentException($"Column '{columnName}' not found", nameof(columnName));
35323543
}
35333544

0 commit comments

Comments
 (0)