Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions filter/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
### Example Model
### Example Parser

```go
type User struct {
ID uint `gorm:"id" filter:"=;>;>=;#;%"`
Name string `gorm:"name" filter:"*"`
}
```
query := `(status LIKE home AND (status IN ("To Do", "In Progress", "Closed") AND artifact='')) OR metric > 0.98 OR metric >= 0.98 OR metric != 0.98`

You can allow all operator by `*`
parser := NewParser(test)
parser.ParserToArray()
parser.ParserToGroups()
query, values := parser.ParserToSQL()

### Protecting Fields
queryResult = "(status LIKE ? AND (status IN(?,?,?) AND artifact = ?)) OR metric > ? OR metric >= ? OR metric != ? "
valResult = []string{"home", "To Do", "In Progress", "Closed", "", "0.98", "0.98", "0.98"}
```

fields is unsearchable by default.

## Grammar

Goven has a simple syntax that allows for powerful queries.

Fields can be compared using the following operators:

`=`, `!=`, `>=`, `<=`, `<`, `>`, `%` , `#`

The `%` operator allows you to do partial string matching using LIKE.

The `#` operator is IN operator followed by a combination of values disrupted by a non-spaced comma
ex: `name#"(duckhue01,duckhue02)"`
`=`, `!=`, `>=`, `<=`, `<`, `>`, `LIKE` , `IN`, `NOT IN`

Multiple queries can be combined using `AND`, `OR`.

Together this means you can build up a query like this:

`model_name=iris AND version>=2.0`
Example for :
LIKE : `name LIKE hh`
IN : `status IN ("To Do", "In Progress", "Closed")`
NOT IN : `status NOT IN ("To Do", "In Progress", "Closed")`

More advanced queries can be built up using bracketed expressions:

`(model_name=iris AND version>=2.0) OR artifact_type=TENSORFLOW`
`(status LIKE home AND (status IN ("To Do", "In Progress", "Closed") AND artifact='')) OR metric > 0.98 OR metric >= 0.98 OR metric != 0.98`
43 changes: 0 additions & 43 deletions filter/adapter/sql/adaptor.go

This file was deleted.

127 changes: 0 additions & 127 deletions filter/adapter/sql/sql.go

This file was deleted.

132 changes: 0 additions & 132 deletions filter/adapter/sql/sql_test.go

This file was deleted.

Loading