diff --git a/join.go b/join.go index 29fa0e6..3a0327c 100644 --- a/join.go +++ b/join.go @@ -121,7 +121,6 @@ func joinScope(relationName string, rel *schema.Relationship, fields []string, b } func join(tx *gorm.DB, joinName string, sch *schema.Schema) *gorm.DB { - var lastTable string var relation *schema.Relationship joins := make([]clause.Join, 0, strings.Count(joinName, ".")+1) diff --git a/search.go b/search.go index fb6b8cb..69e5c2b 100644 --- a/search.go +++ b/search.go @@ -26,7 +26,6 @@ func (s *Search) Scope(schema *schema.Schema) func(*gorm.DB) *gorm.DB { searchQuery := tx.Session(&gorm.Session{NewDB: true}) for _, field := range s.Fields { - f, sch, joinName := getField(field, schema, nil) if f == nil { continue diff --git a/settings.go b/settings.go index 268b09b..9560936 100644 --- a/settings.go +++ b/settings.go @@ -142,7 +142,6 @@ func ScopeUnpaginated[T any](db *gorm.DB, request *Request, dest *[]T) *gorm.DB // and process pagination. Returns the resulting `*database.Paginator`. // The given request is expected to be validated using `ApplyValidation`. func (s *Settings[T]) Scope(db *gorm.DB, request *Request, dest *[]T) (*database.Paginator[T], error) { - page := request.Page.Default(1) pageSize := request.PerPage.Default(DefaultPageSize) @@ -356,7 +355,6 @@ func getSelectableFields(blacklist *Blacklist, sch *schema.Schema) []*schema.Fie func selectScope(table string, fields []*schema.Field, override bool) func(*gorm.DB) *gorm.DB { return func(tx *gorm.DB) *gorm.DB { - if fields == nil { return tx } diff --git a/settings_test.go b/settings_test.go index 5e73306..d3775e9 100644 --- a/settings_test.go +++ b/settings_test.go @@ -2073,13 +2073,11 @@ func TestNewRequest(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.desc, func(t *testing.T) { request := NewRequest(c.query) assert.Equal(t, c.want, request) }) } - } func TestScopeWithCaseInsensitiveSort(t *testing.T) { diff --git a/util_test.go b/util_test.go index 87cf936..fb63713 100644 --- a/util_test.go +++ b/util_test.go @@ -225,7 +225,6 @@ func TestConvertToSafeType(t *testing.T) { } for _, c := range cases { - c := c t.Run(fmt.Sprintf("%s_%s", c.value, c.dataType), func(t *testing.T) { val, ok := ConvertToSafeType(c.value, c.dataType) assert.Equal(t, c.want, val) @@ -235,7 +234,6 @@ func TestConvertToSafeType(t *testing.T) { } func TestConvertArgsToSafeType(t *testing.T) { - // No need for exhaustive testing here since it's already done by TestConvertToSafeType cases := []struct { want any @@ -249,7 +247,6 @@ func TestConvertArgsToSafeType(t *testing.T) { } for _, c := range cases { - c := c t.Run(fmt.Sprintf("%s_%s", c.value, c.dataType), func(t *testing.T) { val, ok := ConvertArgsToSafeType(c.value, c.dataType) assert.Equal(t, c.want, val) @@ -384,7 +381,6 @@ func TestGetDataType(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.desc, func(t *testing.T) { model, err := parseModel(openDryRunDB(t), c.model) if !assert.NoError(t, err) { diff --git a/validation_test.go b/validation_test.go index 5cc090c..cfdee57 100644 --- a/validation_test.go +++ b/validation_test.go @@ -169,7 +169,6 @@ func TestParseJoin(t *testing.T) { } func TestValidateFilter(t *testing.T) { - t.Run("Constructor", func(t *testing.T) { v := &FilterValidator{} assert.NotNil(t, v) @@ -233,7 +232,6 @@ func TestValidateFilter(t *testing.T) { } for _, c := range cases { - c := c t.Run(fmt.Sprintf("Validate_%v_%t", c.value, c.want), func(t *testing.T) { v := &FilterValidator{Or: c.or} ctx := &validation.Context{ @@ -248,7 +246,6 @@ func TestValidateFilter(t *testing.T) { } func TestValidateSort(t *testing.T) { - t.Run("Constructor", func(t *testing.T) { v := &SortValidator{} assert.NotNil(t, v) @@ -305,7 +302,6 @@ func TestValidateSort(t *testing.T) { } for _, c := range cases { - c := c t.Run(fmt.Sprintf("Validate_%v_%t", c.value, c.want), func(t *testing.T) { v := &SortValidator{} ctx := &validation.Context{ @@ -320,7 +316,6 @@ func TestValidateSort(t *testing.T) { } func TestValidateJoin(t *testing.T) { - t.Run("Constructor", func(t *testing.T) { v := &JoinValidator{} assert.NotNil(t, v) @@ -372,7 +367,6 @@ func TestValidateJoin(t *testing.T) { } for _, c := range cases { - c := c t.Run(fmt.Sprintf("Validate_%v_%t", c.value, c.want), func(t *testing.T) { v := &JoinValidator{} ctx := &validation.Context{ @@ -387,7 +381,6 @@ func TestValidateJoin(t *testing.T) { } func TestValidateFields(t *testing.T) { - t.Run("Constructor", func(t *testing.T) { v := &FieldsValidator{} assert.NotNil(t, v) @@ -422,7 +415,6 @@ func TestValidateFields(t *testing.T) { } for _, c := range cases { - c := c t.Run(fmt.Sprintf("Validate_%v_%t", c.value, c.want), func(t *testing.T) { v := &FieldsValidator{} ctx := &validation.Context{