Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into production [no deploy]
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszgryglicki committed May 18, 2018
2 parents f0d5a7a + ae3012b commit c9f0750
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pg_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,15 @@ func WriteTSPoints(ctx *Ctx, con *sql.DB, pts *TSPoints, mergeSeries string, mut
}
namesUA := strings.Join(namesU, ", ")
argsUA := strings.Join(argsU, ", ")
if len(namesU) > 1 {
namesUA = "(" + namesUA + ")"
argsUA = "(" + argsUA + ")"
}
argT := "$" + strconv.Itoa(i)
vals = append(vals, p.t)
q := fmt.Sprintf(
"insert into \"%[1]s\"("+namesIA+") values("+argsIA+") "+
"on conflict(time) do update set ("+namesUA+") = ("+argsUA+") "+
"on conflict(time) do update set "+namesUA+" = "+argsUA+" "+
"where \"%[1]s\".time = "+argT,
name,
)
Expand Down Expand Up @@ -374,13 +378,17 @@ func WriteTSPoints(ctx *Ctx, con *sql.DB, pts *TSPoints, mergeSeries string, mut
}
namesUA := strings.Join(namesU, ", ")
argsUA := strings.Join(argsU, ", ")
if len(namesU) > 1 {
namesUA = "(" + namesUA + ")"
argsUA = "(" + argsUA + ")"
}
argT := "$" + strconv.Itoa(i)
argP := "$" + strconv.Itoa(i+1)
vals = append(vals, p.t)
vals = append(vals, p.period)
q := fmt.Sprintf(
"insert into \"%[1]s\"("+namesIA+") values("+argsIA+") "+
"on conflict(time, period) do update set ("+namesUA+") = ("+argsUA+") "+
"on conflict(time, period) do update set "+namesUA+" = "+argsUA+" "+
"where \"%[1]s\".time = "+argT+" and \"%[1]s\".period = "+argP,
name,
)
Expand Down Expand Up @@ -410,6 +418,10 @@ func WriteTSPoints(ctx *Ctx, con *sql.DB, pts *TSPoints, mergeSeries string, mut
}
namesUA := strings.Join(namesU, ", ")
argsUA := strings.Join(argsU, ", ")
if len(namesU) > 1 {
namesUA = "(" + namesUA + ")"
argsUA = "(" + argsUA + ")"
}
argT := "$" + strconv.Itoa(i)
argP := "$" + strconv.Itoa(i+1)
argS := "$" + strconv.Itoa(i+2)
Expand All @@ -418,7 +430,7 @@ func WriteTSPoints(ctx *Ctx, con *sql.DB, pts *TSPoints, mergeSeries string, mut
vals = append(vals, p.name)
q := fmt.Sprintf(
"insert into \"%[1]s\"("+namesIA+") values("+argsIA+") "+
"on conflict(time, series, period) do update set ("+namesUA+") = ("+argsUA+") "+
"on conflict(time, series, period) do update set "+namesUA+" = "+argsUA+" "+
"where \"%[1]s\".time = "+argT+" and \"%[1]s\".period = "+argP+" and \"%[1]s\".series = "+argS,
mergeS,
)
Expand Down

0 comments on commit c9f0750

Please sign in to comment.