dbml icon indicating copy to clipboard operation
dbml copied to clipboard

sql2dbml - Mysql 8.0.13+ reference to column in DEFAULT generates incorrect dbml

Open nerdwave-nick opened this issue 10 months ago • 1 comments

I ran into the issue that for sql statements like the following

CREATE TABLE `some_table` (
    code VARCHAR(6)
);

-- migration file later on
UPDATE TABLE `some_table` 
ADD name VARCHAR(80) DEFAULT(`code`);

generates incorrect dbml when generated from an sql dump. The resulting dbml will have double backticks around the word code, as follows:

name VARCHAR(80) DEFAULT(``code``)

This leads to tools following in the pipeline to error.

nerdwave-nick avatar Mar 05 '25 13:03 nerdwave-nick

Hi @nerdwave-nick ,

Could you help send us the correct version of your DDL statements? Since the provided has a syntax error in MySQL 8.0.

Also, can you help explain what the purpose of the name column is? Is it default value be the value of the code column?

huyleminh01 avatar Mar 06 '25 03:03 huyleminh01