sqlvet
sqlvet copied to clipboard
Does not work without specifying schema
When using the binary from the release page or building master from the source, the command fails when a schema has not been specified:
[!] No schema specified, will run without table and column validation.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x870c29]
goroutine 1 [running]:
main.(*SQLVet).Vet(0xc000150ee0)
/home/runner/work/sqlvet/sqlvet/main.go:43 +0x29
main.main.func2(0xc000189700?, {0xc00011ebd0?, 0x7?, 0xb7435e?})
/home/runner/work/sqlvet/sqlvet/main.go:147 +0x45
github.com/spf13/cobra.(*Command).execute(0xc00016d808, {0xc000132010, 0x1, 0x1})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:920 +0x867
github.com/spf13/cobra.(*Command).ExecuteC(0xc00016d808)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1044 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:968
main.main()
/home/runner/work/sqlvet/sqlvet/main.go:166 +0x1d6
It appears that s.Schema is nil in vet.NewContext(tables: s.Schema.Tables).
Reproduces for me too with [email protected]
could you try adding a nil check in there and pass in an empty map when schema is nil?