@dbml/core 3.11.0-alpha-0 → 3.11.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 +0 -0
- package/lib/export/DbmlExporter.js +0 -0
- 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 +0 -0
- package/lib/model_structure/config.js +0 -0
- package/lib/model_structure/database.js +2 -6
- 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/utils.js +0 -6
- 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 +5 -21
- package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js +4 -165
- 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 +5 -236
- package/lib/parse/ANTLR/ASTGeneration/snowflake/SnowflakeASTGen.js +0 -0
- package/lib/parse/ANTLR/README.md +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/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/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 -10
- 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/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 +0 -0
- package/types/model_structure/database.d.ts +1 -16
- 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/parse/Parser.d.ts +1 -2
- package/types/parse/error.d.ts +0 -0
- package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js +0 -393
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.g4 +0 -1294
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.interp +0 -3643
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.js +0 -1255
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.tokens +0 -2385
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.g4 +0 -6307
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.interp +0 -3034
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.js +0 -3
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.tokens +0 -2385
- package/lib/parse/ANTLR/parsers/mssql/TSqlParserVisitor.js +0 -5732
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/export/README.md
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/export/index.js
CHANGED
|
File without changes
|
package/lib/export/utils.js
CHANGED
|
File without changes
|
package/lib/import/index.js
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -53,9 +53,7 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
53
53
|
_ref$project = _ref.project,
|
|
54
54
|
project = _ref$project === void 0 ? {} : _ref$project,
|
|
55
55
|
_ref$aliases = _ref.aliases,
|
|
56
|
-
aliases = _ref$aliases === void 0 ? [] : _ref$aliases
|
|
57
|
-
_ref$records = _ref.records,
|
|
58
|
-
records = _ref$records === void 0 ? {} : _ref$records;
|
|
56
|
+
aliases = _ref$aliases === void 0 ? [] : _ref$aliases;
|
|
59
57
|
_classCallCheck(this, Database);
|
|
60
58
|
_this = _super.call(this);
|
|
61
59
|
_this.dbState = new _dbState["default"]();
|
|
@@ -69,7 +67,6 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
69
67
|
_this.name = project.name;
|
|
70
68
|
_this.token = project.token;
|
|
71
69
|
_this.aliases = aliases;
|
|
72
|
-
_this.records = records;
|
|
73
70
|
_this.processNotes(notes);
|
|
74
71
|
// The process order is important. Do not change !
|
|
75
72
|
_this.processSchemas(schemas);
|
|
@@ -294,8 +291,7 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
294
291
|
enumValues: {},
|
|
295
292
|
indexes: {},
|
|
296
293
|
indexColumns: {},
|
|
297
|
-
fields: {}
|
|
298
|
-
records: this.records
|
|
294
|
+
fields: {}
|
|
299
295
|
};
|
|
300
296
|
this.schemas.forEach(function (schema) {
|
|
301
297
|
return schema.normalize(normalizedModel);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getFullTableName = getFullTableName;
|
|
7
6
|
exports.shouldPrintSchema = shouldPrintSchema;
|
|
8
7
|
exports.shouldPrintSchemaName = shouldPrintSchemaName;
|
|
9
8
|
var _config = require("./config");
|
|
@@ -12,9 +11,4 @@ function shouldPrintSchema(schema) {
|
|
|
12
11
|
}
|
|
13
12
|
function shouldPrintSchemaName(schemaName) {
|
|
14
13
|
return schemaName !== _config.DEFAULT_SCHEMA_NAME;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// TODO: This is an ad hoc function for parsing inserts. It should be replaced with a more robust solution
|
|
18
|
-
function getFullTableName(schemaName, tableName) {
|
|
19
|
-
return "".concat(schemaName && shouldPrintSchemaName(schemaName) ? "".concat(schemaName, ".") : '').concat(tableName);
|
|
20
14
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -15,9 +15,6 @@ var _SnowflakeLexer = _interopRequireDefault(require("../parsers/snowflake/Snowf
|
|
|
15
15
|
var _SnowflakeParser = _interopRequireDefault(require("../parsers/snowflake/SnowflakeParser"));
|
|
16
16
|
var _SnowflakeASTGen = _interopRequireDefault(require("./snowflake/SnowflakeASTGen"));
|
|
17
17
|
var _ParserErrorListener = _interopRequireDefault(require("./ParserErrorListener"));
|
|
18
|
-
var _TSqlLexer = _interopRequireDefault(require("../parsers/mssql/TSqlLexer"));
|
|
19
|
-
var _TSqlParser = _interopRequireDefault(require("../parsers/mssql/TSqlParser"));
|
|
20
|
-
var _MssqlASTGen = _interopRequireDefault(require("./mssql/MssqlASTGen"));
|
|
21
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
19
|
/* eslint-disable import/no-named-as-default-member */
|
|
23
20
|
/* eslint-disable import/no-named-as-default */
|
|
@@ -53,29 +50,16 @@ function parse(input, format) {
|
|
|
53
50
|
if (errorListener.errors.length) throw errorListener.errors;
|
|
54
51
|
break;
|
|
55
52
|
}
|
|
56
|
-
case '
|
|
53
|
+
case 'snowflake':
|
|
57
54
|
{
|
|
58
|
-
var _lexer2 = new
|
|
55
|
+
var _lexer2 = new _SnowflakeLexer["default"](chars);
|
|
59
56
|
var _tokens2 = new _antlr["default"].CommonTokenStream(_lexer2);
|
|
60
|
-
var _parser2 = new
|
|
57
|
+
var _parser2 = new _SnowflakeParser["default"](_tokens2);
|
|
61
58
|
_parser2.buildParseTrees = true;
|
|
62
59
|
_parser2.removeErrorListeners();
|
|
63
60
|
_parser2.addErrorListener(errorListener);
|
|
64
|
-
var _parseTree2 = _parser2.
|
|
65
|
-
database = _parseTree2.accept(new
|
|
66
|
-
if (errorListener.errors.length) throw errorListener.errors;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
case 'snowflake':
|
|
70
|
-
{
|
|
71
|
-
var _lexer3 = new _SnowflakeLexer["default"](chars);
|
|
72
|
-
var _tokens3 = new _antlr["default"].CommonTokenStream(_lexer3);
|
|
73
|
-
var _parser3 = new _SnowflakeParser["default"](_tokens3);
|
|
74
|
-
_parser3.buildParseTrees = true;
|
|
75
|
-
_parser3.removeErrorListeners();
|
|
76
|
-
_parser3.addErrorListener(errorListener);
|
|
77
|
-
var _parseTree3 = _parser3.snowflake_file();
|
|
78
|
-
database = _parseTree3.accept(new _SnowflakeASTGen["default"]());
|
|
61
|
+
var _parseTree2 = _parser2.snowflake_file();
|
|
62
|
+
database = _parseTree2.accept(new _SnowflakeASTGen["default"]());
|
|
79
63
|
if (errorListener.errors.length) throw errorListener.errors;
|
|
80
64
|
break;
|
|
81
65
|
}
|
|
@@ -9,7 +9,6 @@ var _lodash = require("lodash");
|
|
|
9
9
|
var _MySqlParserVisitor = _interopRequireDefault(require("../../parsers/mysql/MySqlParserVisitor"));
|
|
10
10
|
var _AST = require("../AST");
|
|
11
11
|
var _constants = require("../constants");
|
|
12
|
-
var _utils = require("../../../../model_structure/utils");
|
|
13
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -78,8 +77,7 @@ var MySQLASTGen = /*#__PURE__*/function (_MySQLParserVisitor) {
|
|
|
78
77
|
enums: [],
|
|
79
78
|
tableGroups: [],
|
|
80
79
|
aliases: [],
|
|
81
|
-
project: {}
|
|
82
|
-
records: {}
|
|
80
|
+
project: {}
|
|
83
81
|
};
|
|
84
82
|
return _this;
|
|
85
83
|
}
|
|
@@ -121,10 +119,6 @@ var MySQLASTGen = /*#__PURE__*/function (_MySQLParserVisitor) {
|
|
|
121
119
|
value: function visitSqlStatement(ctx) {
|
|
122
120
|
if (ctx.ddlStatement()) {
|
|
123
121
|
ctx.ddlStatement().accept(this);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (ctx.dmlStatement()) {
|
|
127
|
-
ctx.dmlStatement().accept(this);
|
|
128
122
|
}
|
|
129
123
|
}
|
|
130
124
|
|
|
@@ -222,7 +216,7 @@ var MySQLASTGen = /*#__PURE__*/function (_MySQLParserVisitor) {
|
|
|
222
216
|
// | CREATE TEMPORARY? TABLE ifNotExists? tableName createDefinitions (tableOption (','? tableOption)*)? partitionDefinitions? # columnCreateTable
|
|
223
217
|
}, {
|
|
224
218
|
key: "visitCopyCreateTable",
|
|
225
|
-
value: function visitCopyCreateTable() {
|
|
219
|
+
value: function visitCopyCreateTable(ctx) {
|
|
226
220
|
// not supported
|
|
227
221
|
}
|
|
228
222
|
}, {
|
|
@@ -635,7 +629,7 @@ var MySQLASTGen = /*#__PURE__*/function (_MySQLParserVisitor) {
|
|
|
635
629
|
// uniqueKeyColumnConstraint: UNIQUE KEY?
|
|
636
630
|
}, {
|
|
637
631
|
key: "visitUniqueKeyColumnConstraint",
|
|
638
|
-
value: function visitUniqueKeyColumnConstraint() {
|
|
632
|
+
value: function visitUniqueKeyColumnConstraint(ctx) {
|
|
639
633
|
return {
|
|
640
634
|
kind: _constants.COLUMN_CONSTRAINT_KIND.UNIQUE,
|
|
641
635
|
value: true
|
|
@@ -939,7 +933,7 @@ var MySQLASTGen = /*#__PURE__*/function (_MySQLParserVisitor) {
|
|
|
939
933
|
}
|
|
940
934
|
}, {
|
|
941
935
|
key: "visitCheckTableConstraint",
|
|
942
|
-
value: function visitCheckTableConstraint() {
|
|
936
|
+
value: function visitCheckTableConstraint(ctx) {
|
|
943
937
|
// ignored
|
|
944
938
|
}
|
|
945
939
|
|
|
@@ -1148,161 +1142,6 @@ var MySQLASTGen = /*#__PURE__*/function (_MySQLParserVisitor) {
|
|
|
1148
1142
|
});
|
|
1149
1143
|
table.indexes.push(index);
|
|
1150
1144
|
}
|
|
1151
|
-
|
|
1152
|
-
// dmlStatement
|
|
1153
|
-
// : selectStatement | insertStatement | updateStatement | deleteStatement | replaceStatement |
|
|
1154
|
-
// callStatement | loadDataStatement | loadXmlStatement | doStatement | handlerStatement | valuesStatement | withStatement | tableStatement ;
|
|
1155
|
-
}, {
|
|
1156
|
-
key: "visitDmlStatement",
|
|
1157
|
-
value: function visitDmlStatement(ctx) {
|
|
1158
|
-
if (ctx.insertStatement()) {
|
|
1159
|
-
ctx.insertStatement().accept(this);
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
// insertStatement
|
|
1164
|
-
// : INSERT priority = (LOW_PRIORITY | DELAYED | HIGH_PRIORITY)? IGNORE? INTO? tableName (
|
|
1165
|
-
// PARTITION '(' partitions = uidList? ')'
|
|
1166
|
-
// )? (
|
|
1167
|
-
// ('(' columns = fullColumnNameList? ')')? insertStatementValue (AS? uid)?
|
|
1168
|
-
// | SET setFirst = updatedElement (',' setElements += updatedElement)*
|
|
1169
|
-
// ) (
|
|
1170
|
-
// ON DUPLICATE KEY UPDATE duplicatedFirst = updatedElement (
|
|
1171
|
-
// ',' duplicatedElements += updatedElement
|
|
1172
|
-
// )*
|
|
1173
|
-
// )?
|
|
1174
|
-
// ;
|
|
1175
|
-
}, {
|
|
1176
|
-
key: "visitInsertStatement",
|
|
1177
|
-
value: function visitInsertStatement(ctx) {
|
|
1178
|
-
var _this$data$records$fu;
|
|
1179
|
-
var names = ctx.tableName().accept(this);
|
|
1180
|
-
var tableName = (0, _lodash.last)(names);
|
|
1181
|
-
var schemaName = names.length > 1 ? names[names.length - 2] : undefined;
|
|
1182
|
-
var fullTableName = (0, _utils.getFullTableName)(schemaName, tableName);
|
|
1183
|
-
|
|
1184
|
-
// insert without specified columns
|
|
1185
|
-
var columns = ctx.fullColumnNameList() ? ctx.fullColumnNameList().accept(this) : [];
|
|
1186
|
-
var values = ctx.insertStatementValue().accept(this);
|
|
1187
|
-
if (columns.length === 0 || values.length === 0) {
|
|
1188
|
-
return;
|
|
1189
|
-
}
|
|
1190
|
-
if (!this.data.records[fullTableName]) {
|
|
1191
|
-
this.data.records[fullTableName] = {
|
|
1192
|
-
schemaName: schemaName,
|
|
1193
|
-
tableName: tableName,
|
|
1194
|
-
columns: columns,
|
|
1195
|
-
values: []
|
|
1196
|
-
};
|
|
1197
|
-
}
|
|
1198
|
-
(_this$data$records$fu = this.data.records[fullTableName].values).push.apply(_this$data$records$fu, _toConsumableArray(values));
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
// fullColumnNameList
|
|
1202
|
-
// : fullColumnName (',' fullColumnName)*
|
|
1203
|
-
// ;
|
|
1204
|
-
}, {
|
|
1205
|
-
key: "visitFullColumnNameList",
|
|
1206
|
-
value: function visitFullColumnNameList(ctx) {
|
|
1207
|
-
var _this18 = this;
|
|
1208
|
-
// [ [ 'id' ], [ 'name' ], [ 'email' ], [ 'created_at' ] ]
|
|
1209
|
-
var columns = ctx.fullColumnName().map(function (fullColumn) {
|
|
1210
|
-
return fullColumn.accept(_this18);
|
|
1211
|
-
});
|
|
1212
|
-
return (0, _lodash.flattenDepth)(columns, 1);
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
// insertStatementValue
|
|
1216
|
-
// : selectStatement
|
|
1217
|
-
// | insertFormat = (VALUES | VALUE) '(' expressionsWithDefaults? ')' (
|
|
1218
|
-
// ',' '(' expressionsWithDefaults? ')'
|
|
1219
|
-
// )*
|
|
1220
|
-
// ;
|
|
1221
|
-
}, {
|
|
1222
|
-
key: "visitInsertStatementValue",
|
|
1223
|
-
value: function visitInsertStatementValue(ctx) {
|
|
1224
|
-
var _this19 = this;
|
|
1225
|
-
return ctx.expressionsWithDefaults().map(function (expression) {
|
|
1226
|
-
// [
|
|
1227
|
-
// [ { value: '1', type: 'number' } ],
|
|
1228
|
-
// [ { value: 'Alice', type: 'string' } ],
|
|
1229
|
-
// [ { value: 'alice@host', type: 'string' } ],
|
|
1230
|
-
// [ { value: '2021-01-01', type: 'string' } ],
|
|
1231
|
-
// [ { value: '2021-01-01', type: 'string' } ],
|
|
1232
|
-
// ]
|
|
1233
|
-
var rowValues = expression.accept(_this19);
|
|
1234
|
-
return (0, _lodash.flattenDepth)(rowValues, 1);
|
|
1235
|
-
});
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
// expressionsWithDefaults
|
|
1239
|
-
// : expressionOrDefault (',' expressionOrDefault)*
|
|
1240
|
-
// ;
|
|
1241
|
-
}, {
|
|
1242
|
-
key: "visitExpressionsWithDefaults",
|
|
1243
|
-
value: function visitExpressionsWithDefaults(ctx) {
|
|
1244
|
-
var _this20 = this;
|
|
1245
|
-
return ctx.expressionOrDefault().map(function (expressionOrDefault) {
|
|
1246
|
-
var rawValues = expressionOrDefault.accept(_this20);
|
|
1247
|
-
|
|
1248
|
-
// We get the value of the column (constantExpressionAtom or functionCallExpressionAtom) through:
|
|
1249
|
-
// expression->predicate->expressionAtom
|
|
1250
|
-
var FLATTEN_DEPTH = 3;
|
|
1251
|
-
var rawColumnValues = (0, _lodash.flattenDepth)(rawValues, FLATTEN_DEPTH);
|
|
1252
|
-
// [ { value: '["555-1234", "555-5678"]', type: 'string' } ]
|
|
1253
|
-
return rawColumnValues;
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
// predicate
|
|
1258
|
-
// : predicate NOT? IN '(' (selectStatement | expressions) ')' # inPredicate
|
|
1259
|
-
// | predicate IS nullNotnull # isNullPredicate
|
|
1260
|
-
// | left = predicate comparisonOperator right = predicate # binaryComparisonPredicate
|
|
1261
|
-
// | predicate comparisonOperator quantifier = (ALL | ANY | SOME) '(' selectStatement ')' # subqueryComparisonPredicate
|
|
1262
|
-
// | predicate NOT? BETWEEN predicate AND predicate # betweenPredicate
|
|
1263
|
-
// | predicate SOUNDS LIKE predicate # soundsLikePredicate
|
|
1264
|
-
// | predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)? # likePredicate
|
|
1265
|
-
// | predicate NOT? regex = (REGEXP | RLIKE) predicate # regexpPredicate
|
|
1266
|
-
// | predicate MEMBER OF '(' predicate ')' # jsonMemberOfPredicate
|
|
1267
|
-
// | expressionAtom # expressionAtomPredicate
|
|
1268
|
-
// ;
|
|
1269
|
-
|
|
1270
|
-
// expressionAtom
|
|
1271
|
-
// : constant # constantExpressionAtom
|
|
1272
|
-
// | fullColumnName # fullColumnNameExpressionAtom
|
|
1273
|
-
// | functionCall # functionCallExpressionAtom
|
|
1274
|
-
// | expressionAtom COLLATE collationName # collateExpressionAtom
|
|
1275
|
-
// | mysqlVariable # mysqlVariableExpressionAtom
|
|
1276
|
-
// | unaryOperator expressionAtom # unaryExpressionAtom
|
|
1277
|
-
// | BINARY expressionAtom # binaryExpressionAtom
|
|
1278
|
-
// | LOCAL_ID VAR_ASSIGN expressionAtom # variableAssignExpressionAtom
|
|
1279
|
-
// | '(' expression (',' expression)* ')' # nestedExpressionAtom
|
|
1280
|
-
// | ROW '(' expression (',' expression)+ ')' # nestedRowExpressionAtom
|
|
1281
|
-
// | EXISTS '(' selectStatement ')' # existsExpressionAtom
|
|
1282
|
-
// | '(' selectStatement ')' # subqueryExpressionAtom
|
|
1283
|
-
// | INTERVAL expression intervalType # intervalExpressionAtom
|
|
1284
|
-
// | left = expressionAtom bitOperator right = expressionAtom # bitExpressionAtom
|
|
1285
|
-
// | left = expressionAtom multOperator right = expressionAtom # mathExpressionAtom
|
|
1286
|
-
// | left = expressionAtom addOperator right = expressionAtom # mathExpressionAtom
|
|
1287
|
-
// | left = expressionAtom jsonOperator right = expressionAtom # jsonExpressionAtom
|
|
1288
|
-
// ;
|
|
1289
|
-
|
|
1290
|
-
// functionCall
|
|
1291
|
-
// : specificFunction # specificFunctionCall
|
|
1292
|
-
// | aggregateWindowedFunction # aggregateFunctionCall
|
|
1293
|
-
// | nonAggregateWindowedFunction # nonAggregateFunctionCall
|
|
1294
|
-
// | scalarFunctionName '(' functionArgs? ')' # scalarFunctionCall
|
|
1295
|
-
// | fullId '(' functionArgs? ')' # udfFunctionCall
|
|
1296
|
-
// | passwordFunctionClause # passwordFunctionCall
|
|
1297
|
-
// ;
|
|
1298
|
-
}, {
|
|
1299
|
-
key: "visitFunctionCallExpressionAtom",
|
|
1300
|
-
value: function visitFunctionCallExpressionAtom(ctx) {
|
|
1301
|
-
return {
|
|
1302
|
-
value: ctx.getText(),
|
|
1303
|
-
type: _constants.DATA_TYPE.EXPRESSION
|
|
1304
|
-
};
|
|
1305
|
-
}
|
|
1306
1145
|
}]);
|
|
1307
1146
|
return MySQLASTGen;
|
|
1308
1147
|
}(_MySqlParserVisitor["default"]);
|
|
File without changes
|
|
File without changes
|