Skip to content

unable to form bulk upsert query #722

@lenonqing

Description

@lenonqing

in v 1.3.3

query := "INSERT INTO TABLE_VALUES (`tid`, `uid`, `count`, `deposit`, `ver`) VALUES (:tid, :uid, :count, :deposit, :ver) ON DUPLICATE KEY UPDATE `tid`=VALUES(`tid`), `uid`=VALUES(`uid`), `count`=VALUES(`count`), `deposit`=VALUES(`deposit`), `ver`=VALUES(`ver`)"
args := []map[string]interface{}{
        {"tid": 1, "uid": 1, "count": 1, "deposit": 0, "ver": 0},
        {"tid": 2, "uid": 1, "count": 1, "deposit": 0, "ver": 0},
    }
query, argsOut, err := sqlx.Named(query, args)
_, err = db.ExecContext(ctx, query, argsOut...)

got sql: expected 5 arguments, got 10 error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions