houqp / houqp/sqlvet

Does not work without specifying schema

Open
#39 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
500
Forks
29
PR merge metrics
No merged PRs in 30d

Description

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/cobra@v1.6.1/command.go:920 +0x867
github.com/spf13/cobra.(*Command).ExecuteC(0xc00016d808)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in main.go at SQLVet.Vet and the vet.NewContext(tables: s.Schema.Tables) call identified in the report. Reproduce the command with no schema using the release binary or a build from master. Done means it no longer panics and can run without table and column validation while preserving the reported warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.