-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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/[email protected]/command.go:1015
github.com/spf13/cobra.(*Command).ExecuteC
/Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148
github.com/spf13/cobra.(*Command).Execute
/Users/runner/go/pkg/mod/github.com/spf13/[email protected]/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
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working