Skip to content

Commit

Permalink
specify tables (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Mar 30, 2024
1 parent 09ae822 commit 211c81a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,12 @@ func (a *bunAdapter) UpdateFilteredPolicies(sec string, ptype string, newRules [
return nil, err
}

oldPolicies := make([]CasbinPolicy, 0)
selectQuery := tx.NewSelect().
Model(&oldPolicies).
Where("ptype = ?", ptype)
deleteQuery := tx.NewDelete().
Model((*CasbinPolicy)(nil)).
Where("ptype = ?", ptype)

// Note that empty string in fieldValues could be any word.
Expand Down Expand Up @@ -488,8 +491,7 @@ func (a *bunAdapter) UpdateFilteredPolicies(sec string, ptype string, newRules [
}

// store old policies
oldPolicies := make([]CasbinPolicy, 0)
if err := selectQuery.Scan(context.Background(), &oldPolicies); err != nil {
if err := selectQuery.Scan(context.Background()); err != nil {
if err := tx.Rollback(); err != nil {
return nil, err
}
Expand Down

0 comments on commit 211c81a

Please sign in to comment.