Skip to content

Commit

Permalink
added lt, gt, lte, and gte for strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Malton committed Oct 3, 2019
1 parent aa5cafa commit e71f835
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 6 deletions.
Binary file added cmd/goqueryset/goqueryset
Binary file not shown.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ require (
golang.org/x/tools v0.0.0-20190226205152-f727befe758c
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.2.0
)

go 1.13
14 changes: 8 additions & 6 deletions internal/queryset/generator/methodsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,21 @@ func (b *methodsBuilder) getQuerySetMethodsForField(f field.Info) []methods.Meth
basicTypeMethods = append(basicTypeMethods, inMethod, notInMethod)
}

if f.IsString {
likeMethod := methods.NewBinaryFilterMethod(fctx.WithOperationName("like"))
notLikeMethod := methods.NewBinaryFilterMethod(fctx.WithOperationName("notlike"))
return append(basicTypeMethods, likeMethod, notLikeMethod)
}

numericMethods := []methods.Method{
methods.NewBinaryFilterMethod(fctx.WithOperationName("lt")),
methods.NewBinaryFilterMethod(fctx.WithOperationName("gt")),
methods.NewBinaryFilterMethod(fctx.WithOperationName("lte")),
methods.NewBinaryFilterMethod(fctx.WithOperationName("gte")),
}

if f.IsString {
likeMethod := methods.NewBinaryFilterMethod(fctx.WithOperationName("like"))
notLikeMethod := methods.NewBinaryFilterMethod(fctx.WithOperationName("notlike"))

methods := append(basicTypeMethods, likeMethod, notLikeMethod)
return append(methods, numericMethods...)
}

if f.IsNumeric {
return append(basicTypeMethods, numericMethods...)
}
Expand Down
168 changes: 168 additions & 0 deletions internal/queryset/generator/test/autogenerated_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions internal/queryset/generator/test/pkgimport/autogenerated_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e71f835

Please sign in to comment.