dotnetcore / dotnetcore/FreeSql

人大金仓KingbaseES,long? 插入了 0 而不是 NULL

Open
#2,206 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

#### 问题描述及重现代码:
v3.5.215 更新到 v3.5.305 后,人大金仓KingbaseES 数据库,值为 null 的 long? 属性,往数据库里插入了 0 而不是 NULL。
```c#
using FreeSql.DataAnnotations;

namespace ConsoleApp5
{
internal class Program
{
static void Main(string[] args)
{
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.KingbaseES, "Server=127.0.0.1;Port=54321;UID=qadmin;PWD=123456;database=qadmindemo")
.UseAutoSyncStructure(true)
.UseMonitorCommand(cmd => Console.WriteLine($"-- sql@{DateTime.Now:HH:mm:ss.fff} --\n{cmd.CommandText}\n---------\n"))
.Build();

fsql.Delete().Where("1=1").ExecuteAffrows();

var sourceEntity = new TestTb1();
fsql.Insert(sourceEntity).ExecuteAffrows(); // sourceEntity 的 LockLogId 为 null,但插入后数据库中 LockLogId 的值为 0

var insertedEntity = fsql.Select().First();

Console.WriteLine($"sourceEntity.LockLogId = {sourceEntity.LockLogId}");
Console.WriteLine($"insertedEntity.LockLogId = {insertedEntity.LockLogId}"); // 输出为 0

Console.ReadLine();
}
}

[Table(Name = "test_tb1")]
public partial class TestTb1
{
[Column(IsPrimary = true, IsIdentity = true)]
public long Id { get; set; }

public long? LockLogId { get; set; }
}
}
```

#### 数据库版本
KES V9

#### 安装的Nuget包
FreeSql.Provider.KingbaseES v3.5.305

#### .net framework/. net core? 及具体版本
.net8

v3.5.215 是好着的,v3.5.305 以及最新的 v3.5.306 均有问题。
另外:加上 `UseNoneCommandParameter(true)` 后则都没有问题,说明是参数化的问题。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.