Please clearly describe what the SQL Sink is doing incorrectly:
When you have a NVarChar column with max length of 1, it will incorrectly truncate the value to an empty string.
This was first introduced in v6.4.0 with this PR: #490
Please clearly describe the expected behavior:
Values less than the max length shouldn't have to be truncated, and the full value should be stored.
List the names and versions of all Serilog packages used in the project:
Serilog: 3.1.1
Serilog.Sinks.MSSqlServer: 6.5.0
Target framework and operating system:
.NET 7
Windows 11
Provide a simple reproduction of your Serilog configuration code:
var sinkOpts = new MSSqlServerSinkOptions() {
TableName = "Logs"
};
var columnOpts = new ColumnOptions() {
AdditionalColumns = new SqlColumn[]
{
new SqlColumn("TestColumn", SqlDbType.NVarChar, allowNull: false, dataLength: 1)
}
};
var log = new LoggerConfiguration()
.WriteTo.MSSqlServer(
connectionString: "NOT_RELEVANT_HERE",
sinkOptions: sinkOpts,
columnOptions: columnOpts
).CreateLogger();
When you have a NVarChar column with max length of 1, it will incorrectly truncate the value to an empty string. This was first introduced in v6.4.0 with this PR: #490
Values less than the max length shouldn't have to be truncated, and the full value should be stored.
.NET 7 Windows 11