What happened
When running tbls doc on a database of a MySQL server, if a table has a foreign key referencing a table from another database, the command fails to find that table and exits early without generating anything.
What you expected to happened
The command should be able to recognize that the key is referencing another database/schema, not throw an error and successfully generate the documentation files.
I understand that it's not realistic to generate children/parents Markdown links, perhaps just displaying the database_name.table_name value is enough in that case.
What stack trace or error message from tbls did you see?
$ DEBUG=1 tbls doc mysql://user:pass@localhost:3306/b doc/schema
not found table 't1' not found table 't1'
github.com/k1LoW/tbls/schema.(*Schema).FindTableByName.func1
/Users/runner/work/tbls/tbls/schema/schema.go:226
github.com/k1LoW/tbls/schema.(*Schema).FindTableByName
/Users/runner/work/tbls/tbls/schema/schema.go:233
github.com/k1LoW/tbls/drivers/mysql.(*Mysql).Analyze
/Users/runner/work/tbls/tbls/drivers/mysql/mysql.go:513
github.com/k1LoW/tbls/datasource.Analyze
/Users/runner/work/tbls/tbls/datasource/datasource.go:155
github.com/k1LoW/tbls/cmd.init.func5
/Users/runner/work/tbls/tbls/cmd/doc.go:72
github.com/spf13/cobra.(*Command).execute
/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1015
github.com/spf13/cobra.(*Command).ExecuteC
/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148
github.com/spf13/cobra.(*Command).Execute
/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071
github.com/k1LoW/tbls/cmd.Execute
/Users/runner/work/tbls/tbls/cmd/root.go:192
main.main
/Users/runner/work/tbls/tbls/main.go:34
runtime.main
/Users/runner/hostedtoolcache/go/1.23.8/arm64/src/runtime/proc.go:272
runtime.goexit
/Users/runner/hostedtoolcache/go/1.23.8/arm64/src/runtime/asm_arm64.s:1223
Anything else we need to know?
Here's the script to create a reproducible database to generate the error above
CREATE DATABASE a;
CREATE TABLE a.t1 (
id int,
PRIMARY KEY (id)
);
CREATE DATABASE b;
CREATE TABLE b.t2 (
fk_id int NULL,
CONSTRAINT fk FOREIGN KEY (fk_id) REFERENCES a.t1 (id)
);
Environment
- tbls version 1.85.4
- Database:
MySQL all versions
- OS:
macOS Sequoia 15.5
- Shell:
zsh
What happened
When running
tbls docon a database of a MySQL server, if a table has a foreign key referencing a table from another database, the command fails to find that table and exits early without generating anything.What you expected to happened
The command should be able to recognize that the key is referencing another database/schema, not throw an error and successfully generate the documentation files.
I understand that it's not realistic to generate children/parents Markdown links, perhaps just displaying the
database_name.table_namevalue is enough in that case.What stack trace or error message from tbls did you see?
Anything else we need to know?
Here's the script to create a reproducible database to generate the error above
Environment
MySQL all versionsmacOS Sequoia 15.5zsh