Skip to content

Commit

Permalink
Update "write" function to work with pgx4 and higher
Browse files Browse the repository at this point in the history
Remove parameterOIDs and resultFormatCodes.

jackc/pgx#571 (comment)
  • Loading branch information
hlcianfagna authored and amotl committed Dec 27, 2023
1 parent 2f98328 commit b36cb38
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions crate.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,14 @@ func (c crateEndpoint) write(ctx context.Context, r *crateWriteRequest) error {
for _, a := range r.rows {
batch.Queue(
"write_statement",
[]interface{}{
a.labels,
a.labelsHash,
// TODO: Find non-string way of encoding timestamps.
a.timestamp.Format("2006-01-02 15:04:05.000-07"),
a.value,
a.valueRaw,
},
[]pgtype.OID{
pgtype.JSONOID,
pgtype.VarcharOID,
pgtype.TimestamptzOID,
pgtype.Float8OID,
pgtype.Int8OID,
},
nil,
a.labels,
a.labelsHash,
// TODO: Find non-string way of encoding timestamps.
// Maybe it is more efficient to submit timestamp as Unixtime,
// instead of converting it into a string?
a.timestamp.Format("2006-01-02 15:04:05.000-07"),
a.value,
a.valueRaw,
)
}

Expand Down

0 comments on commit b36cb38

Please sign in to comment.