From a1e5fd8d9545d176c899e8e9155a72633bcaffe2 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 25 Apr 2024 12:42:11 -0400 Subject: [PATCH] Add insertlog query --- pkg/mls/store/queries.sql | 5 +++++ pkg/mls/store/queries/db.go | 2 +- pkg/mls/store/queries/models.go | 2 +- pkg/mls/store/queries/queries.sql.go | 32 +++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/pkg/mls/store/queries.sql b/pkg/mls/store/queries.sql index 76bc1375..57b697c9 100644 --- a/pkg/mls/store/queries.sql +++ b/pkg/mls/store/queries.sql @@ -31,6 +31,11 @@ INNER JOIN ( address ) b ON a.address = b.address AND a.association_sequence_id = b.max_association_sequence_id; +-- name: InsertAddressLog :one +INSERT INTO address_log (address, inbox_id, association_sequence_id, revocation_sequence_id) +VALUES ($1, $2, $3, $4) +RETURNING *; + -- name: InsertInboxLog :one INSERT INTO inbox_log (inbox_id, server_timestamp_ns, identity_update_proto) VALUES ($1, $2, $3) diff --git a/pkg/mls/store/queries/db.go b/pkg/mls/store/queries/db.go index fa785733..ef8b0c29 100644 --- a/pkg/mls/store/queries/db.go +++ b/pkg/mls/store/queries/db.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 package queries diff --git a/pkg/mls/store/queries/models.go b/pkg/mls/store/queries/models.go index cc2ae9d3..711ac5b8 100644 --- a/pkg/mls/store/queries/models.go +++ b/pkg/mls/store/queries/models.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 package queries diff --git a/pkg/mls/store/queries/queries.sql.go b/pkg/mls/store/queries/queries.sql.go index b2ef7b4d..acbdcebb 100644 --- a/pkg/mls/store/queries/queries.sql.go +++ b/pkg/mls/store/queries/queries.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 // source: queries.sql package queries @@ -237,6 +237,36 @@ func (q *Queries) GetInboxLogFiltered(ctx context.Context, filters json.RawMessa return items, nil } +const insertAddressLog = `-- name: InsertAddressLog :one +INSERT INTO address_log (address, inbox_id, association_sequence_id, revocation_sequence_id) +VALUES ($1, $2, $3, $4) +RETURNING address, inbox_id, association_sequence_id, revocation_sequence_id +` + +type InsertAddressLogParams struct { + Address string + InboxID string + AssociationSequenceID sql.NullInt64 + RevocationSequenceID sql.NullInt64 +} + +func (q *Queries) InsertAddressLog(ctx context.Context, arg InsertAddressLogParams) (AddressLog, error) { + row := q.db.QueryRowContext(ctx, insertAddressLog, + arg.Address, + arg.InboxID, + arg.AssociationSequenceID, + arg.RevocationSequenceID, + ) + var i AddressLog + err := row.Scan( + &i.Address, + &i.InboxID, + &i.AssociationSequenceID, + &i.RevocationSequenceID, + ) + return i, err +} + const insertGroupMessage = `-- name: InsertGroupMessage :one INSERT INTO group_messages (group_id, data, group_id_data_hash) VALUES ($1, $2, $3)