Support dynamic delimiter in mysql parser#778
Conversation
412ef22 to
d0dd8a6
Compare
| @members { | ||
| this.currentDelimiter = ";"; | ||
|
|
||
| this.setDelimiter = function (delimiter) { | ||
| this.currentDelimiter = delimiter.trim(); | ||
| }; | ||
|
|
||
| this.isCurrentDelimiter = function (text) { | ||
| return text === this.currentDelimiter; | ||
| }; | ||
| } |
There was a problem hiding this comment.
This work. Another way is you could define a lexer base class :and move the code here to there. Please check the. For more details, check the PostgresSQL Lexer.g4 and .js for an example
There was a problem hiding this comment.
I have extracted out a base class nhe:
dbml/packages/dbml-core/src/parse/ANTLR/parsers/mysql/MySqlLexer.g4
Lines 39 to 43 in 09d99e5
| CREATE TABLE Table_4 ( | ||
| id INT | ||
| ); |
There was a problem hiding this comment.
Can you add more test for the following cases:
DELIMITER GODELIMITER END- DELIMITER inside comment (should be ignored)
-- DELIMITER ... - DELIMITER appear in quoted string
CREATE TABLE Table_5 (
id INT COMMENT 'just a comment with semi colon ;',
name varchar default 'default value with semi colon ;'
);
DELIMITER @
CREATE TABLE Table_6 (
id INT COMMENT 'just a comment with new delimiter @',
name varchar default 'default value with new delimiter @'
)@
There was a problem hiding this comment.
I have fixed all the problems and add some contrived testcases in delimiter.in.sql nhe: https://github.com/holistics/dbml/blob/c646dddacc98307a490e8363c197bbefdfe1347d/packages/dbml-core/__tests__/parser/mysql-parse/input/delimiter.in.sql.
I have also added other unrelated tests to make sure changes to the Lexer does not break anything unrelated to delimiters.
09d99e5 to
ab37dcd
Compare
ab37dcd to
ecda97a
Compare
… MySqlLexerBase nextToken
Summary
Issue
#566
Lasting Changes (Technical)
(please list down: code changes/things that have wide-effect; new libraries/functions added that can be used by others; examples below)
class EmailValidatorto validate email address' validity)Tenant#is_trial?check)Checklist
Please check directly on the box once each of these are done