byte类型在条件中的解析BUG
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
Research direction
Start by searching the FreeSql query expression translation code for handling of Contains over byte arrays or byte-backed enums; the issue does not name a file or test. Reproduce with the supplied SQL Server example and compare ToSql() output with the expected IN lists; done when both enum and byte collections translate to numeric values while the reported scalar comparison and ToList behavior remain correct.
Written by the indexing model from the issue text.
Description
问题描述及重现代码:
byte类型以及基于byte的枚举,在Where条件中涉及枚举数组/集合时,解析错误
public class MyEntity
{
[Column(IsPrimary = true,IsNullable = false,IsIdentity = true)]
public int Id { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string Name { get; set; }
[Column(IsNullable = false)]
public byte Age { get; set; }
[Column(IsNullable = false, MapType = typeof(byte))]
public SomeType Type { get; set; }
[Column(CanUpdate = false, IsNullable = false)]
public DateTime Created { get; set; }
}
public enum SomeType : byte
{
A = 1,
B = 2,
C = 3,
D = 4,
}
SomeType[] types = [SomeType.A, SomeType.B];
byte[] ages = [18, 25];
string aaa = freeSql.Select<MyEntity>()
.Where(s => s.Id >= 1024)
.Where(s => types.Contains(s.Type))
.Where(s => ages.Contains(s.Age))
.ToSql();
以上示例解析的SQL为:
SELECT a.[Id], a.[Name], a.[Age], a.[Type], a.[Created]
FROM [MyEntity] a
WHERE (a.[Id] >= 1024) AND (((a.[Type]) in 0x0102)) AND (((a.[Age]) in 0x1219))
而预期的结果应该为:
SELECT a.[Id], a.[Name], a.[Age], a.[Type], a.[Created]
FROM [MyEntity] a
WHERE (a.[Id] >= 1024) AND (((a.[Type]) in(1,2))) AND (((a.[Age]) in (18,25)))
以上在ToList方法下映射表现正常;非数组/集合下正常(如: .Where(s => s.Type == SomeType.C))。
根据文档类型映射和型映射-maptype中,应该允许和支持byte相关使用。
数据库版本
Microsoft SQL Server 2022 (RTM-CU25) (KB5081477) - 16.0.4255.1 (X64)
安装的Nuget包
3.5.311
.net framework/. net core? 及具体版本
.NET 10.0.13
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 911
- Avg merge
- 12h 47m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnetcore/FreeSql
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
dotnetcore/FreeSql#2269 · 6 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
dotnetcore/FreeSql#2078 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
dotnetcore/FreeSql#2288 · 1 comment ·
-
NuGet 包是以 Debug 配置发布Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
dotnetcore/FreeSql#2287 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
dotnetcore/FreeSql#2281 ·
All issues in dotnetcore/FreeSql
Similar issues
-
area-multitenancy area-security p1-recommended priority-high technical-debt
Difficulty 2/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
help wanted needs-unity ready for a contributor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eyalgolan/statecraft-israel#1542 ·
Maintainers usually reply within 1 day
-
kind/enhancement Provider Upgrade pulumi/pulumi-azure R1 Task
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
pulumi/pulumi-azure#3669 ·
-
[BUG] FromCString causes 1 byte OOB read in native codePossibly taken A pull request linked to this issue is open or already merged. Opentype/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day