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

error with diagram's creation from mysql with lastest release #7

Closed
denoualflo opened this issue Apr 14, 2022 · 1 comment
Closed

Comments

@denoualflo
Copy link

Hi

Great tool, thank you !

There is a bug with mysql connection

.  ..___.__ .  ..___.__ .__
|\/|[__ [__)|\/|[__ [__)|  \
|  |[___|  \|  |[___|  \|__/ (dev)

Create MermaidJs diagrams from your database

? Choose a schema: VIRO_NGS_COVID
? Choose tables: ALIAS_DICT, [...snip...]
[                    ]Getting columns and constraintsError 1054: Unknown column 'c.TABLE_NAME' in 'on clause'


X Something went wrong!

A small typo in a query c.TABLE_NAME -> kc.TABLE_NAME

Here, diff after bug fix from master branch

diff --git a/database/mysql.go b/database/mysql.go
index 82d1226..7ff4699 100644
--- a/database/mysql.go
+++ b/database/mysql.go
@@ -113,7 +113,7 @@ func (c mySqlConnector) GetConstraints(tableName string) ([]ConstraintResult, er
                                   from information_schema.KEY_COLUMN_USAGE kc
                                                        left join information_schema.KEY_COLUMN_USAGE kc2
                                                                          ON kc.COLUMN_NAME = kc2.COLUMN_NAME AND kc2.CONSTRAINT_NAME = 'PRIMARY' AND
-                                                                                kc2.TABLE_NAME = c.TABLE_NAME
+                                                                                kc2.TABLE_NAME = kc.TABLE_NAME
                                   where kc.CONSTRAINT_NAME = c.CONSTRAINT_NAME
                           ) "isPrimary",
                           (

A new build and it works :)

✓ Diagram was created successfully (result.mmd)

Regards

@KarnerTh
Copy link
Owner

Hey,

thanks for the input, I am glad the tool finds it use.

Strange issue, the TABLE_NAME should be present in this table. The integration tests and my local setup use the MySQL version 8.0 and it works just fine, maybe its a version issue?

Regardless of the version and the issue, your suggested fix makes perfect sense and I applied the change.
Your fix is available with the new 0.1.0 version, you can now get it via go install github.com/KarnerTh/mermerd@latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants