Skip to content

自定义驱动使用gorm更新数据时报错 sql: expected 0 arguments, got 2 #7447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kyour-cn opened this issue May 9, 2025 · 1 comment
Assignees
Labels
type:question general questions

Comments

@kyour-cn
Copy link

kyour-cn commented May 9, 2025

Your Question

使用gorm更新数据时报错 sql: expected 0 arguments, got 2

参考文档写的,并且各个AI都没有发现问题所在

The document you expected this should be explained

Expected answer

gorm.io/gorm v1.26.1

result := erpDb.Table(g.orderTableName).
    Where("order_no = ? AND order_status <> 2", orderNo).
    Update("order_status", status)
if result.Error != nil {
    slog.Error("更新ERP订单状态异常: " + result.Error.Error())
    return result.Error
}

但是日志中可见sql都是正确的
2025-05-09 14:17:55 DEBUG E:/Project/Go/b2b_sync_next/internal/task/task_order.go:111 sql: expected 0 arguments, got 2
[0.504ms] [rows:0] UPDATE "sync_order" SET "order_status"=3 WHERE order_no = '25032611090764727001' AND order_status <> 2

@kyour-cn kyour-cn added the type:question general questions label May 9, 2025
@kyour-cn
Copy link
Author

kyour-cn commented May 9, 2025

使用的自定义驱动,ODBC连接的sqlserver

@kyour-cn kyour-cn changed the title 使用gorm更新数据时报错 sql: expected 0 arguments, got 2 自定义驱动使用gorm更新数据时报错 sql: expected 0 arguments, got 2 May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question general questions
Projects
None yet
Development

No branches or pull requests

2 participants