@dbml/core 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +201 -1
- package/lib/export/DbmlExporter.js +5 -1
- package/lib/export/JsonExporter.js +0 -0
- package/lib/export/ModelExporter.js +0 -0
- package/lib/export/MysqlExporter.js +0 -0
- package/lib/export/OracleExporter.js +0 -0
- package/lib/export/PostgresExporter.js +0 -0
- package/lib/export/README.md +0 -0
- package/lib/export/SqlServerExporter.js +0 -0
- package/lib/export/index.js +0 -0
- package/lib/export/utils.js +0 -0
- package/lib/import/index.js +0 -0
- package/lib/index.js +7 -0
- package/lib/model_structure/check.js +0 -0
- package/lib/model_structure/config.js +0 -0
- package/lib/model_structure/database.js +0 -0
- package/lib/model_structure/dbState.js +0 -0
- package/lib/model_structure/element.js +0 -0
- package/lib/model_structure/endpoint.js +0 -0
- package/lib/model_structure/enum.js +0 -0
- package/lib/model_structure/enumValue.js +0 -0
- package/lib/model_structure/field.js +0 -0
- package/lib/model_structure/indexColumn.js +0 -0
- package/lib/model_structure/indexes.js +0 -0
- package/lib/model_structure/ref.js +0 -0
- package/lib/model_structure/schema.js +0 -0
- package/lib/model_structure/stickyNote.js +0 -0
- package/lib/model_structure/table.js +0 -0
- package/lib/model_structure/tableGroup.js +0 -0
- package/lib/model_structure/tablePartial.js +0 -0
- package/lib/model_structure/utils.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/AST.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/ParserErrorListener.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/SyntaxError.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/constants.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/helpers.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/index.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/mssql/README.md +263 -157
- package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/mysql/README.md +262 -157
- package/lib/parse/ANTLR/ASTGeneration/oraclesql/OracleSQLASTGen.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/oraclesql/README.md +261 -157
- package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLLexerBase.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLParserBase.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.js +0 -0
- package/lib/parse/ANTLR/ASTGeneration/postgres/README.md +252 -157
- package/lib/parse/ANTLR/ASTGeneration/snowflake/README.md +236 -157
- package/lib/parse/ANTLR/ASTGeneration/snowflake/SnowflakeASTGen.js +0 -0
- package/lib/parse/ANTLR/README.md +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.g4 +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.interp +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.js +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.tokens +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.g4 +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.interp +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.js +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.tokens +0 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlParserVisitor.js +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.g4 +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.interp +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.js +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.tokens +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexerBase.js +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.g4 +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.interp +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.js +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.tokens +0 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlParserVisitor.js +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.g4 +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.interp +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.js +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.tokens +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexerBase.js +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.g4 +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.interp +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.js +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.tokens +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserBase.js +0 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserVisitor.js +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.g4 +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.interp +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.js +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.tokens +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.g4 +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.interp +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.js +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.tokens +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserVisitor.js +0 -0
- package/lib/parse/ANTLR/parsers/postgresql/README.md +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.g4 +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.interp +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.js +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.tokens +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.g4 +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.interp +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.js +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.tokens +0 -0
- package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParserVisitor.js +0 -0
- package/lib/parse/Parser.js +0 -0
- package/lib/parse/buildParser.js +0 -0
- package/lib/parse/databaseGenerator.js +0 -0
- package/lib/parse/dbml/parser.pegjs +0 -0
- package/lib/parse/dbmlParser.js +0 -0
- package/lib/parse/error.js +0 -0
- package/lib/parse/mssql/base_parsers.js +0 -0
- package/lib/parse/mssql/column_definition/actions.js +0 -0
- package/lib/parse/mssql/column_definition/index.js +0 -0
- package/lib/parse/mssql/constraint_definition/actions.js +0 -0
- package/lib/parse/mssql/constraint_definition/index.js +0 -0
- package/lib/parse/mssql/expression.js +0 -0
- package/lib/parse/mssql/fk_definition/actions.js +0 -0
- package/lib/parse/mssql/fk_definition/index.js +0 -0
- package/lib/parse/mssql/index.js +0 -0
- package/lib/parse/mssql/index_definition/actions.js +0 -0
- package/lib/parse/mssql/index_definition/index.js +0 -0
- package/lib/parse/mssql/keyword_parsers.js +0 -0
- package/lib/parse/mssql/keyword_utils.js +0 -0
- package/lib/parse/mssql/statements/actions.js +0 -0
- package/lib/parse/mssql/statements/index.js +0 -0
- package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +0 -0
- package/lib/parse/mssql/statements/statement_types/alter_table/add/actions.js +0 -0
- package/lib/parse/mssql/statements/statement_types/alter_table/add/index.js +0 -0
- package/lib/parse/mssql/statements/statement_types/alter_table/index.js +0 -0
- package/lib/parse/mssql/statements/statement_types/comments/actions.js +0 -0
- package/lib/parse/mssql/statements/statement_types/comments/index.js +0 -0
- package/lib/parse/mssql/statements/statement_types/create_index/actions.js +0 -0
- package/lib/parse/mssql/statements/statement_types/create_index/index.js +0 -0
- package/lib/parse/mssql/statements/statement_types/create_table/actions.js +0 -0
- package/lib/parse/mssql/statements/statement_types/create_table/index.js +0 -0
- package/lib/parse/mssql/statements/statement_types/index.js +0 -0
- package/lib/parse/mssql/utils.js +0 -0
- package/lib/parse/mssql/whitespaces.js +0 -0
- package/lib/parse/mssqlParser.js +0 -0
- package/lib/parse/mysql/parser.pegjs +0 -0
- package/lib/parse/mysqlParser.js +0 -0
- package/lib/parse/postgresParser.js +0 -0
- package/lib/parse/postgresql/Base_rules.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Alter_table/Alter_table.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Commands.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Comment.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_index.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_table/Create_table.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_table/Create_table_of.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_table/Create_table_partition_of.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_type/Create_type.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_type/Create_type_enum.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Create_type/Create_type_range.pegjs +0 -0
- package/lib/parse/postgresql/Commands/Ignore_syntax.pegjs +0 -0
- package/lib/parse/postgresql/Expression.pegjs +0 -0
- package/lib/parse/postgresql/InitializerUtils.pegjs +0 -0
- package/lib/parse/postgresql/Keywords.pegjs +0 -0
- package/lib/parse/postgresql/get_parser.js +0 -0
- package/lib/parse/postgresql/parser.pegjs +0 -0
- package/lib/parse/schemarb/parser.pegjs +0 -0
- package/lib/parse/schemarbParser.js +0 -0
- package/lib/transform/index.js +30 -0
- package/lib/utils/version.js +0 -0
- package/package.json +3 -3
- package/types/export/ModelExporter.d.ts +0 -0
- package/types/export/index.d.ts +0 -0
- package/types/import/index.d.ts +0 -0
- package/types/index.d.ts +2 -1
- package/types/model_structure/check.d.ts +0 -0
- package/types/model_structure/database.d.ts +0 -0
- package/types/model_structure/dbState.d.ts +0 -0
- package/types/model_structure/element.d.ts +0 -0
- package/types/model_structure/endpoint.d.ts +0 -0
- package/types/model_structure/enum.d.ts +0 -0
- package/types/model_structure/enumValue.d.ts +0 -0
- package/types/model_structure/field.d.ts +0 -0
- package/types/model_structure/indexColumn.d.ts +0 -0
- package/types/model_structure/indexes.d.ts +0 -0
- package/types/model_structure/ref.d.ts +0 -0
- package/types/model_structure/schema.d.ts +0 -0
- package/types/model_structure/stickyNote.d.ts +0 -0
- package/types/model_structure/table.d.ts +0 -0
- package/types/model_structure/tableGroup.d.ts +0 -0
- package/types/model_structure/tablePartial.d.ts +0 -0
- package/types/parse/Parser.d.ts +0 -0
- package/types/parse/error.d.ts +0 -0
- package/types/transform/index.d.ts +7 -0
|
@@ -1,157 +1,262 @@
|
|
|
1
|
-
# MySQL
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
|
14
|
-
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
|
46
|
-
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
|
82
|
-
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
|
94
|
-
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
|
103
|
-
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
|
112
|
-
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
|
121
|
-
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
|
132
|
-
|
|
133
|
-
|
|
|
134
|
-
|
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
|
147
|
-
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
|
156
|
-
|
|
157
|
-
|
|
|
1
|
+
# MySQL SQL Parser Support
|
|
2
|
+
|
|
3
|
+
> Comprehensive documentation for the MySQL model structure generator based on the ANTLR4 parser.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This module provides SQL parsing capabilities for MySQL databases, enabling conversion of MySQL DDL statements to DBML format. The parser supports MySQL-specific syntax including `AUTO_INCREMENT` columns, `UNIQUE KEY`/`UNIQUE INDEX` syntax, inline table and column comments, and various index types.
|
|
8
|
+
|
|
9
|
+
## Support Legend
|
|
10
|
+
|
|
11
|
+
| Symbol | Meaning |
|
|
12
|
+
|--------|---------|
|
|
13
|
+
| ✓ | Fully supported and correctly parsed |
|
|
14
|
+
| ◐ | Valid SQL that is parsed, but some options/clauses are ignored |
|
|
15
|
+
| ✗ | Valid MySQL syntax, but the parser fails to generate output |
|
|
16
|
+
| — | Syntax not valid in MySQL |
|
|
17
|
+
|
|
18
|
+
## Key Capabilities
|
|
19
|
+
|
|
20
|
+
- **Data Definition**
|
|
21
|
+
- `CREATE TABLE` with full syntax support
|
|
22
|
+
- Data types: parameterized types (e.g., `VARCHAR(255)`, `DECIMAL(10,2)`)
|
|
23
|
+
- **Constraints**
|
|
24
|
+
- `PRIMARY KEY` (column-level, table-level, multi-column, with explicit name)
|
|
25
|
+
- `FOREIGN KEY` with `ON UPDATE` / `ON DELETE` actions
|
|
26
|
+
- `UNIQUE`, `UNIQUE KEY`, `UNIQUE INDEX`
|
|
27
|
+
- `CHECK`, `DEFAULT`, `NOT NULL`
|
|
28
|
+
- **Auto-increment**
|
|
29
|
+
- `AUTO_INCREMENT` column attribute
|
|
30
|
+
- **Indexes**
|
|
31
|
+
- `CREATE INDEX` with BTREE, HASH
|
|
32
|
+
- Table-level indexes in `CREATE TABLE`
|
|
33
|
+
- Function-based indexes
|
|
34
|
+
- **Comments**
|
|
35
|
+
- Inline `COMMENT` attribute for tables and columns
|
|
36
|
+
- **Data Manipulation**
|
|
37
|
+
- Basic `INSERT` and multi-row `INSERT`
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Feature Support Matrix
|
|
42
|
+
|
|
43
|
+
### `CREATE TABLE`
|
|
44
|
+
|
|
45
|
+
| Feature | Status | Notes |
|
|
46
|
+
|---------|---------|-------|
|
|
47
|
+
| Basic `CREATE TABLE` syntax | ✓ | |
|
|
48
|
+
| Enumerated data types (ENUM) | ✓ | MySQL uses inline ENUM type |
|
|
49
|
+
| Parameterized types `name(...)` | ✓ | e.g., `VARCHAR(255)`, `DECIMAL(10,2)` |
|
|
50
|
+
| Array types `name[...]` | — | Not supported in MySQL |
|
|
51
|
+
| TEMPORARY tables | ✗ | Tables are completely ignored |
|
|
52
|
+
| `CREATE TABLE` AS SELECT | ✗ | |
|
|
53
|
+
| Table options (ENGINE, CHARSET, etc.) | ◐ | Options are ignored |
|
|
54
|
+
|
|
55
|
+
### Constraints
|
|
56
|
+
|
|
57
|
+
#### `PRIMARY KEY`
|
|
58
|
+
|
|
59
|
+
| Feature | Status | Notes |
|
|
60
|
+
|---------|---------|-------|
|
|
61
|
+
| Column-level `PRIMARY KEY` | ✓ | `id INT PRIMARY KEY` |
|
|
62
|
+
| Table-level `PRIMARY KEY` | ✓ | `PRIMARY KEY (id)` |
|
|
63
|
+
| Multi-column `PRIMARY KEY` | ✓ | `PRIMARY KEY (a, b)` |
|
|
64
|
+
| Explicitly named (CONSTRAINT name) | ✓ | `CONSTRAINT pk_name PRIMARY KEY (id)` |
|
|
65
|
+
| Index options (USING BTREE, etc.) | ◐ | Options are ignored |
|
|
66
|
+
|
|
67
|
+
#### `FOREIGN KEY`
|
|
68
|
+
|
|
69
|
+
| Feature | Status | Notes |
|
|
70
|
+
|---------|---------|-------|
|
|
71
|
+
| Column-level `FOREIGN KEY` | ✓ | `col INT REFERENCES other(id)` |
|
|
72
|
+
| Table-level `FOREIGN KEY` | ✓ | `FOREIGN KEY (col) REFERENCES other(id)` |
|
|
73
|
+
| Multi-column `FOREIGN KEY` | ✓ | `FOREIGN KEY (a, b) REFERENCES other(x, y)` |
|
|
74
|
+
| Explicitly named (CONSTRAINT name) | ✓ | `CONSTRAINT fk_name FOREIGN KEY ...` |
|
|
75
|
+
| `ON UPDATE` action | ✓ | CASCADE, SET NULL, RESTRICT, NO ACTION |
|
|
76
|
+
| `ON DELETE` action | ✓ | CASCADE, SET NULL, RESTRICT, NO ACTION |
|
|
77
|
+
| Index options | ◐ | Options are ignored |
|
|
78
|
+
|
|
79
|
+
#### `UNIQUE`
|
|
80
|
+
|
|
81
|
+
| Feature | Status | Notes |
|
|
82
|
+
|---------|---------|-------|
|
|
83
|
+
| Column-level `UNIQUE` | ✓ | `col INT UNIQUE` |
|
|
84
|
+
| Table-level `UNIQUE` | ✓ | `UNIQUE (col)` |
|
|
85
|
+
| Multi-column `UNIQUE` | ✓ | `UNIQUE (a, b)` |
|
|
86
|
+
| Explicitly named (CONSTRAINT name) | ✓ | `CONSTRAINT uq_name UNIQUE (col)` |
|
|
87
|
+
| Index options | ◐ | Options are ignored |
|
|
88
|
+
| NULLS NOT DISTINCT | ✗ | Treats NULLs as equal - parse failure in MySQL |
|
|
89
|
+
| `UNIQUE KEY` / `UNIQUE INDEX` | ✓ | MySQL-specific alternative syntax |
|
|
90
|
+
|
|
91
|
+
#### `CHECK`
|
|
92
|
+
|
|
93
|
+
| Feature | Status | Notes |
|
|
94
|
+
|---------|---------|-------|
|
|
95
|
+
| Column-level `CHECK` | ✓ | `col INT CHECK (col > 0)` |
|
|
96
|
+
| Table-level `CHECK` | ✓ | `CHECK (col > 0)` |
|
|
97
|
+
| Explicitly named (CONSTRAINT name) | ✓ | Name ignored for column-level checks |
|
|
98
|
+
| NOT ENFORCED option | ◐ | Enforcement control is ignored |
|
|
99
|
+
|
|
100
|
+
#### `DEFAULT`
|
|
101
|
+
|
|
102
|
+
| Feature | Status | Notes |
|
|
103
|
+
|---------|---------|-------|
|
|
104
|
+
| Column-level `DEFAULT` | ✓ | `col INT DEFAULT 0` |
|
|
105
|
+
| Table-level `DEFAULT` | — | MySQL only supports column-level `DEFAULT` |
|
|
106
|
+
| Function as `DEFAULT` | ✓ | `DEFAULT CURRENT_TIMESTAMP`, `DEFAULT UUID()` |
|
|
107
|
+
| Explicitly named `DEFAULT` | — | MySQL doesn't support named `DEFAULT` constraints |
|
|
108
|
+
|
|
109
|
+
#### `NOT NULL` / NULL
|
|
110
|
+
|
|
111
|
+
| Feature | Status | Notes |
|
|
112
|
+
|---------|---------|-------|
|
|
113
|
+
| Column-level `NOT NULL` | ✓ | `col INT NOT NULL` |
|
|
114
|
+
| NULL (explicitly nullable) | ✓ | `col INT NULL` |
|
|
115
|
+
| Table-level `NOT NULL` | — | MySQL only supports column-level `NOT NULL` |
|
|
116
|
+
| Constraint options | ◐ | Options are ignored |
|
|
117
|
+
|
|
118
|
+
### Auto-Increment Columns
|
|
119
|
+
|
|
120
|
+
| Feature | Status | Notes |
|
|
121
|
+
|---------|---------|-------|
|
|
122
|
+
| `AUTO_INCREMENT` (column attribute) | ✓ | `id INT AUTO_INCREMENT PRIMARY KEY` |
|
|
123
|
+
| `AUTO_INCREMENT` starting value | ◐ | `AUTO_INCREMENT=1000` table option is ignored |
|
|
124
|
+
| `SERIAL` (pseudo-type) | — | PostgreSQL syntax - not valid in MySQL |
|
|
125
|
+
| `BIGSERIAL` (pseudo-type) | — | PostgreSQL syntax - not valid in MySQL |
|
|
126
|
+
| `IDENTITY(seed, increment)` (column property) | — | SQL Server/Snowflake syntax - not valid in MySQL |
|
|
127
|
+
| `GENERATED AS IDENTITY` (column property) | — | SQL standard syntax - not valid in MySQL |
|
|
128
|
+
|
|
129
|
+
### Inline Indexes (in `CREATE TABLE`)
|
|
130
|
+
|
|
131
|
+
| Feature | Status | Notes |
|
|
132
|
+
|---------|---------|-------|
|
|
133
|
+
| Column-level indexes | ✗ | Parse failure |
|
|
134
|
+
| Table-level indexes (INDEX/KEY) | ✓ | |
|
|
135
|
+
| Named indexes | ✓ | |
|
|
136
|
+
| Multi-column indexes | ✓ | |
|
|
137
|
+
| USING BTREE | ✓ | |
|
|
138
|
+
| USING HASH | ✓ | |
|
|
139
|
+
| CLUSTERED/NONCLUSTERED | — | SQL Server syntax |
|
|
140
|
+
| FULLTEXT index | ◐ | Ignored |
|
|
141
|
+
| SPATIAL index | ◐ | Ignored |
|
|
142
|
+
| Other index options | ◐ | Ignored |
|
|
143
|
+
|
|
144
|
+
### Table/Column Comments (in `CREATE TABLE`)
|
|
145
|
+
|
|
146
|
+
| Feature | Status | Notes |
|
|
147
|
+
|---------|---------|-------|
|
|
148
|
+
| Table `COMMENT` attribute | ✓ | e.g., `CREATE TABLE t (...) COMMENT 'desc'` |
|
|
149
|
+
| Column `COMMENT` attribute | ✓ | e.g., `col INT COMMENT 'desc'` |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### `CREATE INDEX`
|
|
154
|
+
|
|
155
|
+
| Feature | Status | Notes |
|
|
156
|
+
|---------|---------|-------|
|
|
157
|
+
| Basic `CREATE INDEX` | ✓ | |
|
|
158
|
+
| Multi-column index | ✓ | |
|
|
159
|
+
| Explicitly named index | ✓ | |
|
|
160
|
+
| `UNIQUE` index | ✓ | |
|
|
161
|
+
| BTREE index | ✓ | |
|
|
162
|
+
| HASH index | ✓ | |
|
|
163
|
+
| Function-based index | ✓ | e.g., `CREATE INDEX ON t ((col + 1))` |
|
|
164
|
+
| Partial/Filtered index | ✗ | Parse failure |
|
|
165
|
+
| INCLUDE columns | — | Not supported in MySQL |
|
|
166
|
+
| CLUSTERED/NONCLUSTERED | ◐ | Ignored |
|
|
167
|
+
| FULLTEXT index | ◐ | Ignored |
|
|
168
|
+
| SPATIAL index | ◐ | Ignored |
|
|
169
|
+
| COLLATE | ✗ | Parse failure |
|
|
170
|
+
| Index `COMMENT` | ◐ | Ignored |
|
|
171
|
+
| NULLS FIRST/LAST | — | Not supported in MySQL |
|
|
172
|
+
| ASC/DESC | ◐ | Ignored |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### `INSERT` Statements
|
|
177
|
+
|
|
178
|
+
| Feature | Status | Notes |
|
|
179
|
+
|---------|---------|-------|
|
|
180
|
+
| Basic `INSERT` ... VALUES | ✓ | |
|
|
181
|
+
| Multi-row `INSERT` | ✓ | |
|
|
182
|
+
| `INSERT` ... SELECT | ✗ | |
|
|
183
|
+
| WITH clause (CTE) | ✗ | |
|
|
184
|
+
| Target table alias | — | Not supported in MySQL |
|
|
185
|
+
| `INSERT` ... RETURNING | — | Not supported in MySQL |
|
|
186
|
+
| `INSERT` ... ON DUPLICATE KEY UPDATE | ◐ | Clause is ignored |
|
|
187
|
+
| `INSERT` IGNORE | ◐ | IGNORE is ignored |
|
|
188
|
+
| `INSERT` OVERWRITE | — | Snowflake/Hive syntax |
|
|
189
|
+
| Multi-table `INSERT` | ✗ | |
|
|
190
|
+
| Conditional `INSERT` (WHEN/FIRST/ALL) | ✗ | |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
### `ALTER TABLE`
|
|
195
|
+
|
|
196
|
+
| Feature | Status | Notes |
|
|
197
|
+
|---------|---------|-------|
|
|
198
|
+
| **ADD COLUMN** | | |
|
|
199
|
+
| - All column properties | ✗ | |
|
|
200
|
+
| **DROP COLUMN** | ✗ | |
|
|
201
|
+
| **ALTER COLUMN / MODIFY COLUMN** | | |
|
|
202
|
+
| - `COMMENT` | ✗ | |
|
|
203
|
+
| - Other modifications | ✗ | |
|
|
204
|
+
| **RENAME COLUMN** | ✗ | |
|
|
205
|
+
| **ADD CONSTRAINT** | | |
|
|
206
|
+
| - Named `CHECK` | ✓ | |
|
|
207
|
+
| - Unnamed `CHECK` | ✓ | |
|
|
208
|
+
| - Named `UNIQUE` | ✗ | |
|
|
209
|
+
| - Unnamed `UNIQUE` | ✗ | |
|
|
210
|
+
| - Named `PRIMARY KEY` | ◐ | Name is ignored |
|
|
211
|
+
| - Unnamed `PRIMARY KEY` | ✓ | |
|
|
212
|
+
| - Named `FOREIGN KEY` | ✓ | |
|
|
213
|
+
| - Unnamed `FOREIGN KEY` | ✓ | |
|
|
214
|
+
| - `DEFAULT` | ✗ | Parse failure |
|
|
215
|
+
| - `NOT NULL` / NULL | ✗ | |
|
|
216
|
+
| **DROP CONSTRAINT** | ✗ | |
|
|
217
|
+
| **ALTER CONSTRAINT** | ✗ | |
|
|
218
|
+
| **RENAME TABLE** | ✗ | |
|
|
219
|
+
| **SET SCHEMA** | ✗ | |
|
|
220
|
+
| **ADD INDEX** | ✗ | |
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### Other DDL Statements
|
|
225
|
+
|
|
226
|
+
| Feature | Status | Notes |
|
|
227
|
+
|---------|---------|-------|
|
|
228
|
+
| `DROP TABLE` | ✗ | |
|
|
229
|
+
| `DROP INDEX` | ✗ | |
|
|
230
|
+
| `ALTER INDEX` | — | Not supported in MySQL |
|
|
231
|
+
| `CREATE VIEW` | ✗ | |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### Comments (Standalone Statements)
|
|
236
|
+
|
|
237
|
+
| Feature | Status | Notes |
|
|
238
|
+
|---------|---------|-------|
|
|
239
|
+
| Standalone table comments | — | Use inline `COMMENT` in `CREATE TABLE` |
|
|
240
|
+
| Standalone column comments | — | Use inline `COMMENT` |
|
|
241
|
+
| Index comments | ✗ | Parse failure |
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Known Limitations
|
|
246
|
+
|
|
247
|
+
- **TEMPORARY tables**: Completely ignored during parsing
|
|
248
|
+
- **Column-level indexes in `CREATE TABLE`**: Parse failure for INDEX/KEY definitions inline with columns
|
|
249
|
+
- **`ALTER TABLE` operations**: Limited support; primarily ADD CONSTRAINT (`CHECK`, `FOREIGN KEY`) is functional
|
|
250
|
+
- **DDL modification statements**: `DROP TABLE`, `DROP INDEX` not supported
|
|
251
|
+
- **`INSERT` ... SELECT**: Subqueries in `INSERT` statements not supported
|
|
252
|
+
- **`CREATE VIEW`**: View definitions are not parsed
|
|
253
|
+
- **FULLTEXT/SPATIAL indexes**: Parsed but ignored in output
|
|
254
|
+
|
|
255
|
+
## MySQL-Specific Notes
|
|
256
|
+
|
|
257
|
+
1. **`AUTO_INCREMENT`**: The MySQL-specific `AUTO_INCREMENT` attribute is correctly recognized and converted to auto-increment columns in DBML
|
|
258
|
+
2. **`UNIQUE KEY`/`UNIQUE INDEX`**: Both MySQL syntaxes are supported for defining unique constraints
|
|
259
|
+
3. **Inline Comments**: MySQL's `COMMENT` attribute for tables and columns is fully supported (unlike PostgreSQL which uses `COMMENT ON` statements)
|
|
260
|
+
4. **Index Types**: `BTREE` and `HASH` index types are supported; `FULLTEXT` and `SPATIAL` are parsed but ignored
|
|
261
|
+
5. **Table Engine**: `ENGINE`, `CHARSET`, `COLLATE` and other table options are parsed but ignored in DBML output
|
|
262
|
+
6. **ENUM Type**: MySQL's inline `ENUM` type definition is handled differently from PostgreSQL's `CREATE TYPE`
|
|
File without changes
|