LockList locks resources in the db
(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator, lockPolicy schema.LockPolicy)
| 969 | |
| 970 | // LockList locks resources in the db |
| 971 | func (tx *Transaction) LockListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator, lockPolicy schema.LockPolicy) (list []*schema.Resource, total uint64, err error) { |
| 972 | defer tx.measureTime(time.Now(), s.ID, "lock_list") |
| 973 | |
| 974 | sc := lockListContextHelper(s, filter, options, pg, lockPolicy) |
| 975 | |
| 976 | sql, args, err := buildSelect(sc) |
| 977 | if err != nil { |
| 978 | return nil, 0, err |
| 979 | } |
| 980 | |
| 981 | if tx.db.sqlType == "mysql" { |
| 982 | sql += " FOR UPDATE" |
| 983 | } |
| 984 | |
| 985 | // update join for recursive |
| 986 | if options != nil { |
| 987 | sc.join = options.Details |
| 988 | } else { |
| 989 | sc.join = true |
| 990 | } |
| 991 | |
| 992 | return tx.executeSelect(ctx, sc, sql, args) |
| 993 | } |
| 994 | |
| 995 | func lockListContextHelper(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator, lockPolicy schema.LockPolicy) *selectContext { |
| 996 | policyJoin := shouldJoin(lockPolicy) |
no test coverage detected