From 9489bc45644b243db42ef7ef2d1445460b07f817 Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Fri, 21 Apr 2023 18:37:22 +0800 Subject: [PATCH] Jet seems to output bytes only as an array. so a single byte becomes a byte[1] array. Return the first byte of that array in this instance --- src/EFCore.Jet.Data/JetDataReader.cs | 2 ++ .../EFCore.Jet.FunctionalTests/Query/InheritanceQueryJetTest.cs | 2 +- .../Query/NorthwindSelectQueryJetTest.cs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/EFCore.Jet.Data/JetDataReader.cs b/src/EFCore.Jet.Data/JetDataReader.cs index 6ec4683..74cf15f 100644 --- a/src/EFCore.Jet.Data/JetDataReader.cs +++ b/src/EFCore.Jet.Data/JetDataReader.cs @@ -93,6 +93,8 @@ namespace EntityFrameworkCore.Jet.Data if (value is byte byteValue) return byteValue; + if (value is byte[] byteArrayValue) + return byteArrayValue[0]; if (value is sbyte sbyteValue) return checked((byte)sbyteValue); if (value is short shortValue) diff --git a/test/EFCore.Jet.FunctionalTests/Query/InheritanceQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/InheritanceQueryJetTest.cs index 744564e..de78aed 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/InheritanceQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/InheritanceQueryJetTest.cs @@ -359,7 +359,7 @@ WHERE `a`.`Discriminator` = 'Kiwi'"); await base.Byte_enum_value_constant_used_in_projection(async); AssertSql( - @"SELECT IIF(`a`.`IsFlightless` = TRUE, 0, 1) + @"SELECT IIF(`a`.`IsFlightless` = TRUE, 0x00, 0x01) FROM `Animals` AS `a` WHERE `a`.`Discriminator` = 'Kiwi'"); } diff --git a/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs index 4e39cca..ed606a0 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs @@ -910,7 +910,7 @@ FROM `Orders` AS `o` await base.Select_byte_constant(isAsync); AssertSql( - $@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', 1, 2) + $@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', 0x01, 0x02) FROM `Customers` AS `c`"); }