Skip to content

Commit 9ec0d37

Browse files
committed
fixed nullable byte arrays
1 parent 9d3f68c commit 9ec0d37

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

nuget/Sqlite_net.SourceGenerator/SQLiteFastColumnSetterGenerator.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,14 @@ static void GeneratePropertySetter(string typedObject, StringBuilder sb, Propert
409409
if (isNullable)
410410
propertyType = propertyType.Replace("?", "");
411411

412+
switch (propertyType) {
413+
case "byte[]":
414+
case "Byte[]":
415+
case "System.Byte[]":
416+
isNullable = true; // need to handle nullable for byte arrays
417+
break;
418+
}
419+
412420
if (isNullable) {
413421
sb.AppendLine($" if (SQLite3.ColumnType(stmt, index) != SQLite3.ColType.Null)");
414422
sb.AppendLine($" {{");
@@ -487,7 +495,9 @@ static void GeneratePropertySetter(string typedObject, StringBuilder sb, Propert
487495
break;
488496

489497
case "byte[]":
490-
sb.AppendLine($" {typedObject}.{property.PropertyName} = SQLite3.ColumnByteArray(stmt, index);");
498+
case "Byte[]":
499+
case "System.Byte[]":
500+
sb.AppendLine($" {typedObject}.{property.PropertyName} = SQLite3.ColumnByteArray(stmt, index);");
491501
break;
492502

493503
default:

0 commit comments

Comments
 (0)