mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-07 06:42:15 +00:00
feat(database): add row locking options for queries (#10990)
Introduce options to lock rows returned by queries, allowing for more controlled transaction handling. This includes support for different lock modes such as "FOR UPDATE," "FOR NO KEY UPDATE," and "FOR SHARE." ## Additional information - closes https://github.com/zitadel/zitadel/issues/10930 - closes https://github.com/zitadel/zitadel/issues/10675
This commit is contained in:
@@ -114,6 +114,16 @@ func TestQueryOptions(t *testing.T) {
|
||||
args: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with lock",
|
||||
options: []QueryOption{
|
||||
WithResultLock(),
|
||||
},
|
||||
want: want{
|
||||
stmt: " FOR UPDATE",
|
||||
args: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "multiple options",
|
||||
options: []QueryOption{
|
||||
@@ -122,9 +132,10 @@ func TestQueryOptions(t *testing.T) {
|
||||
WithOrderByDescending(NewColumn("table", "column")),
|
||||
WithLimit(10),
|
||||
WithOffset(5),
|
||||
WithResultLock(),
|
||||
},
|
||||
want: want{
|
||||
stmt: " LEFT JOIN other_table ON table.id = other_table.table_id WHERE table.column = $1 ORDER BY table.column DESC LIMIT $2 OFFSET $3",
|
||||
stmt: " LEFT JOIN other_table ON table.id = other_table.table_id WHERE table.column = $1 ORDER BY table.column DESC LIMIT $2 OFFSET $3 FOR UPDATE",
|
||||
args: []any{123, uint32(10), uint32(5)},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user