Skip to content

Commit 5506372

Browse files
committed
firewalldb: remove unnecessary SQL query executions
As the privacy mapper SQL table defines constraints that ensure no duplicate real nor pseudo values can be set for the same session group, we can remove two query executions that were previously used to check that uniqueness manually before inserting a new privacy pair.
1 parent a4fc12e commit 5506372

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

firewalldb/privacy_mapper_sql.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,6 @@ func (p *privacyMapSQLTx) NewPair(ctx context.Context, real,
5555
return err
5656
}
5757

58-
_, err = p.queries.GetPseudoForReal(ctx, sqlc.GetPseudoForRealParams{
59-
GroupID: groupID,
60-
RealVal: real,
61-
})
62-
if err == nil {
63-
return ErrDuplicateRealValue
64-
} else if !errors.Is(err, sql.ErrNoRows) {
65-
return err
66-
}
67-
68-
_, err = p.queries.GetRealForPseudo(ctx, sqlc.GetRealForPseudoParams{
69-
GroupID: groupID,
70-
PseudoVal: pseudo,
71-
})
72-
if err == nil {
73-
return ErrDuplicatePseudoValue
74-
} else if !errors.Is(err, sql.ErrNoRows) {
75-
return err
76-
}
77-
7858
return p.queries.InsertPrivacyPair(ctx, sqlc.InsertPrivacyPairParams{
7959
GroupID: groupID,
8060
RealVal: real,

0 commit comments

Comments
 (0)