Improve SQL sanitization

This commit is contained in:
Deluan 2024-09-09 19:45:02 -04:00
parent d3bb4bb9a1
commit 3107170afd
23 changed files with 259 additions and 159 deletions

View file

@ -15,17 +15,15 @@ import (
type radioRepository struct {
sqlRepository
sqlRestful
}
func NewRadioRepository(ctx context.Context, db dbx.Builder) model.RadioRepository {
r := &radioRepository{}
r.ctx = ctx
r.db = db
r.tableName = "radio"
r.filterMappings = map[string]filterFunc{
r.registerModel(&model.Radio{}, map[string]filterFunc{
"name": containsFilter("name"),
}
})
r.sortMappings = map[string]string{
"name": "(name collate nocase), name",
}
@ -96,7 +94,7 @@ func (r *radioRepository) Put(radio *model.Radio) error {
}
func (r *radioRepository) Count(options ...rest.QueryOptions) (int64, error) {
return r.CountAll(r.parseRestOptions(options...))
return r.CountAll(r.parseRestOptions(r.ctx, options...))
}
func (r *radioRepository) EntityName() string {
@ -112,7 +110,7 @@ func (r *radioRepository) Read(id string) (interface{}, error) {
}
func (r *radioRepository) ReadAll(options ...rest.QueryOptions) (interface{}, error) {
return r.GetAll(r.parseRestOptions(options...))
return r.GetAll(r.parseRestOptions(r.ctx, options...))
}
func (r *radioRepository) Save(entity interface{}) (string, error) {