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

Having multiple primary keys causes a parsing issue when converting SQL to an ER-Diagram #4112

Open
2 tasks done
pica4500 opened this issue Jan 17, 2024 · 1 comment
Open
2 tasks done

Comments

@pica4500
Copy link

pica4500 commented Jan 17, 2024

Preflight Checklist

  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

You must agree to search and the code of conduct. You must fill in this entire template. If you delete part/all or miss parts out your issue will be closed.

If you are technical, you should reporting bugs along the lines of https://marker.io/blog/how-to-write-bug-report. If you are not technical, we will make allowances, please try to make an effort to understand the process.

Describe the bug
In the example below, when converting SQL to ER-Diagram, the primary key cannot be parsed.

CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID, LastName)
);

To Reproduce
Steps to reproduce the behavior:

  1. Go to '+'
  2. Click on 'Advanced'
  3. Scroll down to 'SQL'
  4. copy and paste below code and generate
CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID, LastName)
);
  1. See draw.io cannot parse ID, LastName as a primary key
    image

Expected behavior
ER Diagram should check ID, LastName column as PK

Screenshots

image

draw.io version (In the Help->About menu of the draw.io editor):

  • draw.io version 21.6.6

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Firefox
  • Browser Version 120.0.1

Smartphone (please complete the following information):

  • Only checked in desktop

I tested the problem in incognito/private mode with all browser extensions switched off, write "yes" below:

  • yes

Additional context
draw.io docs says it supports MySQL
(https://www.drawio.com/doc/faq/sql-plugin)

In MySQL docs, you can also check, this kind of multiple primary keys are supported.
(https://dev.mysql.com/doc/refman/8.0/en/partitioning-limitations-partitioning-keys-unique-keys.html)

I guess, you have to check below code.
If input has PRIMARY KEY (ID, LastName) then, below code will push "ID, LastName" string into primaryKeyList and this string will not match with any columns i guess.

var primaryKey = name.replace('PRIMARY KEY (', '').replace(')', '');

var primaryKey = name.replace('PRIMARY KEY (', '').replace(')', '');

@lastlink
Copy link

@pica4500 I have a pr #4122 for the sql plugin that you have to install yourself manually (one file change) for improvements on the sql import parsing into uml diagram for draw.io.

Note on https://www.drawio.com/doc/faq/sql-plugin that this plugin is not maintained by core drawio developers, and they are closed contributions hence won't merge my pr with the improvements.
This plugin should be used as-is, as an unsupported example for developers.

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