dbml icon indicating copy to clipboard operation
dbml copied to clipboard

It seems that `DELIMITER` cannot be handled well

Open try-agaaain opened this issue 1 year ago • 1 comments

I try to convert sakila/sakila-mv-schema.sql to DBML format, but in this file There are a lot of DELIMITER. When sql2dbml encounters these symbols, the following error will appear:

$ sql2dbml --mysql ./sakila/sakila-mv-schema.sql -o mydatabase.dbml
  ERROR: 
    You have a syntax error at "sakila-mv-schema.sql" line 189 column 0. mismatched input 'DELIMITER' expecting {<EOF>, '-'}

  A complete log can be found in:
     /workspace/test_db/dbml-error.log

The code at "sakila-mv-schema.sql" line 189 is as follows:

...

CREATE TABLE film_text (
  film_id SMALLINT NOT NULL,
  title VARCHAR(255) NOT NULL,
  description TEXT,
  PRIMARY KEY  (film_id),
  FULLTEXT KEY idx_title_description (title,description)
)ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- After MySQL 5.6.10, InnoDB supports fulltext indexes
/*!50610 ALTER TABLE film_text engine=InnoDB */;

--
-- Triggers for loading film_text from film
--

DELIMITER ;;
CREATE TRIGGER `ins_film` AFTER INSERT ON `film` FOR EACH ROW BEGIN
    INSERT INTO film_text (film_id, title, description)
        VALUES (new.film_id, new.title, new.description);
  END;;


CREATE TRIGGER `upd_film` AFTER UPDATE ON `film` FOR EACH ROW BEGIN
    IF (old.title != new.title) OR (old.description != new.description) OR (old.film_id != new.film_id)
    THEN
        UPDATE film_text
            SET title=new.title,
                description=new.description,
                film_id=new.film_id
        WHERE film_id=old.film_id;
    END IF;
  END;;
...

try-agaaain avatar Apr 30 '24 03:04 try-agaaain

me too

goroya avatar Aug 22 '24 04:08 goroya

MySQL's delimiter is currently supported in the newest version of dbml (v5.2.0) and dbdiagram.

However, note that our parser still doesn't recognize some syntax in the SQL sample above sakila/sakila-mv-schema.sql.

If you have time, you can test out the delimiter support and maybe drop a note. Thank you!

H-DNA avatar Nov 24 '25 03:11 H-DNA