drawdb-io / drawdb

Free, simple, and intuitive online database diagram editor and SQL generator.
https://drawdb.app
GNU Affero General Public License v3.0
22.7k stars 1.58k forks source link

[BUG] MYSQL: incorrect syntax for SET and ENUM export SQL #251

Closed csc530 closed 1 month ago

csc530 commented 1 month ago

When creating a MYSQL database creating a table with an ENUM or SET column type the exported SQL file (under file > export SQL) is incorrect. Whether valid, invalid, or empty values are entered in the drawdb column's values input. Currently, the exported syntax is

CREATE TABLE .... (
  `enum_column` ENUM ...,
  `set_column` SET ...,
  ...
);

missing brackets containing the enum/set's values

the expected output is...

CREATE TABLE .... (
  `enum_column` ENUM('value','val',...) ...,
  `set_column` SET('a','1',...) ...,
  ...
);

To Reproduce

Steps to reproduce the behaviour:

  1. Go to drawdb editor
  2. Choose a MySQL database
  3. Create a new table
  4. Add a column of set or enum type
  5. Add values for the column
  6. Click on file > 'Export SQL'
  7. See erroneous create table statement

Desktop:

Additional context

Not sure if the MySQL export is for a different version of MySQL (I'm using MySQL V8.0.30), I have a pr to solve the issue that I will link to this issue.

I'm happy to open a PR with a fix to this issue

lakshyeahh commented 1 month ago

I have understood the problem as well as high level structure of code. It can be assigned to me. Thank You.