dotnetcore / dotnetcore/FreeSql

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

Open
#2,112 2 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

数据库定义的字段类型为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: 你需要重写或转换表达式

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.