Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/FirebirdSql.Data.FirebirdClient.Tests/FbDataReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,22 @@ public async Task GetFieldValueTest()
await transaction.RollbackAsync();
}
}

[Test]
public async Task GetFieldTypeMatchesGetValueForOctetsTest()
{
// IDataRecord.GetFieldType: "the type of Object that would be returned from GetValue."
await using (var command = new FbCommand("select cast('ab' as varchar(10) character set octets), cast('ab' as char(4) character set octets) from rdb$database", Connection))
{
await using (var reader = await command.ExecuteReaderAsync())
{
Assert.IsTrue(await reader.ReadAsync());
for (var i = 0; i < reader.FieldCount; i++)
{
Assert.AreEqual(typeof(byte[]), reader.GetValue(i).GetType());
Assert.AreEqual(typeof(byte[]), reader.GetFieldType(i));
}
}
}
}
}
6 changes: 6 additions & 0 deletions src/FirebirdSql.Data.FirebirdClient/Common/DbField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ public void FixNull()

public Type GetSystemType()
{
// SetValue stores CHAR and VARCHAR in the OCTETS character set as byte[], so that is the type GetValue returns.
if ((SqlType == IscCodes.SQL_TEXT || SqlType == IscCodes.SQL_VARYING) && (Charset?.IsOctetsCharset ?? false) && DbDataType != DbDataType.Guid)
{
return typeof(byte[]);
}

return TypeHelper.GetTypeFromDbDataType(DbDataType);
}

Expand Down