I am doing this:
Note : Request is generated with squirrel
// Prepare query
qb := sq.Update(d.table).
SetMap(updates).
Where(filter).
PlaceholderFormat(sq.Dollar)
// Build sql query
q, args, err := qb.ToSql()
if err != nil {
return fmt.Errorf("postgresql: unable to build query: %w", err)
}
fmt.Println(q, args)
// Prepare the statement
stmt, err := d.session.PreparexContext(ctx, q)
if err != nil {
return fmt.Errorf("postgresql: unable to prepare query: %w", err)
}
// Do the insert query
res, err := stmt.ExecContext(ctx, args...)
if err != nil {
return fmt.Errorf("postgresql: unable to execute query: %w", err)
}
With this data :
// Updates
updates := map[string]interface{}{
"acknowledgment_duration": obj.AcknowledgmentDuration,
}
type sqlIssue struct {
...
AcknowledgmentDuration int `db:"acknowledgment_duration"`
I am sure that the value is not 0 when I print it I got the right value, the SQL request is good when I print it, but whatever I try the value in Postgress stays at "0". It is not being updated, nor created with the right value.
The generated SQL request is :
UPDATE issues SET ..................., acknowledgment_duration = $9, .......... WHERE id = $14 [ ......... 10000000000 ..... ]
SQL table is :
-- +migrate Up
CREATE TABLE issues (
...
acknowledgment_duration BIGINT,
Am I missing something?
If I perform the request myself into the database with a too such as Adminer, it is working. So it must be inside my Go code I guess.
question from:
https://stackoverflow.com/questions/65858504/postgres-bigint-value-not-being-created-or-updated 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…