Skip to content
Merged
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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
GIT_COMMIT := $(shell git rev-parse --short HEAD)

test:
go mod tidy
go test -failfast -timeout 20s -race ./...

install:
go install -ldflags "-X main.gitCommit=$(GIT_COMMIT)" .

cover:
go test -coverprofile=go-cover.profile -timeout 5s ./...
go tool cover -html=go-cover.profile
Expand Down
6 changes: 6 additions & 0 deletions pkg/vet/vet.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ func parseExpression(ctx VetContext, clause *pg_query.Node, parseRe *ParseResult
if arg := nullTest.GetArg(); arg != nil {
return parseExpression(ctx, arg, parseRe)
}
case clause.GetBooleanTest() != nil:
// WHERE bool_value IS TRUE / IS FALSE / IS UNKNOWN (and NOT variants)
boolTest := clause.GetBooleanTest()
if arg := boolTest.GetArg(); arg != nil {
return parseExpression(ctx, arg, parseRe)
}
case clause.GetColumnRef() != nil:
// cu := columnRefToColumnUsed(expr)
cu := columnRefToColumnUsed(clause.GetColumnRef())
Expand Down
16 changes: 16 additions & 0 deletions pkg/vet/vet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ var mockDbSchema = &schema.Db{
Name: "baz_count",
Type: "int",
},
"bool_value": {
Name: "bool_value",
Type: "bool",
},
},
ReadOnly: true,
},
Expand Down Expand Up @@ -409,6 +413,18 @@ func TestSelect(t *testing.T) {
"select with null test",
`SELECT id FROM foo WHERE value IS NULL`,
},
{
"select with boolean test",
`SELECT id FROM baz WHERE bool_value IS TRUE`,
},
{
"select with negated boolean test",
`SELECT id FROM baz WHERE bool_value IS NOT TRUE`,
},
{
"select with is not null",
`SELECT id FROM foo WHERE value IS NOT NULL`,
},
{
"select with join",
`SELECT id, coalesce(count,0)
Expand Down
Loading