Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors running mysql tests with connectionstring #10

Closed
kmpm opened this issue Nov 12, 2019 · 7 comments
Closed

Errors running mysql tests with connectionstring #10

kmpm opened this issue Nov 12, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@kmpm
Copy link
Contributor

kmpm commented Nov 12, 2019

I have been able to successfully test on sqlite, mssql and pg but mysql fails.
Code is fresh from master (except some debug prints and possibly gofmt) but I am running on Windows 10 with go1.13.3 windows/amd64.
I also have similar issues in an Ubuntu WSL on the same machine with go version go1.13.4 linux/amd64

windows

go clean -testcache
go test sse_test.go -driver mysql -mysql-connection-string "ssetestusr:ssetestusrpass@tcp(192.168.239.128:3306)/ssetest"
2019/11/12 14:51:39 mysql is the driver
2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Connecting to mysql db
--- FAIL: Test_ReadSchema (0.03s)
    sse_test.go:74: Column colB not found on table CompoundKeyChild, source of constraint CompoundKeyChild_ibfk_1
2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Connecting to mysql db
--- FAIL: Test_GetRows (0.02s)
    sse_test.go:780: Column colB not found on table CompoundKeyChild, source of constraint CompoundKeyChild_ibfk_1
2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Checking database connection...
2019/11/12 14:51:39 Reading schema, this may take a while...
2019/11/12 14:51:39 Request: '' | GET / HTTP/1.1

2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Connecting to mysql db
2019/11/12 14:51:39 Request: '' | GET /tables/DataTypeTest HTTP/1.1

2019/11/12 14:51:39 Connecting to mysql db
--- FAIL: Test_Http (0.46s)
panic: No columns found when reading table data table [recovered]
        panic: No columns found when reading table data table

goroutine 34 [running]:
testing.tRunner.func1(0xc000346000)
        c:/go/src/testing/testing.go:874 +0x3aa
panic(0x9ee540, 0xb5d260)
        c:/go/src/runtime/panic.go:679 +0x1c0
github.com/timabell/schema-explorer/reader.GetRows(0xb7a780, 0xc0002f9508, 0x0, 0x0, 0xc00045c3c0, 0xc0003295e0, 0x0, 0x0, 0x0, 0xc0004aa100, ...)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/reader/dbReader.go:136 +0x3cb
github.com/timabell/schema-explorer/render.ShowTable(0xb728a0, 0xc00034d2c0, 0xb7a780, 0xc0002f9508, 0xc000098f00, 0xc00045c3c0, 0xc0003295e0, 0xab21d8, 0x13, 0x0, ...)             C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/render/render.go:241 +0x269
github.com/timabell/schema-explorer/serve.TableHandler(0xb728a0, 0xc00034d2c0, 0xc000319700, 0x0)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/serve/table-handlers.go:74 +0x8e1
github.com/timabell/schema-explorer/serve.TableInfoHandler(0xb728a0, 0xc00034d2c0, 0xc000319700)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/serve/table-handlers.go:24 +0x4b
net/http.HandlerFunc.ServeHTTP(0xad55a8, 0xb728a0, 0xc00034d2c0, 0xc000319700)
        c:/go/src/net/http/server.go:2007 +0x4b
github.com/timabell/schema-explorer/serve.loggingHandler.func1(0xb728a0, 0xc00034d2c0, 0xc000319700)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/serve/logging.go:23 +0x1b0
net/http.HandlerFunc.ServeHTTP(0xc0005483a0, 0xb728a0, 0xc00034d2c0, 0xc000319700)
        c:/go/src/net/http/server.go:2007 +0x4b
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00034e000, 0xb728a0, 0xc00034d2c0, 0xc000319500)
        C:/Users/peter/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0xe9
command-line-arguments.CheckForStatusWithMethodAndBody(0xc000514b80, 0x14, 0xaa5939, 0x3, 0xc00034e000, 0xc8, 0x0, 0x0, 0xc000346000)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:968 +0x185
command-line-arguments.CheckForStatusWithMethod(...)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:962
command-line-arguments.CheckForStatus(...)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:958
command-line-arguments.CheckForOk(...)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:954
command-line-arguments.Test_Http(0xc000346000)
        C:/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:884 +0x417
testing.tRunner(0xc000346000, 0xad4ea0)
        c:/go/src/testing/testing.go:909 +0xd0
created by testing.(*T).Run
        c:/go/src/testing/testing.go:960 +0x357
FAIL    command-line-arguments  0.689s
FAIL
make: *** [Makefile:65: testmysql] Error 1

wsl

go clean -testcache
go test sse_test.go -driver mysql -mysql-connection-string "ssetestusr:ssetestusrpass@tcp(192.168.239.128:3306)/ssetest"
2019/11/12 14:56:55 mysql is the driver
2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:55 Connecting to mysql db
--- FAIL: Test_ReadSchema (0.03s)
    sse_test.go:74: Column colB not found on table CompoundKeyChild, source of constraint CompoundKeyChild_ibfk_1
2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:55 Connecting to mysql db
--- FAIL: Test_GetRows (0.03s)
    sse_test.go:780: Column colB not found on table CompoundKeyChild, source of constraint CompoundKeyChild_ibfk_1
2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:55 Checking database connection...
2019/11/12 14:56:55 Reading schema, this may take a while...
2019/11/12 14:56:55 Request: '' | GET / HTTP/1.1

2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:55 Connecting to mysql db
2019/11/12 14:56:56 Request: '' | GET /tables/DataTypeTest HTTP/1.1

2019/11/12 14:56:56 Connecting to mysql db
--- FAIL: Test_Http (0.48s)
panic: No columns found when reading table data table [recovered]
        panic: No columns found when reading table data table

goroutine 15 [running]:
testing.tRunner.func1(0xc00010e700)
        /usr/local/go/src/testing/testing.go:874 +0x3a3
panic(0x9a3a40, 0xb15b70)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/timabell/schema-explorer/reader.GetRows(0xb32e00, 0xc000411fc8, 0x0, 0x0, 0xc0002fc240, 0xc0002ca230, 0x0, 0x0, 0x0, 0xc000374900, ...)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/reader/dbReader.go:136 +0x3c4
github.com/timabell/schema-explorer/render.ShowTable(0xb2b4e0, 0xc00035ef00, 0xb32e00, 0xc000411fc8, 0xc0002dca00, 0xc0002fc240, 0xc0002ca230, 0xa688a8, 0x13, 0x0, ...)             /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/render/render.go:241 +0x262
github.com/timabell/schema-explorer/serve.TableHandler(0xb2b4e0, 0xc00035ef00, 0xc000377100, 0x0)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/serve/table-handlers.go:74 +0x8da
github.com/timabell/schema-explorer/serve.TableInfoHandler(0xb2b4e0, 0xc00035ef00, 0xc000377100)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/serve/table-handlers.go:24 +0x44
net/http.HandlerFunc.ServeHTTP(0xa8b038, 0xb2b4e0, 0xc00035ef00, 0xc000377100)
        /usr/local/go/src/net/http/server.go:2007 +0x44
github.com/timabell/schema-explorer/serve.loggingHandler.func1(0xb2b4e0, 0xc00035ef00, 0xc000377100)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/serve/logging.go:23 +0x1a9
net/http.HandlerFunc.ServeHTTP(0xc000430380, 0xb2b4e0, 0xc00035ef00, 0xc000377100)
        /usr/local/go/src/net/http/server.go:2007 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0002b2780, 0xb2b4e0, 0xc00035ef00, 0xc000376600)
        /home/peterm/go/pkg/mod/github.com/gorilla/mux@v1.7.3/mux.go:212 +0xe2
command-line-arguments.CheckForStatusWithMethodAndBody(0xc000429ee0, 0x14, 0xa5c3b8, 0x3, 0xc0002b2780, 0xc8, 0x0, 0x0, 0xc00010e700)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:968 +0x17e
command-line-arguments.CheckForStatusWithMethod(...)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:962
command-line-arguments.CheckForStatus(...)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:958
command-line-arguments.CheckForOk(...)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:954
command-line-arguments.Test_Http(0xc00010e700)
        /mnt/c/Delat/Code/go-sse/src/github.com/timabell/schema-explorer/sse_test.go:884 +0x410
testing.tRunner(0xc00010e700, 0xa8a918)
        /usr/local/go/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:960 +0x350
FAIL    command-line-arguments  0.582s
FAIL
@kmpm
Copy link
Contributor Author

kmpm commented Nov 13, 2019

mysql version 8.0.* if that makes a difference

@kmpm
Copy link
Contributor Author

kmpm commented Nov 13, 2019

Looks as if mysql.go : getColumns tries to use an empty opts.Database ("") as table_schema and that returns no column rows from the server.

@kmpm
Copy link
Contributor Author

kmpm commented Nov 13, 2019

Ok. I test using a connection string and if so there is no database name set that the driver can use.
The driver needs to figure out the name of the database from that string ( no hard part ) but I do not know where it matters if it's an empty string or where it needs to be a name.

kmpm added a commit to kmpm/schema-explorer that referenced this issue Nov 13, 2019
Gets the selected database from the server if not detected by configuration before getting columns on mysql.
Closes timabell#10
@timabell
Copy link
Owner

have a look in the sh files to see how I've been doing the setup. by the way I just added docker stuff for mysql which is handy

@kmpm
Copy link
Contributor Author

kmpm commented Nov 13, 2019

I have tested your way as well but shouldn't all connection methods be tested :)

@timabell
Copy link
Owner

Thanks for documenting this, it explains why my attempt at a gha failed - #62

@timabell timabell changed the title Errors running mysql tests Errors running mysql tests with connectionstring Jan 28, 2024
@timabell timabell added the bug Something isn't working label Jan 28, 2024
timabell pushed a commit that referenced this issue Jan 28, 2024
Gets the selected database from the server if not detected by configuration before getting columns on mysql.
Closes #10
@timabell
Copy link
Owner

And thanks for the PR and patch, merged. Amazing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants