holistics / dbml

Database Markup Language (DBML), designed to define and document database structures
https://dbml.org
Apache License 2.0
2.91k stars 171 forks source link

It seems that `DELIMITER` cannot be handled well #566

Open try-agaaain opened 7 months ago

try-agaaain commented 7 months ago

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;;
...
goroya commented 3 months ago

me too