@dbml/core 5.1.0 → 5.3.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/lib/export/DbmlExporter.js +3 -2
- package/lib/export/MysqlExporter.js +2 -2
- package/lib/export/OracleExporter.js +2 -2
- package/lib/export/PostgresExporter.js +2 -2
- package/lib/export/SqlServerExporter.js +2 -2
- package/lib/model_structure/element.js +1 -3
- package/lib/parse/ANTLR/ASTGeneration/AST.js +0 -2
- package/lib/parse/ANTLR/ASTGeneration/constants.js +1 -0
- package/lib/parse/ANTLR/ASTGeneration/index.js +16 -3
- package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js +1 -1
- package/lib/parse/ANTLR/ASTGeneration/mssql/README.md +157 -0
- package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js +1 -1
- package/lib/parse/ANTLR/ASTGeneration/mysql/README.md +157 -0
- package/lib/parse/ANTLR/ASTGeneration/oraclesql/OracleSQLASTGen.js +1161 -0
- package/lib/parse/ANTLR/ASTGeneration/oraclesql/README.md +157 -0
- package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.js +2 -3
- package/lib/parse/ANTLR/ASTGeneration/postgres/README.md +157 -0
- package/lib/parse/ANTLR/ASTGeneration/snowflake/README.md +157 -0
- package/lib/parse/ANTLR/ASTGeneration/snowflake/SnowflakeASTGen.js +1 -1
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.g4 +60 -2
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.interp +25 -4
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.js +1235 -1171
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.tokens +2306 -2300
- package/lib/parse/ANTLR/parsers/mysql/MySqlLexerBase.js +52 -0
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.g4 +6 -4
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.interp +15 -3
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.js +2 -2
- package/lib/parse/ANTLR/parsers/mysql/MySqlParser.tokens +2306 -2300
- package/lib/parse/ANTLR/parsers/mysql/MySqlParserVisitor.js +1 -1
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.g4 +2623 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.interp +7475 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.js +3 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.tokens +4934 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexerBase.js +35 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.g4 +9988 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.interp +6174 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.js +3 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.tokens +4934 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserBase.js +64 -0
- package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserVisitor.js +8466 -0
- package/lib/parse/Parser.js +8 -0
- package/lib/parse/buildParser.js +1 -1
- package/lib/parse/databaseGenerator.js +2 -2
- package/lib/parse/error.js +0 -1
- package/lib/parse/mssql/fk_definition/actions.js +1 -1
- package/lib/parse/mssql/index.js +0 -1
- package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +0 -1
- package/lib/parse/mssql/statements/statement_types/alter_table/add/actions.js +0 -2
- package/lib/parse/mssql/statements/statement_types/comments/index.js +2 -2
- package/lib/parse/mssql/utils.js +0 -1
- package/package.json +16 -5
- package/types/import/index.d.ts +1 -1
- package/types/parse/Parser.d.ts +3 -1
|
@@ -0,0 +1,1161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
var _AST = require("../AST");
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
var _helpers = require("../helpers");
|
|
12
|
+
var _error = require("../../../error");
|
|
13
|
+
var _OracleSqlParserVisitor = _interopRequireDefault(require("../../parsers/oraclesql/OracleSqlParserVisitor"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
19
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
21
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
22
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
23
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
25
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
26
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
27
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
28
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
29
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
30
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
31
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
32
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
34
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
35
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
36
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
37
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
38
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
39
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
40
|
+
// We cannot use TABLE_CONSTRAINT_KIND and COLUMN_CONSTRAINT_KIND from '../constants' as their values are indistinguishable from each other
|
|
41
|
+
// For example: TABLE_CONSTRAINT_KIND.UNIQUE === COLUMN_CONSTRAINT_KIND.UNIQUE
|
|
42
|
+
// Therefore, we redefine them to be different
|
|
43
|
+
// TODO: Migrate the other parser to use our version instead
|
|
44
|
+
var TABLE_CONSTRAINT_KIND = {
|
|
45
|
+
FIELD: 'table_field',
|
|
46
|
+
INDEX: 'table_index',
|
|
47
|
+
FK: 'table_fk',
|
|
48
|
+
UNIQUE: 'table_unique',
|
|
49
|
+
PK: 'table_pk',
|
|
50
|
+
DEFAULT: 'table_default',
|
|
51
|
+
CHECK: 'table_check'
|
|
52
|
+
};
|
|
53
|
+
var COLUMN_CONSTRAINT_KIND = {
|
|
54
|
+
NOT_NULL: 'col_not_null',
|
|
55
|
+
NULLABLE: 'col_nullable',
|
|
56
|
+
UNIQUE: 'col_unique',
|
|
57
|
+
PK: 'col_pk',
|
|
58
|
+
DEFAULT: 'col_dbdefault',
|
|
59
|
+
INCREMENT: 'col_increment',
|
|
60
|
+
INLINE_REF: 'col_inline_ref',
|
|
61
|
+
NOTE: 'col_note',
|
|
62
|
+
CHECK: 'col_check'
|
|
63
|
+
};
|
|
64
|
+
var findTable = function findTable(tables, schemaName, tableName) {
|
|
65
|
+
var realSchemaName = schemaName || null;
|
|
66
|
+
var table = tables.find(function (table) {
|
|
67
|
+
var targetSchemaName = table.schemaName || null;
|
|
68
|
+
return targetSchemaName === realSchemaName && table.name === tableName;
|
|
69
|
+
});
|
|
70
|
+
return table;
|
|
71
|
+
};
|
|
72
|
+
var findColumn = function findColumn(table, columnName) {
|
|
73
|
+
var column = table.fields.find(function (field) {
|
|
74
|
+
return field.name === columnName;
|
|
75
|
+
});
|
|
76
|
+
return column;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// `e` is the value returned by `visitExpression`
|
|
80
|
+
var processDefaultExpression = function processDefaultExpression(e) {
|
|
81
|
+
return {
|
|
82
|
+
value: e.type !== _constants.CONSTRAINT_TYPE.COLUMN ? e.value : e.rawValue,
|
|
83
|
+
type: e.type !== _constants.CONSTRAINT_TYPE.COLUMN ? e.type : _constants.DATA_TYPE.EXPRESSION
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// `e` is the value returned by `visitExpression`
|
|
88
|
+
var processIndexExpression = function processIndexExpression(e) {
|
|
89
|
+
var type;
|
|
90
|
+
switch (e.type) {
|
|
91
|
+
case _constants.CONSTRAINT_TYPE.COLUMN:
|
|
92
|
+
type = _constants.CONSTRAINT_TYPE.COLUMN;
|
|
93
|
+
break;
|
|
94
|
+
case _constants.DATA_TYPE.STRING:
|
|
95
|
+
type = _constants.CONSTRAINT_TYPE.STRING;
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
type = _constants.CONSTRAINT_TYPE.EXPRESSION;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
value: e.value.toString(),
|
|
103
|
+
type: type
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
var createCompilerError = function createCompilerError(ctx, message) {
|
|
107
|
+
return _error.CompilerError.create([{
|
|
108
|
+
message: message,
|
|
109
|
+
location: {
|
|
110
|
+
start: {
|
|
111
|
+
line: ctx.start.line,
|
|
112
|
+
column: ctx.start.column + 1
|
|
113
|
+
},
|
|
114
|
+
end: {
|
|
115
|
+
line: ctx.stop.line,
|
|
116
|
+
column: ctx.stop.column + (0, _helpers.getOriginalText)(ctx).length + 1
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}]);
|
|
120
|
+
};
|
|
121
|
+
var unquoteString = function unquoteString(str) {
|
|
122
|
+
var quoteChar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '"';
|
|
123
|
+
return !str.startsWith(quoteChar) ? str : str.slice(1, -1) // Strip off starting and ending quotes
|
|
124
|
+
.replaceAll("".concat(quoteChar).concat(quoteChar), quoteChar); // Unescape quotes, in Oracle, quotes are escaped by doubling it
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Only methods for rules representing whole statements can mutate `data`:
|
|
128
|
+
// * create_table
|
|
129
|
+
// * alter_table
|
|
130
|
+
// * create_index
|
|
131
|
+
// * insert_statement
|
|
132
|
+
// All other methods must be pure
|
|
133
|
+
var OracleSqlASTGen = exports["default"] = /*#__PURE__*/function (_OracleSqlParserVisit) {
|
|
134
|
+
function OracleSqlASTGen() {
|
|
135
|
+
var _this;
|
|
136
|
+
_classCallCheck(this, OracleSqlASTGen);
|
|
137
|
+
_this = _callSuper(this, OracleSqlASTGen);
|
|
138
|
+
_this.data = {
|
|
139
|
+
schemas: [],
|
|
140
|
+
tables: [],
|
|
141
|
+
refs: [],
|
|
142
|
+
enums: [],
|
|
143
|
+
tableGroups: [],
|
|
144
|
+
aliases: [],
|
|
145
|
+
project: {},
|
|
146
|
+
records: []
|
|
147
|
+
};
|
|
148
|
+
return _this;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// sql_script
|
|
152
|
+
// : sql_plus_command_no_semicolon? (
|
|
153
|
+
// (((sql_plus_command SEMICOLON? '/'?) | (unit_statement SEMICOLON '/'?))* (sql_plus_command | unit_statement)) SEMICOLON? '/'?
|
|
154
|
+
// )? EOF
|
|
155
|
+
// ;
|
|
156
|
+
_inherits(OracleSqlASTGen, _OracleSqlParserVisit);
|
|
157
|
+
return _createClass(OracleSqlASTGen, [{
|
|
158
|
+
key: "visitSql_script",
|
|
159
|
+
value: function visitSql_script(ctx) {
|
|
160
|
+
var _ctx$unit_statement,
|
|
161
|
+
_this2 = this;
|
|
162
|
+
(_ctx$unit_statement = ctx.unit_statement()) === null || _ctx$unit_statement === void 0 || _ctx$unit_statement.forEach(function (stmt) {
|
|
163
|
+
return stmt.accept(_this2);
|
|
164
|
+
});
|
|
165
|
+
return this.data;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// unit_statement
|
|
169
|
+
// : create_table
|
|
170
|
+
// | comment_on_table
|
|
171
|
+
// | comment_on_column
|
|
172
|
+
// | alter_table
|
|
173
|
+
// | create_index
|
|
174
|
+
// | data_manipulation_language_statements
|
|
175
|
+
// | <other rules>
|
|
176
|
+
// ;
|
|
177
|
+
}, {
|
|
178
|
+
key: "visitUnit_statement",
|
|
179
|
+
value: function visitUnit_statement(ctx) {
|
|
180
|
+
if (ctx.create_table()) {
|
|
181
|
+
ctx.create_table().accept(this);
|
|
182
|
+
} else if (ctx.comment_on_table()) {
|
|
183
|
+
ctx.comment_on_table().accept(this);
|
|
184
|
+
} else if (ctx.comment_on_column()) {
|
|
185
|
+
ctx.comment_on_column().accept(this);
|
|
186
|
+
} else if (ctx.alter_table()) {
|
|
187
|
+
ctx.alter_table().accept(this);
|
|
188
|
+
} else if (ctx.create_index()) {
|
|
189
|
+
ctx.create_index().accept(this);
|
|
190
|
+
} else if (ctx.data_manipulation_language_statements()) {
|
|
191
|
+
ctx.data_manipulation_language_statements().accept(this);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// data_manipulation_language_statements
|
|
196
|
+
// : insert_statement
|
|
197
|
+
// | <other rules>
|
|
198
|
+
// ;
|
|
199
|
+
}, {
|
|
200
|
+
key: "visitData_manipulation_language_statements",
|
|
201
|
+
value: function visitData_manipulation_language_statements(ctx) {
|
|
202
|
+
if (ctx.insert_statement()) {
|
|
203
|
+
ctx.insert_statement().accept(this);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// create_table
|
|
208
|
+
// : CREATE TABLE (schema_name '.')? table_name
|
|
209
|
+
// (relational_table | <other rules>)
|
|
210
|
+
// | <other rules>
|
|
211
|
+
// ;
|
|
212
|
+
}, {
|
|
213
|
+
key: "visitCreate_table",
|
|
214
|
+
value: function visitCreate_table(ctx) {
|
|
215
|
+
var tableName = ctx.table_name().accept(this);
|
|
216
|
+
var schemaName = ctx.schema_name() ? ctx.schema_name().accept(this) : undefined;
|
|
217
|
+
if (ctx.relational_table()) {
|
|
218
|
+
var _this$data$refs, _this$data$refs2;
|
|
219
|
+
var tableElements = ctx.relational_table().accept(this);
|
|
220
|
+
var _tableElements$reduce = tableElements.reduce(function (acc, ele) {
|
|
221
|
+
var _acc$;
|
|
222
|
+
if (ele.type === TABLE_CONSTRAINT_KIND.FIELD) acc[0].push(ele.value);else if ([TABLE_CONSTRAINT_KIND.INDEX, TABLE_CONSTRAINT_KIND.UNIQUE, TABLE_CONSTRAINT_KIND.PK].includes(ele.type)) acc[1].push(ele.value);else if (ele.type === TABLE_CONSTRAINT_KIND.FK) acc[2].push(ele.value);else if (ele.type === TABLE_CONSTRAINT_KIND.CHECK) (_acc$ = acc[3]).push.apply(_acc$, _toConsumableArray(ele.value.checks));
|
|
223
|
+
return acc;
|
|
224
|
+
}, [[], [], [], []]),
|
|
225
|
+
_tableElements$reduce2 = _slicedToArray(_tableElements$reduce, 4),
|
|
226
|
+
fieldsData = _tableElements$reduce2[0],
|
|
227
|
+
indexes = _tableElements$reduce2[1],
|
|
228
|
+
tableRefs = _tableElements$reduce2[2],
|
|
229
|
+
tableChecks = _tableElements$reduce2[3];
|
|
230
|
+
(_this$data$refs = this.data.refs).push.apply(_this$data$refs, _toConsumableArray((0, _lodash.flatten)(fieldsData.map(function (fieldData) {
|
|
231
|
+
return fieldData.inline_refs.map(function (inlineRef) {
|
|
232
|
+
inlineRef.endpoints[0].tableName = tableName;
|
|
233
|
+
inlineRef.endpoints[0].schemaName = schemaName;
|
|
234
|
+
inlineRef.endpoints[0].fieldNames = [fieldData.field.name];
|
|
235
|
+
return inlineRef;
|
|
236
|
+
});
|
|
237
|
+
}))));
|
|
238
|
+
(_this$data$refs2 = this.data.refs).push.apply(_this$data$refs2, _toConsumableArray(tableRefs.map(function (tableRef) {
|
|
239
|
+
tableRef.endpoints[0].tableName = tableName;
|
|
240
|
+
tableRef.endpoints[0].schemaName = schemaName;
|
|
241
|
+
return tableRef;
|
|
242
|
+
})));
|
|
243
|
+
this.data.tables.push(new _AST.Table({
|
|
244
|
+
name: tableName,
|
|
245
|
+
schemaName: schemaName,
|
|
246
|
+
fields: fieldsData.map(function (fd) {
|
|
247
|
+
return fd.field;
|
|
248
|
+
}),
|
|
249
|
+
indexes: indexes,
|
|
250
|
+
checks: tableChecks
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// relational_table
|
|
256
|
+
// : ('(' relational_property (',' relational_property)* ')')? relational_table_properties?
|
|
257
|
+
// ;
|
|
258
|
+
}, {
|
|
259
|
+
key: "visitRelational_table",
|
|
260
|
+
value: function visitRelational_table(ctx) {
|
|
261
|
+
var _this3 = this;
|
|
262
|
+
if (ctx.relational_property()) {
|
|
263
|
+
return ctx.relational_property().map(function (p) {
|
|
264
|
+
return p.accept(_this3);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return [];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// relational_property
|
|
271
|
+
// : column_definition
|
|
272
|
+
// | out_of_line_constraint
|
|
273
|
+
// | out_of_line_ref_constraint
|
|
274
|
+
// | <other rules>
|
|
275
|
+
// ;
|
|
276
|
+
}, {
|
|
277
|
+
key: "visitRelational_property",
|
|
278
|
+
value: function visitRelational_property(ctx) {
|
|
279
|
+
if (ctx.column_definition()) {
|
|
280
|
+
return ctx.column_definition().accept(this);
|
|
281
|
+
}
|
|
282
|
+
if (ctx.out_of_line_constraint()) {
|
|
283
|
+
return ctx.out_of_line_constraint().accept(this);
|
|
284
|
+
}
|
|
285
|
+
if (ctx.out_of_line_ref_constraint()) {
|
|
286
|
+
return ctx.out_of_line_ref_constraint().accept(this);
|
|
287
|
+
}
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// column_definition
|
|
292
|
+
// : column_name ((datatype | type_name) (COLLATE column_collation_name)?)? SORT? (
|
|
293
|
+
// VISIBLE
|
|
294
|
+
// | INVISIBLE
|
|
295
|
+
// )? (DEFAULT (ON NULL_)? expression | identity_clause)? (ENCRYPT encryption_spec)? (
|
|
296
|
+
// inline_constraint+
|
|
297
|
+
// | inline_ref_constraint
|
|
298
|
+
// )? annotations_clause?
|
|
299
|
+
// ;
|
|
300
|
+
}, {
|
|
301
|
+
key: "visitColumn_definition",
|
|
302
|
+
value: function visitColumn_definition(ctx) {
|
|
303
|
+
var _ctx$datatype,
|
|
304
|
+
_ctx$type_name,
|
|
305
|
+
_this4 = this;
|
|
306
|
+
var name = (0, _lodash.last)(ctx.column_name().accept(this));
|
|
307
|
+
var type = ((_ctx$datatype = ctx.datatype()) === null || _ctx$datatype === void 0 ? void 0 : _ctx$datatype.accept(this)) || ((_ctx$type_name = ctx.type_name()) === null || _ctx$type_name === void 0 ? void 0 : _ctx$type_name.accept(this));
|
|
308
|
+
if (!type) throw createCompilerError(ctx, 'Importing a column definition without a type is not supported');
|
|
309
|
+
var constraints = (ctx.inline_constraint() || []).map(function (c) {
|
|
310
|
+
return c.accept(_this4);
|
|
311
|
+
}).filter(Boolean);
|
|
312
|
+
if (ctx.DEFAULT()) {
|
|
313
|
+
var value = ctx.expression().accept(this);
|
|
314
|
+
constraints.push({
|
|
315
|
+
type: COLUMN_CONSTRAINT_KIND.DEFAULT,
|
|
316
|
+
value: {
|
|
317
|
+
dbdefault: processDefaultExpression(value)
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
if (ctx.identity_clause()) {
|
|
322
|
+
constraints.push({
|
|
323
|
+
type: COLUMN_CONSTRAINT_KIND.INCREMENT,
|
|
324
|
+
value: {
|
|
325
|
+
increment: true
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
var settings = {
|
|
330
|
+
checks: [],
|
|
331
|
+
inline_refs: []
|
|
332
|
+
};
|
|
333
|
+
constraints.forEach(function (constraint) {
|
|
334
|
+
var _settings$checks, _settings$inline_refs;
|
|
335
|
+
switch (constraint.type) {
|
|
336
|
+
case COLUMN_CONSTRAINT_KIND.DEFAULT:
|
|
337
|
+
settings.dbdefault = constraint.value.dbdefault;
|
|
338
|
+
break;
|
|
339
|
+
case COLUMN_CONSTRAINT_KIND.NOT_NULL:
|
|
340
|
+
settings.not_null = true;
|
|
341
|
+
break;
|
|
342
|
+
case COLUMN_CONSTRAINT_KIND.NULLABLE:
|
|
343
|
+
settings.not_null = false;
|
|
344
|
+
break;
|
|
345
|
+
case COLUMN_CONSTRAINT_KIND.PK:
|
|
346
|
+
settings.pk = true;
|
|
347
|
+
break;
|
|
348
|
+
case COLUMN_CONSTRAINT_KIND.UNIQUE:
|
|
349
|
+
settings.unique = true;
|
|
350
|
+
break;
|
|
351
|
+
case COLUMN_CONSTRAINT_KIND.CHECK:
|
|
352
|
+
(_settings$checks = settings.checks).push.apply(_settings$checks, _toConsumableArray(constraint.value.checks));
|
|
353
|
+
break;
|
|
354
|
+
case COLUMN_CONSTRAINT_KIND.INCREMENT:
|
|
355
|
+
settings.increment = true;
|
|
356
|
+
break;
|
|
357
|
+
case COLUMN_CONSTRAINT_KIND.FK:
|
|
358
|
+
(_settings$inline_refs = settings.inline_refs).push.apply(_settings$inline_refs, _toConsumableArray(constraint.value.inline_refs));
|
|
359
|
+
break;
|
|
360
|
+
default:
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
var field = new _AST.Field(_objectSpread({
|
|
364
|
+
name: name,
|
|
365
|
+
type: type
|
|
366
|
+
}, settings));
|
|
367
|
+
return {
|
|
368
|
+
type: TABLE_CONSTRAINT_KIND.FIELD,
|
|
369
|
+
value: {
|
|
370
|
+
field: field,
|
|
371
|
+
inline_refs: settings.inline_refs || []
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// inline_constraint
|
|
377
|
+
// : constraint_name? (
|
|
378
|
+
// NOT? NULL_
|
|
379
|
+
// | (UNIQUE | PRIMARY) KEY?
|
|
380
|
+
// | references_clause
|
|
381
|
+
// | check_constraint
|
|
382
|
+
// ) constraint_state?
|
|
383
|
+
// ;
|
|
384
|
+
}, {
|
|
385
|
+
key: "visitInline_constraint",
|
|
386
|
+
value: function visitInline_constraint(ctx) {
|
|
387
|
+
var _ctx$constraint_name;
|
|
388
|
+
if (ctx.NULL_() && ctx.NOT()) {
|
|
389
|
+
return {
|
|
390
|
+
type: COLUMN_CONSTRAINT_KIND.NOT_NULL,
|
|
391
|
+
value: {
|
|
392
|
+
not_null: true
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
if (ctx.NULL_()) {
|
|
397
|
+
return {
|
|
398
|
+
type: COLUMN_CONSTRAINT_KIND.NULLABLE,
|
|
399
|
+
value: {
|
|
400
|
+
not_null: false
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
if (ctx.UNIQUE()) {
|
|
405
|
+
return {
|
|
406
|
+
type: COLUMN_CONSTRAINT_KIND.UNIQUE,
|
|
407
|
+
value: {
|
|
408
|
+
unique: true
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
if (ctx.PRIMARY()) {
|
|
413
|
+
return {
|
|
414
|
+
type: COLUMN_CONSTRAINT_KIND.PK,
|
|
415
|
+
value: {
|
|
416
|
+
pk: true
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
var name = (_ctx$constraint_name = ctx.constraint_name()) === null || _ctx$constraint_name === void 0 ? void 0 : _ctx$constraint_name.accept(this);
|
|
421
|
+
if (ctx.references_clause()) {
|
|
422
|
+
var ref = ctx.references_clause().accept(this);
|
|
423
|
+
ref.name = name;
|
|
424
|
+
return {
|
|
425
|
+
type: COLUMN_CONSTRAINT_KIND.FK,
|
|
426
|
+
value: {
|
|
427
|
+
inline_refs: [ref]
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
if (ctx.check_constraint()) {
|
|
432
|
+
var checkCtx = ctx.check_constraint();
|
|
433
|
+
checkCtx.isColumn = true;
|
|
434
|
+
var check = checkCtx.accept(this);
|
|
435
|
+
check.value.checks[0].name = name;
|
|
436
|
+
return check;
|
|
437
|
+
}
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// out_of_line_constraint
|
|
442
|
+
// : (
|
|
443
|
+
// ((CONSTRAINT | CONSTRAINTS) constraint_name)? (
|
|
444
|
+
// UNIQUE '(' column_name (',' column_name)* ')'
|
|
445
|
+
// | PRIMARY KEY '(' column_name (',' column_name)* ')'
|
|
446
|
+
// | foreign_key_clause
|
|
447
|
+
// | CHECK '(' condition ')'
|
|
448
|
+
// )
|
|
449
|
+
// )
|
|
450
|
+
// constraint_state?
|
|
451
|
+
// parallel_clause?
|
|
452
|
+
// ;
|
|
453
|
+
}, {
|
|
454
|
+
key: "visitOut_of_line_constraint",
|
|
455
|
+
value: function visitOut_of_line_constraint(ctx) {
|
|
456
|
+
var _this5 = this;
|
|
457
|
+
if (ctx.UNIQUE()) {
|
|
458
|
+
var _ctx$constraint_name2;
|
|
459
|
+
var columns = ctx.column_name().map(function (c) {
|
|
460
|
+
return {
|
|
461
|
+
value: (0, _lodash.last)(c.accept(_this5)),
|
|
462
|
+
type: _constants.CONSTRAINT_TYPE.COLUMN
|
|
463
|
+
};
|
|
464
|
+
});
|
|
465
|
+
return {
|
|
466
|
+
type: TABLE_CONSTRAINT_KIND.UNIQUE,
|
|
467
|
+
value: new _AST.Index({
|
|
468
|
+
columns: columns,
|
|
469
|
+
unique: true,
|
|
470
|
+
name: (_ctx$constraint_name2 = ctx.constraint_name()) === null || _ctx$constraint_name2 === void 0 ? void 0 : _ctx$constraint_name2.accept(this)
|
|
471
|
+
})
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
if (ctx.PRIMARY()) {
|
|
475
|
+
var _ctx$constraint_name3;
|
|
476
|
+
var _columns = ctx.column_name().map(function (c) {
|
|
477
|
+
return {
|
|
478
|
+
value: (0, _lodash.last)(c.accept(_this5)),
|
|
479
|
+
type: _constants.CONSTRAINT_TYPE.COLUMN
|
|
480
|
+
};
|
|
481
|
+
});
|
|
482
|
+
return {
|
|
483
|
+
type: TABLE_CONSTRAINT_KIND.PK,
|
|
484
|
+
value: new _AST.Index({
|
|
485
|
+
columns: _columns,
|
|
486
|
+
pk: true,
|
|
487
|
+
name: (_ctx$constraint_name3 = ctx.constraint_name()) === null || _ctx$constraint_name3 === void 0 ? void 0 : _ctx$constraint_name3.accept(this)
|
|
488
|
+
})
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
if (ctx.foreign_key_clause()) {
|
|
492
|
+
var _ctx$constraint_name4;
|
|
493
|
+
var ref = ctx.foreign_key_clause().accept(this);
|
|
494
|
+
ref.value.name = (_ctx$constraint_name4 = ctx.constraint_name()) === null || _ctx$constraint_name4 === void 0 ? void 0 : _ctx$constraint_name4.accept(this);
|
|
495
|
+
return ref;
|
|
496
|
+
}
|
|
497
|
+
if (ctx.condition()) {
|
|
498
|
+
var _ctx$constraint_name5;
|
|
499
|
+
var expression = (0, _helpers.getOriginalText)(ctx.condition());
|
|
500
|
+
return {
|
|
501
|
+
type: TABLE_CONSTRAINT_KIND.CHECK,
|
|
502
|
+
value: {
|
|
503
|
+
checks: [{
|
|
504
|
+
name: (_ctx$constraint_name5 = ctx.constraint_name()) === null || _ctx$constraint_name5 === void 0 ? void 0 : _ctx$constraint_name5.accept(this),
|
|
505
|
+
expression: expression
|
|
506
|
+
}]
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// out_of_line_ref_constraint
|
|
514
|
+
// : (CONSTRAINT constraint_name)? FOREIGN KEY '(' (','? ref_col_or_attr = regular_id)+ ')' references_clause constraint_state?
|
|
515
|
+
// | <other rules>
|
|
516
|
+
// ;
|
|
517
|
+
}, {
|
|
518
|
+
key: "visitOut_of_line_ref_constraint",
|
|
519
|
+
value: function visitOut_of_line_ref_constraint(ctx) {
|
|
520
|
+
var _ctx$constraint_name6,
|
|
521
|
+
_this6 = this;
|
|
522
|
+
var refName = (_ctx$constraint_name6 = ctx.constraint_name()) === null || _ctx$constraint_name6 === void 0 ? void 0 : _ctx$constraint_name6.accept(this);
|
|
523
|
+
var firstFieldNames = ctx.regular_id().map(function (c) {
|
|
524
|
+
return c.accept(_this6);
|
|
525
|
+
});
|
|
526
|
+
var ref = ctx.references_clause().accept(this);
|
|
527
|
+
ref.endpoints[0].fieldNames = firstFieldNames;
|
|
528
|
+
if (refName) {
|
|
529
|
+
ref.name = refName;
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
type: TABLE_CONSTRAINT_KIND.FK,
|
|
533
|
+
value: ref
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// foreign_key_clause
|
|
538
|
+
// : FOREIGN KEY paren_column_list references_clause on_delete_clause?
|
|
539
|
+
// ;
|
|
540
|
+
}, {
|
|
541
|
+
key: "visitForeign_key_clause",
|
|
542
|
+
value: function visitForeign_key_clause(ctx) {
|
|
543
|
+
var firstFieldNames = ctx.paren_column_list().accept(this).map(function (c) {
|
|
544
|
+
return (0, _lodash.last)(c);
|
|
545
|
+
});
|
|
546
|
+
var ref = ctx.references_clause().accept(this);
|
|
547
|
+
ref.endpoints[0].fieldNames = firstFieldNames;
|
|
548
|
+
if (ctx.on_delete_clause()) {
|
|
549
|
+
ref.onDelete = ctx.on_delete_clause().accept(this);
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
type: TABLE_CONSTRAINT_KIND.FK,
|
|
553
|
+
value: ref
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// references_clause
|
|
558
|
+
// : REFERENCES tableview_name paren_column_list? (ON DELETE (CASCADE | SET NULL_))?
|
|
559
|
+
// ;
|
|
560
|
+
}, {
|
|
561
|
+
key: "visitReferences_clause",
|
|
562
|
+
value: function visitReferences_clause(ctx) {
|
|
563
|
+
if (!ctx.paren_column_list()) throw createCompilerError(ctx.tableview_name(), 'Importing a foreign key with implicit referenced columns is not supported');
|
|
564
|
+
var names = ctx.tableview_name().accept(this);
|
|
565
|
+
var refTableName = (0, _lodash.last)(names);
|
|
566
|
+
var refSchemaName = names.length > 1 ? names[names.length - 2] : undefined;
|
|
567
|
+
var secondFieldNames = ctx.paren_column_list().accept(this).map(function (c) {
|
|
568
|
+
return (0, _lodash.last)(c);
|
|
569
|
+
});
|
|
570
|
+
return new _AST.Ref({
|
|
571
|
+
endpoints: [new _AST.Endpoint({
|
|
572
|
+
tableName: null,
|
|
573
|
+
schemaName: null,
|
|
574
|
+
fieldNames: [],
|
|
575
|
+
relation: '*'
|
|
576
|
+
}), new _AST.Endpoint({
|
|
577
|
+
tableName: refTableName,
|
|
578
|
+
schemaName: refSchemaName,
|
|
579
|
+
fieldNames: secondFieldNames,
|
|
580
|
+
relation: '1'
|
|
581
|
+
})]
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// on_delete_clause
|
|
586
|
+
// : ON DELETE (CASCADE | SET NULL_)
|
|
587
|
+
// ;
|
|
588
|
+
}, {
|
|
589
|
+
key: "visitOn_delete_clause",
|
|
590
|
+
value: function visitOn_delete_clause(ctx) {
|
|
591
|
+
if (ctx.CASCADE()) return 'cascade';
|
|
592
|
+
if (ctx.SET() && ctx.NULL_()) return 'set null';
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// check_constraint
|
|
597
|
+
// : CHECK '(' condition ')'
|
|
598
|
+
// ;
|
|
599
|
+
}, {
|
|
600
|
+
key: "visitCheck_constraint",
|
|
601
|
+
value: function visitCheck_constraint(ctx) {
|
|
602
|
+
var expression = (0, _helpers.getOriginalText)(ctx.condition());
|
|
603
|
+
return {
|
|
604
|
+
type: ctx.isColumn ? COLUMN_CONSTRAINT_KIND.CHECK : TABLE_CONSTRAINT_KIND.CHECK,
|
|
605
|
+
value: {
|
|
606
|
+
checks: [{
|
|
607
|
+
expression: expression
|
|
608
|
+
}]
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
}, {
|
|
613
|
+
key: "visitColumn_list",
|
|
614
|
+
value: function visitColumn_list(ctx) {
|
|
615
|
+
var _this7 = this;
|
|
616
|
+
return ctx.column_name().map(function (c) {
|
|
617
|
+
return c.accept(_this7);
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// tableview_name
|
|
622
|
+
// : identifier ('.' id_expression)? (
|
|
623
|
+
// AT_SIGN link_name
|
|
624
|
+
// | /*TODO{!(input.LA(2) == BY)}?*/ partition_extension_clause
|
|
625
|
+
// )?
|
|
626
|
+
// | xmltable outer_join_sign?
|
|
627
|
+
// ;
|
|
628
|
+
}, {
|
|
629
|
+
key: "visitTableview_name",
|
|
630
|
+
value: function visitTableview_name(ctx) {
|
|
631
|
+
var schema = ctx.id_expression() ? [ctx.identifier().accept(this)] : [];
|
|
632
|
+
var table = ctx.id_expression() ? ctx.id_expression().accept(this) : ctx.identifier().accept(this);
|
|
633
|
+
return [].concat(schema, [table]);
|
|
634
|
+
}
|
|
635
|
+
}, {
|
|
636
|
+
key: "visitSchema_name",
|
|
637
|
+
value: function visitSchema_name(ctx) {
|
|
638
|
+
return ctx.identifier().accept(this);
|
|
639
|
+
}
|
|
640
|
+
}, {
|
|
641
|
+
key: "visitTable_name",
|
|
642
|
+
value: function visitTable_name(ctx) {
|
|
643
|
+
return ctx.identifier().accept(this);
|
|
644
|
+
}
|
|
645
|
+
}, {
|
|
646
|
+
key: "visitColumn_name",
|
|
647
|
+
value: function visitColumn_name(ctx) {
|
|
648
|
+
var _this8 = this;
|
|
649
|
+
return [ctx.identifier().accept(this)].concat(ctx.id_expression().map(function (i) {
|
|
650
|
+
return i.accept(_this8);
|
|
651
|
+
}));
|
|
652
|
+
}
|
|
653
|
+
}, {
|
|
654
|
+
key: "visitIdentifier",
|
|
655
|
+
value: function visitIdentifier(ctx) {
|
|
656
|
+
var text = (0, _helpers.getOriginalText)(ctx);
|
|
657
|
+
return unquoteString(text);
|
|
658
|
+
}
|
|
659
|
+
}, {
|
|
660
|
+
key: "visitType_name",
|
|
661
|
+
value: function visitType_name(ctx) {
|
|
662
|
+
var _this9 = this;
|
|
663
|
+
var names = ctx.id_expression().map(function (i) {
|
|
664
|
+
return i.accept(_this9);
|
|
665
|
+
});
|
|
666
|
+
var typeName = (0, _lodash.last)(names);
|
|
667
|
+
var schemaName = names.length > 1 ? names[names.length - 2] : undefined;
|
|
668
|
+
return {
|
|
669
|
+
type_name: typeName,
|
|
670
|
+
schemaName: schemaName
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
}, {
|
|
674
|
+
key: "visitDatatype",
|
|
675
|
+
value: function visitDatatype(ctx) {
|
|
676
|
+
var typeName = (0, _helpers.getOriginalText)(ctx);
|
|
677
|
+
return {
|
|
678
|
+
type_name: unquoteString(typeName)
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// comment_on_table
|
|
683
|
+
// : COMMENT ON TABLE tableview_name IS quoted_string
|
|
684
|
+
// ;
|
|
685
|
+
}, {
|
|
686
|
+
key: "visitComment_on_table",
|
|
687
|
+
value: function visitComment_on_table(ctx) {
|
|
688
|
+
var names = ctx.tableview_name().accept(this);
|
|
689
|
+
var tableName = (0, _lodash.last)(names);
|
|
690
|
+
var schemaName = names.length > 1 ? names[names.length - 2] : undefined;
|
|
691
|
+
var table = findTable(this.data.tables, schemaName, tableName);
|
|
692
|
+
if (!table) {
|
|
693
|
+
throw createCompilerError(ctx.tableview_name(), "Table \"".concat(tableName, "\" not found"));
|
|
694
|
+
}
|
|
695
|
+
var note = ctx.quoted_string().accept(this);
|
|
696
|
+
table.note = {
|
|
697
|
+
value: note
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// comment_on_column
|
|
702
|
+
// : COMMENT ON COLUMN column_name IS quoted_string
|
|
703
|
+
// ;
|
|
704
|
+
}, {
|
|
705
|
+
key: "visitComment_on_column",
|
|
706
|
+
value: function visitComment_on_column(ctx) {
|
|
707
|
+
var names = ctx.column_name().accept(this);
|
|
708
|
+
var columnName = (0, _lodash.last)(names);
|
|
709
|
+
names.pop();
|
|
710
|
+
var tableName = (0, _lodash.last)(names);
|
|
711
|
+
names.pop();
|
|
712
|
+
var schemaName = (0, _lodash.last)(names);
|
|
713
|
+
var table = findTable(this.data.tables, schemaName, tableName);
|
|
714
|
+
if (!table) {
|
|
715
|
+
throw createCompilerError(ctx.column_name(), "Table \"".concat(tableName, "\" not found"));
|
|
716
|
+
}
|
|
717
|
+
var field = findColumn(table, columnName);
|
|
718
|
+
if (!field) {
|
|
719
|
+
throw createCompilerError(ctx.column_name(), "Column \"".concat(columnName, "\" not found in table \"").concat(tableName, "\""));
|
|
720
|
+
}
|
|
721
|
+
var note = ctx.quoted_string().accept(this);
|
|
722
|
+
field.note = {
|
|
723
|
+
value: note
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// alter_table
|
|
728
|
+
// : ALTER TABLE tableview_name memoptimize_read_write_clause* (constraint_clauses | column_clauses | <other rules>) ((enable_disable_clause | enable_or_disable (TABLE LOCK | ALL TRIGGERS))+)?
|
|
729
|
+
|
|
730
|
+
// ;
|
|
731
|
+
}, {
|
|
732
|
+
key: "visitAlter_table",
|
|
733
|
+
value: function visitAlter_table(ctx) {
|
|
734
|
+
var _this0 = this;
|
|
735
|
+
var names = ctx.tableview_name().accept(this);
|
|
736
|
+
var tableName = (0, _lodash.last)(names);
|
|
737
|
+
var schemaName = names.length > 1 ? names[names.length - 2] : undefined;
|
|
738
|
+
var table = findTable(this.data.tables, schemaName, tableName);
|
|
739
|
+
if (!table) {
|
|
740
|
+
throw createCompilerError(ctx.tableview_name(), "Table \"".concat(tableName, "\" not found"));
|
|
741
|
+
}
|
|
742
|
+
function handleConstraint(column, constraint) {
|
|
743
|
+
var _table$checks, _column$checks;
|
|
744
|
+
switch (constraint.type) {
|
|
745
|
+
case TABLE_CONSTRAINT_KIND.FK:
|
|
746
|
+
case COLUMN_CONSTRAINT_KIND.FK:
|
|
747
|
+
constraint.value.endpoints[0].tableName = tableName;
|
|
748
|
+
constraint.value.endpoints[0].schemaName = schemaName;
|
|
749
|
+
this.data.refs.push(constraint.value);
|
|
750
|
+
break;
|
|
751
|
+
case TABLE_CONSTRAINT_KIND.CHECK:
|
|
752
|
+
if (!table.checks) table.checks = [];
|
|
753
|
+
(_table$checks = table.checks).push.apply(_table$checks, _toConsumableArray(constraint.value.checks));
|
|
754
|
+
break;
|
|
755
|
+
case COLUMN_CONSTRAINT_KIND.CHECK:
|
|
756
|
+
if (!column.checks) table.checks = [];
|
|
757
|
+
(_column$checks = column.checks).push.apply(_column$checks, _toConsumableArray(constraint.value.checks));
|
|
758
|
+
break;
|
|
759
|
+
case COLUMN_CONSTRAINT_KIND.PK:
|
|
760
|
+
column.pk = true;
|
|
761
|
+
column.unique = undefined;
|
|
762
|
+
break;
|
|
763
|
+
case COLUMN_CONSTRAINT_KIND.UNIQUE:
|
|
764
|
+
column.unique = true;
|
|
765
|
+
break;
|
|
766
|
+
case TABLE_CONSTRAINT_KIND.UNIQUE:
|
|
767
|
+
case TABLE_CONSTRAINT_KIND.INDEX:
|
|
768
|
+
case TABLE_CONSTRAINT_KIND.PK:
|
|
769
|
+
if (!table.indexes) table.indexes = [];
|
|
770
|
+
table.indexes.push(constraint.value);
|
|
771
|
+
break;
|
|
772
|
+
case COLUMN_CONSTRAINT_KIND.DEFAULT:
|
|
773
|
+
column.dbdefault = constraint.value.dbdefault;
|
|
774
|
+
break;
|
|
775
|
+
case COLUMN_CONSTRAINT_KIND.NOT_NULL:
|
|
776
|
+
column.not_null = true;
|
|
777
|
+
break;
|
|
778
|
+
case COLUMN_CONSTRAINT_KIND.NULLABLE:
|
|
779
|
+
column.not_null = false;
|
|
780
|
+
break;
|
|
781
|
+
case COLUMN_CONSTRAINT_KIND.INCREMENT:
|
|
782
|
+
column.increment = true;
|
|
783
|
+
break;
|
|
784
|
+
default:
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (ctx.constraint_clauses() || ctx.column_clauses()) {
|
|
788
|
+
var res = ctx.constraint_clauses() ? [{
|
|
789
|
+
column: null,
|
|
790
|
+
constraints: ctx.constraint_clauses().accept(this)
|
|
791
|
+
}] : ctx.column_clauses().accept(this);
|
|
792
|
+
res.forEach(function (r) {
|
|
793
|
+
var column = r.column !== null ? findColumn(table, r.column) : null;
|
|
794
|
+
if (r.column !== null && !column) {
|
|
795
|
+
throw createCompilerError(ctx.tableview_name(), "Column \"".concat(r.column, "\" not found on Table \"").concat(tableName, "\""));
|
|
796
|
+
}
|
|
797
|
+
r.constraints.forEach(function (c) {
|
|
798
|
+
return handleConstraint.bind(_this0)(column, c);
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// column_clauses
|
|
805
|
+
// : add_modify_drop_column_clauses
|
|
806
|
+
// | <other rules>
|
|
807
|
+
// ;
|
|
808
|
+
}, {
|
|
809
|
+
key: "visitColumn_clauses",
|
|
810
|
+
value: function visitColumn_clauses(ctx) {
|
|
811
|
+
if (ctx.add_modify_drop_column_clauses()) {
|
|
812
|
+
return ctx.add_modify_drop_column_clauses().accept(this);
|
|
813
|
+
}
|
|
814
|
+
return [];
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// add_modify_drop_column_clauses
|
|
818
|
+
// : (constraint_clauses | add_column_clause | modify_column_clauses | drop_column_clause)+
|
|
819
|
+
// ;
|
|
820
|
+
}, {
|
|
821
|
+
key: "visitAdd_modify_drop_column_clauses",
|
|
822
|
+
value: function visitAdd_modify_drop_column_clauses(ctx) {
|
|
823
|
+
var _this1 = this;
|
|
824
|
+
var constraints = [];
|
|
825
|
+
if (ctx.constraint_clauses()) {
|
|
826
|
+
constraints.push({
|
|
827
|
+
column: null,
|
|
828
|
+
constraints: ctx.constraint_clauses().flatMap(function (c) {
|
|
829
|
+
return c.accept(_this1);
|
|
830
|
+
})
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
if (ctx.modify_column_clauses()) {
|
|
834
|
+
constraints.push.apply(constraints, _toConsumableArray(ctx.modify_column_clauses().flatMap(function (c) {
|
|
835
|
+
return c.accept(_this1);
|
|
836
|
+
})));
|
|
837
|
+
}
|
|
838
|
+
return constraints;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// modify_column_clauses
|
|
842
|
+
// : MODIFY (
|
|
843
|
+
// '(' modify_col_properties (',' modify_col_properties)* ')'
|
|
844
|
+
// | '(' modify_col_visibility (',' modify_col_visibility)* ')'
|
|
845
|
+
// | modify_col_properties
|
|
846
|
+
// | modify_col_visibility
|
|
847
|
+
// | modify_col_substitutable
|
|
848
|
+
// )
|
|
849
|
+
// ;
|
|
850
|
+
}, {
|
|
851
|
+
key: "visitModify_column_clauses",
|
|
852
|
+
value: function visitModify_column_clauses(ctx) {
|
|
853
|
+
var _this10 = this;
|
|
854
|
+
return ctx.modify_col_properties().map(function (c) {
|
|
855
|
+
return c.accept(_this10);
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// modify_col_properties
|
|
860
|
+
// : column_name datatype? (DEFAULT (ON NULL_)? expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? annotations_clause?
|
|
861
|
+
// ;
|
|
862
|
+
}, {
|
|
863
|
+
key: "visitModify_col_properties",
|
|
864
|
+
value: function visitModify_col_properties(ctx) {
|
|
865
|
+
var _this11 = this;
|
|
866
|
+
var constraints = [];
|
|
867
|
+
var columnName = (0, _lodash.last)(ctx.column_name().accept(this));
|
|
868
|
+
if (ctx.DEFAULT()) {
|
|
869
|
+
var expression = ctx.expression().accept(this);
|
|
870
|
+
constraints.push({
|
|
871
|
+
type: COLUMN_CONSTRAINT_KIND.DEFAULT,
|
|
872
|
+
value: {
|
|
873
|
+
dbdefault: processDefaultExpression(expression)
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
} else if (ctx.inline_constraint()) {
|
|
877
|
+
constraints.push.apply(constraints, _toConsumableArray(ctx.inline_constraint().map(function (c) {
|
|
878
|
+
return c.accept(_this11);
|
|
879
|
+
})));
|
|
880
|
+
}
|
|
881
|
+
return {
|
|
882
|
+
column: columnName,
|
|
883
|
+
constraints: constraints
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// constraint_clauses
|
|
888
|
+
// : ADD '(' (out_of_line_constraint (',' out_of_line_constraint)* | out_of_line_ref_constraint) ')'
|
|
889
|
+
// | ADD (out_of_line_constraint | out_of_line_ref_constraint)
|
|
890
|
+
// | <other rules>
|
|
891
|
+
// ;
|
|
892
|
+
}, {
|
|
893
|
+
key: "visitConstraint_clauses",
|
|
894
|
+
value: function visitConstraint_clauses(ctx) {
|
|
895
|
+
var _this12 = this;
|
|
896
|
+
if (ctx.out_of_line_constraint()) {
|
|
897
|
+
return ctx.out_of_line_constraint().map(function (c) {
|
|
898
|
+
return c.accept(_this12);
|
|
899
|
+
}).filter(Boolean);
|
|
900
|
+
}
|
|
901
|
+
if (ctx.out_of_line_ref_constraint()) {
|
|
902
|
+
return [ctx.out_of_line_ref_constraint().accept(this)];
|
|
903
|
+
}
|
|
904
|
+
return [];
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// create_index
|
|
908
|
+
// : CREATE (UNIQUE | BITMAP)? INDEX index_name (IF NOT EXISTS)? ON (
|
|
909
|
+
// cluster_index_clause
|
|
910
|
+
// | table_index_clause
|
|
911
|
+
// | bitmap_join_index_clause
|
|
912
|
+
// ) (USABLE | UNUSABLE)? ((DEFERRED | IMMEDIATE) INVALIDATION)?
|
|
913
|
+
// ;
|
|
914
|
+
}, {
|
|
915
|
+
key: "visitCreate_index",
|
|
916
|
+
value: function visitCreate_index(ctx) {
|
|
917
|
+
if (!ctx.table_index_clause()) return;
|
|
918
|
+
var unique = !!ctx.UNIQUE();
|
|
919
|
+
var bitmap = !!ctx.BITMAP();
|
|
920
|
+
var indexName = ctx.index_name().accept(this);
|
|
921
|
+
var _ctx$table_index_clau = ctx.table_index_clause().accept(this),
|
|
922
|
+
names = _ctx$table_index_clau.names,
|
|
923
|
+
columns = _ctx$table_index_clau.columns;
|
|
924
|
+
var tableName = (0, _lodash.last)(names);
|
|
925
|
+
var schemaName = names.length > 1 ? names[names.length - 2] : undefined;
|
|
926
|
+
var table = findTable(this.data.tables, schemaName, tableName);
|
|
927
|
+
if (!table) {
|
|
928
|
+
throw createCompilerError(ctx.table_index_clause(), "Table ".concat(tableName, " not found"));
|
|
929
|
+
}
|
|
930
|
+
if (!table.indexes) table.indexes = [];
|
|
931
|
+
table.indexes.push(new _AST.Index({
|
|
932
|
+
name: indexName,
|
|
933
|
+
columns: columns,
|
|
934
|
+
unique: unique,
|
|
935
|
+
type: bitmap ? 'bitmap' : undefined
|
|
936
|
+
}));
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// table_index_clause
|
|
940
|
+
// : tableview_name table_alias? '(' index_expr (ASC | DESC)? (',' index_expr (ASC | DESC)?)* ')' index_properties?
|
|
941
|
+
// ;
|
|
942
|
+
}, {
|
|
943
|
+
key: "visitTable_index_clause",
|
|
944
|
+
value: function visitTable_index_clause(ctx) {
|
|
945
|
+
var _this13 = this;
|
|
946
|
+
var names = ctx.tableview_name().accept(this);
|
|
947
|
+
var columns = ctx.index_expr().map(function (i) {
|
|
948
|
+
return i.accept(_this13);
|
|
949
|
+
});
|
|
950
|
+
return {
|
|
951
|
+
names: names,
|
|
952
|
+
columns: columns
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// constraint_name
|
|
957
|
+
// : id_expression
|
|
958
|
+
// ;
|
|
959
|
+
}, {
|
|
960
|
+
key: "visitConstraint_name",
|
|
961
|
+
value: function visitConstraint_name(ctx) {
|
|
962
|
+
return unquoteString((0, _helpers.getOriginalText)(ctx));
|
|
963
|
+
}
|
|
964
|
+
}, {
|
|
965
|
+
key: "visitIndex_name",
|
|
966
|
+
value: function visitIndex_name(ctx) {
|
|
967
|
+
return ctx.identifier().accept(this);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
// index_expr
|
|
971
|
+
// : column_name
|
|
972
|
+
// | expression
|
|
973
|
+
// ;
|
|
974
|
+
}, {
|
|
975
|
+
key: "visitIndex_expr",
|
|
976
|
+
value: function visitIndex_expr(ctx) {
|
|
977
|
+
if (ctx.expression()) {
|
|
978
|
+
var expression = processIndexExpression(ctx.expression().accept(this));
|
|
979
|
+
return {
|
|
980
|
+
value: expression.value,
|
|
981
|
+
type: expression.type
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
var columnName = (0, _lodash.last)(ctx.column_name().accept(this));
|
|
985
|
+
return {
|
|
986
|
+
value: columnName,
|
|
987
|
+
type: _constants.CONSTRAINT_TYPE.COLUMN
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// insert_statement
|
|
992
|
+
// : INSERT (single_table_insert | <other rules>)
|
|
993
|
+
// ;
|
|
994
|
+
}, {
|
|
995
|
+
key: "visitInsert_statement",
|
|
996
|
+
value: function visitInsert_statement(ctx) {
|
|
997
|
+
if (ctx.single_table_insert()) {
|
|
998
|
+
ctx.single_table_insert().accept(this);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// single_table_insert
|
|
1003
|
+
// : insert_into_clause (values_clause | <other rules>)
|
|
1004
|
+
// ;
|
|
1005
|
+
}, {
|
|
1006
|
+
key: "visitSingle_table_insert",
|
|
1007
|
+
value: function visitSingle_table_insert(ctx) {
|
|
1008
|
+
var intoClause = ctx.insert_into_clause().accept(this);
|
|
1009
|
+
var valuesClause = ctx.values_clause().accept(this);
|
|
1010
|
+
if (intoClause && valuesClause) {
|
|
1011
|
+
var tableName = intoClause.tableName,
|
|
1012
|
+
schemaName = intoClause.schemaName,
|
|
1013
|
+
columns = intoClause.columns;
|
|
1014
|
+
var values = valuesClause.values;
|
|
1015
|
+
var record = new _AST.TableRecord({
|
|
1016
|
+
schemaName: schemaName,
|
|
1017
|
+
tableName: tableName,
|
|
1018
|
+
columns: columns,
|
|
1019
|
+
values: values
|
|
1020
|
+
});
|
|
1021
|
+
this.data.records.push(record);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// insert_into_clause
|
|
1026
|
+
// : INTO general_table_ref paren_column_list?
|
|
1027
|
+
// ;
|
|
1028
|
+
}, {
|
|
1029
|
+
key: "visitInsert_into_clause",
|
|
1030
|
+
value: function visitInsert_into_clause(ctx) {
|
|
1031
|
+
var names = ctx.general_table_ref().accept(this);
|
|
1032
|
+
var tableName = (0, _lodash.last)(names);
|
|
1033
|
+
var schemaName = names.length > 1 ? names[names.length - 2] : undefined;
|
|
1034
|
+
var columns = ctx.paren_column_list() ? ctx.paren_column_list().accept(this).map(function (c) {
|
|
1035
|
+
return (0, _lodash.last)(c);
|
|
1036
|
+
}) : [];
|
|
1037
|
+
return {
|
|
1038
|
+
tableName: tableName,
|
|
1039
|
+
schemaName: schemaName,
|
|
1040
|
+
columns: columns
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
}, {
|
|
1044
|
+
key: "visitGeneral_table_ref",
|
|
1045
|
+
value: function visitGeneral_table_ref(ctx) {
|
|
1046
|
+
return ctx.dml_table_expression_clause().accept(this);
|
|
1047
|
+
}
|
|
1048
|
+
}, {
|
|
1049
|
+
key: "visitDml_table_expression_clause",
|
|
1050
|
+
value: function visitDml_table_expression_clause(ctx) {
|
|
1051
|
+
if (ctx.tableview_name()) {
|
|
1052
|
+
return ctx.tableview_name().accept(this);
|
|
1053
|
+
}
|
|
1054
|
+
return [];
|
|
1055
|
+
}
|
|
1056
|
+
}, {
|
|
1057
|
+
key: "visitParen_column_list",
|
|
1058
|
+
value: function visitParen_column_list(ctx) {
|
|
1059
|
+
return ctx.column_list().accept(this);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
// values_clause
|
|
1063
|
+
// : VALUES '(' expressions_ ')'
|
|
1064
|
+
// ;
|
|
1065
|
+
}, {
|
|
1066
|
+
key: "visitValues_clause",
|
|
1067
|
+
value: function visitValues_clause(ctx) {
|
|
1068
|
+
var expressions = ctx.expressions_().accept(this);
|
|
1069
|
+
return {
|
|
1070
|
+
values: [expressions.map(function (e) {
|
|
1071
|
+
return {
|
|
1072
|
+
value: e.type !== _constants.CONSTRAINT_TYPE.COLUMN ? e.value : e.rawValue,
|
|
1073
|
+
type: e.type !== _constants.CONSTRAINT_TYPE.COLUMN ? e.type : _constants.DATA_TYPE.EXPRESSION
|
|
1074
|
+
};
|
|
1075
|
+
})]
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
}, {
|
|
1079
|
+
key: "visitExpressions_",
|
|
1080
|
+
value: function visitExpressions_(ctx) {
|
|
1081
|
+
var _this14 = this;
|
|
1082
|
+
return ctx.expression().map(function (e) {
|
|
1083
|
+
return e.accept(_this14);
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
}, {
|
|
1087
|
+
key: "visitId_expression",
|
|
1088
|
+
value: function visitId_expression(ctx) {
|
|
1089
|
+
var text = (0, _helpers.getOriginalText)(ctx);
|
|
1090
|
+
return unquoteString(text);
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// expression
|
|
1094
|
+
// : CHAR_STRING
|
|
1095
|
+
// | TRUE
|
|
1096
|
+
// | FALSE
|
|
1097
|
+
// | NULL_
|
|
1098
|
+
// | APPROXIMATE_NUM_LIT
|
|
1099
|
+
// | UNSIGNED_INTEGER
|
|
1100
|
+
// | column_name
|
|
1101
|
+
// | cursor_expression
|
|
1102
|
+
// | logical_expression
|
|
1103
|
+
// ;
|
|
1104
|
+
}, {
|
|
1105
|
+
key: "visitExpression",
|
|
1106
|
+
value: function visitExpression(ctx) {
|
|
1107
|
+
var value = (0, _helpers.getOriginalText)(ctx);
|
|
1108
|
+
if (ctx.CHAR_STRING()) {
|
|
1109
|
+
return {
|
|
1110
|
+
type: _constants.DATA_TYPE.STRING,
|
|
1111
|
+
value: unquoteString(value, "'") // string literals use single quotes
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
if (ctx.TRUE()) {
|
|
1115
|
+
return {
|
|
1116
|
+
type: _constants.DATA_TYPE.BOOLEAN,
|
|
1117
|
+
value: true
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
if (ctx.FALSE()) {
|
|
1121
|
+
return {
|
|
1122
|
+
type: _constants.DATA_TYPE.BOOLEAN,
|
|
1123
|
+
value: false
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
if (ctx.NULL_()) {
|
|
1127
|
+
return {
|
|
1128
|
+
type: _constants.DATA_TYPE.BOOLEAN,
|
|
1129
|
+
value: null
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
if (ctx.APPROXIMATE_NUM_LIT() || ctx.UNSIGNED_INTEGER()) {
|
|
1133
|
+
return {
|
|
1134
|
+
type: _constants.DATA_TYPE.NUMBER,
|
|
1135
|
+
value: parseFloat(value)
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
if (ctx.column_name()) {
|
|
1139
|
+
return {
|
|
1140
|
+
type: _constants.CONSTRAINT_TYPE.COLUMN,
|
|
1141
|
+
rawValue: unquoteString(value),
|
|
1142
|
+
value: unquoteString((0, _helpers.getOriginalText)(ctx.column_name()))
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
return {
|
|
1146
|
+
type: _constants.CONSTRAINT_TYPE.EXPRESSION,
|
|
1147
|
+
value: value
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
}, {
|
|
1151
|
+
key: "visitQuoted_string",
|
|
1152
|
+
value: function visitQuoted_string(ctx) {
|
|
1153
|
+
return unquoteString((0, _helpers.getOriginalText)(ctx), "'"); // string literals use single quotes
|
|
1154
|
+
}
|
|
1155
|
+
}, {
|
|
1156
|
+
key: "visitRegular_id",
|
|
1157
|
+
value: function visitRegular_id(ctx) {
|
|
1158
|
+
return unquoteString((0, _helpers.getOriginalText)(ctx), '"');
|
|
1159
|
+
}
|
|
1160
|
+
}]);
|
|
1161
|
+
}(_OracleSqlParserVisitor["default"]);
|