Skip to content

pg数据库使用insertorupdate的mergeinto语法异常 #2112

@AN-535

Description

@AN-535

数据库定义的字段类型为date,c#定义为DateTime,生成的sql为:
MERGE INTO "info" t1 USING (
SELECT
'a0f77f87-67fa-4d56-bd4c-8e8cbad9ddf6' AS "id",
'2025-10-07 00:00:00.000000' AS "birth_day") t2 ON (t1."id" = t2."id")
WHEN MATCHED THEN
UPDATE
SET
"birth_day" = t2."birth_day"
WHEN NOT MATCHED THEN
INSERT ("id", "birth_day")
VALUES
(
t2."id",
t2."birth_day");
执行会报错:
错误: 字段 "birth_day" 的类型为 date, 但表达式的类型为 text
"birth_day" = t2."birth_day",
^
HINT: 你需要重写或转换表达式

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