Skip to content

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

@munanwang

Description

@munanwang

问题描述及重现代码:

v3.5.215 更新到 v3.5.305 后,人大金仓KingbaseES 数据库,值为 null 的 long? 属性,往数据库里插入了 0 而不是 NULL。

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<TestTb1>().Where("1=1").ExecuteAffrows();

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

            var insertedEntity = fsql.Select<TestTb1>().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) 后则都没有问题,说明是参数化的问题。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions