@dbml/core 11.0.2-arch.0.0 → 11.0.2-arch.0.2

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.
Files changed (360) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/lib/_virtual/_rolldown/runtime.cjs +1 -1
  4. package/lib/_virtual/_rolldown/runtime.mjs +2 -3
  5. package/lib/export/DbmlExporter.cjs +1 -1
  6. package/lib/export/DbmlExporter.mjs +2 -3
  7. package/lib/export/JsonExporter.mjs +1 -2
  8. package/lib/export/ModelExporter.cjs +1 -1
  9. package/lib/export/ModelExporter.mjs +9 -10
  10. package/lib/export/MysqlExporter.mjs +1 -2
  11. package/lib/export/OracleExporter.mjs +1 -2
  12. package/lib/export/PostgresExporter.cjs +8 -8
  13. package/lib/export/PostgresExporter.mjs +30 -31
  14. package/lib/export/SqlServerExporter.mjs +1 -2
  15. package/lib/export/index.cjs +1 -1
  16. package/lib/export/index.mjs +5 -6
  17. package/lib/export/utils.mjs +1 -2
  18. package/lib/import/index.cjs +1 -1
  19. package/lib/import/index.mjs +10 -11
  20. package/lib/index.cjs +1 -1
  21. package/lib/index.mjs +6 -6
  22. package/lib/model_structure/check.mjs +1 -2
  23. package/lib/model_structure/config.mjs +1 -2
  24. package/lib/model_structure/database.cjs +1 -1
  25. package/lib/model_structure/database.mjs +14 -15
  26. package/lib/model_structure/dbState.mjs +1 -2
  27. package/lib/model_structure/dep.cjs +1 -1
  28. package/lib/model_structure/dep.mjs +6 -7
  29. package/lib/model_structure/depEdge.cjs +1 -1
  30. package/lib/model_structure/depEdge.mjs +10 -11
  31. package/lib/model_structure/element.mjs +1 -2
  32. package/lib/model_structure/endpoint.cjs +1 -1
  33. package/lib/model_structure/endpoint.mjs +17 -18
  34. package/lib/model_structure/enum.cjs +1 -1
  35. package/lib/model_structure/enum.mjs +8 -9
  36. package/lib/model_structure/enumValue.mjs +1 -2
  37. package/lib/model_structure/field.cjs +1 -1
  38. package/lib/model_structure/field.mjs +5 -6
  39. package/lib/model_structure/group.mjs +1 -2
  40. package/lib/model_structure/indexColumn.mjs +1 -2
  41. package/lib/model_structure/indexes.mjs +1 -2
  42. package/lib/model_structure/link.mjs +1 -2
  43. package/lib/model_structure/node.mjs +1 -2
  44. package/lib/model_structure/ref.mjs +1 -2
  45. package/lib/model_structure/schema.cjs +1 -1
  46. package/lib/model_structure/schema.mjs +15 -16
  47. package/lib/model_structure/stickyNote.mjs +1 -2
  48. package/lib/model_structure/table.cjs +1 -1
  49. package/lib/model_structure/table.mjs +28 -29
  50. package/lib/model_structure/tableGroup.cjs +1 -1
  51. package/lib/model_structure/tableGroup.mjs +5 -6
  52. package/lib/model_structure/tablePartial.mjs +1 -2
  53. package/lib/model_structure/utils.mjs +1 -2
  54. package/lib/node_modules/antlr4/dist/antlr4.web.mjs +1 -2
  55. package/lib/node_modules/lodash-es/_DataView.cjs +1 -1
  56. package/lib/node_modules/lodash-es/_DataView.mjs +4 -5
  57. package/lib/node_modules/lodash-es/_Hash.mjs +1 -2
  58. package/lib/node_modules/lodash-es/_ListCache.mjs +1 -2
  59. package/lib/node_modules/lodash-es/_Map.cjs +1 -1
  60. package/lib/node_modules/lodash-es/_Map.mjs +4 -5
  61. package/lib/node_modules/lodash-es/_MapCache.mjs +1 -2
  62. package/lib/node_modules/lodash-es/_Promise.cjs +1 -1
  63. package/lib/node_modules/lodash-es/_Promise.mjs +4 -5
  64. package/lib/node_modules/lodash-es/_Set.cjs +1 -1
  65. package/lib/node_modules/lodash-es/_Set.mjs +4 -5
  66. package/lib/node_modules/lodash-es/_SetCache.mjs +1 -2
  67. package/lib/node_modules/lodash-es/_Stack.mjs +1 -2
  68. package/lib/node_modules/lodash-es/_Symbol.mjs +1 -2
  69. package/lib/node_modules/lodash-es/_Uint8Array.mjs +1 -2
  70. package/lib/node_modules/lodash-es/_WeakMap.cjs +1 -1
  71. package/lib/node_modules/lodash-es/_WeakMap.mjs +4 -5
  72. package/lib/node_modules/lodash-es/_arrayAggregator.mjs +1 -2
  73. package/lib/node_modules/lodash-es/_arrayEach.mjs +1 -2
  74. package/lib/node_modules/lodash-es/_arrayFilter.mjs +1 -2
  75. package/lib/node_modules/lodash-es/_arrayLikeKeys.cjs +1 -1
  76. package/lib/node_modules/lodash-es/_arrayLikeKeys.mjs +9 -10
  77. package/lib/node_modules/lodash-es/_arrayMap.mjs +1 -2
  78. package/lib/node_modules/lodash-es/_arrayPush.mjs +1 -2
  79. package/lib/node_modules/lodash-es/_arrayReduce.mjs +1 -2
  80. package/lib/node_modules/lodash-es/_arraySome.mjs +1 -2
  81. package/lib/node_modules/lodash-es/_asciiToArray.mjs +1 -2
  82. package/lib/node_modules/lodash-es/_assocIndexOf.mjs +1 -2
  83. package/lib/node_modules/lodash-es/_baseAggregator.mjs +1 -2
  84. package/lib/node_modules/lodash-es/_baseAssignValue.mjs +1 -2
  85. package/lib/node_modules/lodash-es/_baseEach.mjs +1 -2
  86. package/lib/node_modules/lodash-es/_baseFlatten.mjs +1 -2
  87. package/lib/node_modules/lodash-es/_baseFor.mjs +1 -2
  88. package/lib/node_modules/lodash-es/_baseForOwn.cjs +1 -1
  89. package/lib/node_modules/lodash-es/_baseForOwn.mjs +5 -6
  90. package/lib/node_modules/lodash-es/_baseGet.mjs +1 -2
  91. package/lib/node_modules/lodash-es/_baseGetAllKeys.cjs +1 -1
  92. package/lib/node_modules/lodash-es/_baseGetAllKeys.mjs +5 -6
  93. package/lib/node_modules/lodash-es/_baseGetTag.mjs +1 -2
  94. package/lib/node_modules/lodash-es/_baseHasIn.mjs +1 -2
  95. package/lib/node_modules/lodash-es/_baseIsArguments.mjs +1 -2
  96. package/lib/node_modules/lodash-es/_baseIsEqual.cjs +1 -1
  97. package/lib/node_modules/lodash-es/_baseIsEqual.mjs +5 -6
  98. package/lib/node_modules/lodash-es/_baseIsEqualDeep.cjs +1 -1
  99. package/lib/node_modules/lodash-es/_baseIsEqualDeep.mjs +15 -16
  100. package/lib/node_modules/lodash-es/_baseIsMatch.mjs +1 -2
  101. package/lib/node_modules/lodash-es/_baseIsNative.cjs +1 -1
  102. package/lib/node_modules/lodash-es/_baseIsNative.mjs +6 -7
  103. package/lib/node_modules/lodash-es/_baseIsTypedArray.cjs +1 -1
  104. package/lib/node_modules/lodash-es/_baseIsTypedArray.mjs +5 -6
  105. package/lib/node_modules/lodash-es/_baseIteratee.cjs +1 -1
  106. package/lib/node_modules/lodash-es/_baseIteratee.mjs +7 -8
  107. package/lib/node_modules/lodash-es/_baseKeys.mjs +1 -2
  108. package/lib/node_modules/lodash-es/_baseMatches.mjs +1 -2
  109. package/lib/node_modules/lodash-es/_baseMatchesProperty.cjs +1 -1
  110. package/lib/node_modules/lodash-es/_baseMatchesProperty.mjs +10 -11
  111. package/lib/node_modules/lodash-es/_baseNth.mjs +1 -2
  112. package/lib/node_modules/lodash-es/_baseProperty.mjs +1 -2
  113. package/lib/node_modules/lodash-es/_basePropertyDeep.mjs +1 -2
  114. package/lib/node_modules/lodash-es/_baseReduce.mjs +1 -2
  115. package/lib/node_modules/lodash-es/_baseSlice.mjs +1 -2
  116. package/lib/node_modules/lodash-es/_baseTimes.mjs +1 -2
  117. package/lib/node_modules/lodash-es/_baseToString.cjs +1 -1
  118. package/lib/node_modules/lodash-es/_baseToString.mjs +7 -8
  119. package/lib/node_modules/lodash-es/_baseTrim.mjs +1 -2
  120. package/lib/node_modules/lodash-es/_baseUnary.mjs +1 -2
  121. package/lib/node_modules/lodash-es/_cacheHas.mjs +1 -2
  122. package/lib/node_modules/lodash-es/_castFunction.mjs +1 -2
  123. package/lib/node_modules/lodash-es/_castPath.mjs +1 -2
  124. package/lib/node_modules/lodash-es/_castSlice.mjs +1 -2
  125. package/lib/node_modules/lodash-es/_copyArray.mjs +1 -2
  126. package/lib/node_modules/lodash-es/_coreJsData.mjs +1 -2
  127. package/lib/node_modules/lodash-es/_createAggregator.cjs +1 -1
  128. package/lib/node_modules/lodash-es/_createAggregator.mjs +8 -9
  129. package/lib/node_modules/lodash-es/_createBaseEach.mjs +1 -2
  130. package/lib/node_modules/lodash-es/_createBaseFor.mjs +1 -2
  131. package/lib/node_modules/lodash-es/_createCaseFirst.cjs +1 -1
  132. package/lib/node_modules/lodash-es/_createCaseFirst.mjs +8 -9
  133. package/lib/node_modules/lodash-es/_defineProperty.mjs +1 -2
  134. package/lib/node_modules/lodash-es/_equalArrays.mjs +1 -2
  135. package/lib/node_modules/lodash-es/_equalByTag.cjs +1 -1
  136. package/lib/node_modules/lodash-es/_equalByTag.mjs +6 -7
  137. package/lib/node_modules/lodash-es/_equalObjects.mjs +1 -2
  138. package/lib/node_modules/lodash-es/_freeGlobal.mjs +1 -2
  139. package/lib/node_modules/lodash-es/_getAllKeys.cjs +1 -1
  140. package/lib/node_modules/lodash-es/_getAllKeys.mjs +5 -6
  141. package/lib/node_modules/lodash-es/_getMapData.mjs +1 -2
  142. package/lib/node_modules/lodash-es/_getMatchData.cjs +1 -1
  143. package/lib/node_modules/lodash-es/_getMatchData.mjs +6 -7
  144. package/lib/node_modules/lodash-es/_getNative.mjs +1 -2
  145. package/lib/node_modules/lodash-es/_getRawTag.mjs +1 -2
  146. package/lib/node_modules/lodash-es/_getSymbols.mjs +1 -2
  147. package/lib/node_modules/lodash-es/_getTag.cjs +1 -1
  148. package/lib/node_modules/lodash-es/_getTag.mjs +12 -13
  149. package/lib/node_modules/lodash-es/_getValue.mjs +1 -2
  150. package/lib/node_modules/lodash-es/_hasPath.cjs +1 -1
  151. package/lib/node_modules/lodash-es/_hasPath.mjs +9 -10
  152. package/lib/node_modules/lodash-es/_hasUnicode.mjs +1 -2
  153. package/lib/node_modules/lodash-es/_hashClear.mjs +1 -2
  154. package/lib/node_modules/lodash-es/_hashDelete.mjs +1 -2
  155. package/lib/node_modules/lodash-es/_hashGet.mjs +1 -2
  156. package/lib/node_modules/lodash-es/_hashHas.mjs +1 -2
  157. package/lib/node_modules/lodash-es/_hashSet.mjs +1 -2
  158. package/lib/node_modules/lodash-es/_isFlattenable.cjs +1 -1
  159. package/lib/node_modules/lodash-es/_isFlattenable.mjs +5 -6
  160. package/lib/node_modules/lodash-es/_isIndex.mjs +1 -2
  161. package/lib/node_modules/lodash-es/_isKey.cjs +1 -1
  162. package/lib/node_modules/lodash-es/_isKey.mjs +6 -7
  163. package/lib/node_modules/lodash-es/_isKeyable.mjs +1 -2
  164. package/lib/node_modules/lodash-es/_isMasked.mjs +1 -2
  165. package/lib/node_modules/lodash-es/_isPrototype.mjs +1 -2
  166. package/lib/node_modules/lodash-es/_isStrictComparable.mjs +1 -2
  167. package/lib/node_modules/lodash-es/_listCacheClear.mjs +1 -2
  168. package/lib/node_modules/lodash-es/_listCacheDelete.mjs +1 -2
  169. package/lib/node_modules/lodash-es/_listCacheGet.mjs +1 -2
  170. package/lib/node_modules/lodash-es/_listCacheHas.mjs +1 -2
  171. package/lib/node_modules/lodash-es/_listCacheSet.mjs +1 -2
  172. package/lib/node_modules/lodash-es/_mapCacheClear.mjs +1 -2
  173. package/lib/node_modules/lodash-es/_mapCacheDelete.mjs +1 -2
  174. package/lib/node_modules/lodash-es/_mapCacheGet.mjs +1 -2
  175. package/lib/node_modules/lodash-es/_mapCacheHas.mjs +1 -2
  176. package/lib/node_modules/lodash-es/_mapCacheSet.mjs +1 -2
  177. package/lib/node_modules/lodash-es/_mapToArray.mjs +1 -2
  178. package/lib/node_modules/lodash-es/_matchesStrictComparable.mjs +1 -2
  179. package/lib/node_modules/lodash-es/_memoizeCapped.mjs +1 -2
  180. package/lib/node_modules/lodash-es/_nativeCreate.mjs +1 -2
  181. package/lib/node_modules/lodash-es/_nativeKeys.mjs +1 -2
  182. package/lib/node_modules/lodash-es/_nodeUtil.mjs +1 -2
  183. package/lib/node_modules/lodash-es/_objectToString.mjs +1 -2
  184. package/lib/node_modules/lodash-es/_overArg.mjs +1 -2
  185. package/lib/node_modules/lodash-es/_root.mjs +1 -2
  186. package/lib/node_modules/lodash-es/_setCacheAdd.mjs +1 -2
  187. package/lib/node_modules/lodash-es/_setCacheHas.mjs +1 -2
  188. package/lib/node_modules/lodash-es/_setToArray.mjs +1 -2
  189. package/lib/node_modules/lodash-es/_stackClear.mjs +1 -2
  190. package/lib/node_modules/lodash-es/_stackDelete.mjs +1 -2
  191. package/lib/node_modules/lodash-es/_stackGet.mjs +1 -2
  192. package/lib/node_modules/lodash-es/_stackHas.mjs +1 -2
  193. package/lib/node_modules/lodash-es/_stackSet.mjs +1 -2
  194. package/lib/node_modules/lodash-es/_stringToArray.cjs +1 -1
  195. package/lib/node_modules/lodash-es/_stringToArray.mjs +5 -6
  196. package/lib/node_modules/lodash-es/_stringToPath.mjs +1 -2
  197. package/lib/node_modules/lodash-es/_toKey.mjs +1 -2
  198. package/lib/node_modules/lodash-es/_toSource.mjs +1 -2
  199. package/lib/node_modules/lodash-es/_trimmedEndIndex.mjs +1 -2
  200. package/lib/node_modules/lodash-es/_unicodeToArray.mjs +1 -2
  201. package/lib/node_modules/lodash-es/capitalize.mjs +1 -2
  202. package/lib/node_modules/lodash-es/concat.cjs +1 -1
  203. package/lib/node_modules/lodash-es/concat.mjs +7 -8
  204. package/lib/node_modules/lodash-es/eq.mjs +1 -2
  205. package/lib/node_modules/lodash-es/first.mjs +1 -1
  206. package/lib/node_modules/lodash-es/flatten.mjs +1 -2
  207. package/lib/node_modules/lodash-es/flattenDeep.mjs +1 -2
  208. package/lib/node_modules/lodash-es/flattenDepth.cjs +1 -1
  209. package/lib/node_modules/lodash-es/flattenDepth.mjs +5 -6
  210. package/lib/node_modules/lodash-es/forEach.cjs +1 -1
  211. package/lib/node_modules/lodash-es/forEach.mjs +7 -8
  212. package/lib/node_modules/lodash-es/get.mjs +1 -2
  213. package/lib/node_modules/lodash-es/groupBy.mjs +1 -2
  214. package/lib/node_modules/lodash-es/hasIn.mjs +1 -2
  215. package/lib/node_modules/lodash-es/head.mjs +1 -2
  216. package/lib/node_modules/lodash-es/identity.mjs +1 -2
  217. package/lib/node_modules/lodash-es/isArguments.cjs +1 -1
  218. package/lib/node_modules/lodash-es/isArguments.mjs +6 -7
  219. package/lib/node_modules/lodash-es/isArray.mjs +1 -2
  220. package/lib/node_modules/lodash-es/isArrayLike.mjs +1 -2
  221. package/lib/node_modules/lodash-es/isBuffer.mjs +1 -2
  222. package/lib/node_modules/lodash-es/isEmpty.cjs +1 -1
  223. package/lib/node_modules/lodash-es/isEmpty.mjs +13 -14
  224. package/lib/node_modules/lodash-es/isFunction.mjs +1 -2
  225. package/lib/node_modules/lodash-es/isLength.mjs +1 -2
  226. package/lib/node_modules/lodash-es/isNil.mjs +1 -2
  227. package/lib/node_modules/lodash-es/isObject.mjs +1 -2
  228. package/lib/node_modules/lodash-es/isObjectLike.mjs +1 -2
  229. package/lib/node_modules/lodash-es/isSymbol.mjs +1 -2
  230. package/lib/node_modules/lodash-es/isTypedArray.mjs +1 -2
  231. package/lib/node_modules/lodash-es/keys.cjs +1 -1
  232. package/lib/node_modules/lodash-es/keys.mjs +6 -7
  233. package/lib/node_modules/lodash-es/last.mjs +1 -2
  234. package/lib/node_modules/lodash-es/lodash.cjs +1 -1
  235. package/lib/node_modules/lodash-es/lodash.mjs +19 -19
  236. package/lib/node_modules/lodash-es/memoize.mjs +1 -2
  237. package/lib/node_modules/lodash-es/nth.cjs +1 -1
  238. package/lib/node_modules/lodash-es/nth.mjs +5 -6
  239. package/lib/node_modules/lodash-es/property.cjs +1 -1
  240. package/lib/node_modules/lodash-es/property.mjs +7 -8
  241. package/lib/node_modules/lodash-es/reduce.cjs +1 -1
  242. package/lib/node_modules/lodash-es/reduce.mjs +8 -9
  243. package/lib/node_modules/lodash-es/stubArray.mjs +1 -2
  244. package/lib/node_modules/lodash-es/stubFalse.mjs +1 -2
  245. package/lib/node_modules/lodash-es/toFinite.mjs +1 -2
  246. package/lib/node_modules/lodash-es/toInteger.mjs +1 -2
  247. package/lib/node_modules/lodash-es/toNumber.cjs +1 -1
  248. package/lib/node_modules/lodash-es/toNumber.mjs +9 -10
  249. package/lib/node_modules/lodash-es/toString.mjs +1 -2
  250. package/lib/node_modules/lodash-es/upperFirst.mjs +1 -2
  251. package/lib/node_modules/luxon/build/es6/luxon.mjs +1 -2
  252. package/lib/node_modules/parsimmon/build/parsimmon.umd.min.cjs +1 -1
  253. package/lib/node_modules/parsimmon/build/parsimmon.umd.min.mjs +3 -4
  254. package/lib/node_modules/pluralize/pluralize.cjs +1 -1
  255. package/lib/node_modules/pluralize/pluralize.mjs +3 -4
  256. package/lib/packages/dbml-core/node_modules/lodash/lodash.cjs +2 -2
  257. package/lib/packages/dbml-core/node_modules/lodash/lodash.mjs +3 -4
  258. package/lib/packages/dbml-core/package.json.cjs +1 -1
  259. package/lib/packages/dbml-core/package.json.mjs +2 -3
  260. package/lib/parse/ANTLR/ASTGeneration/AST.mjs +1 -2
  261. package/lib/parse/ANTLR/ASTGeneration/ParserErrorListener.mjs +1 -2
  262. package/lib/parse/ANTLR/ASTGeneration/SyntaxError.mjs +1 -2
  263. package/lib/parse/ANTLR/ASTGeneration/constants.mjs +1 -2
  264. package/lib/parse/ANTLR/ASTGeneration/helpers.mjs +1 -2
  265. package/lib/parse/ANTLR/ASTGeneration/index.mjs +1 -2
  266. package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.mjs +1 -2
  267. package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.cjs +1 -1
  268. package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.mjs +2 -3
  269. package/lib/parse/ANTLR/ASTGeneration/oraclesql/OracleSQLASTGen.cjs +1 -1
  270. package/lib/parse/ANTLR/ASTGeneration/oraclesql/OracleSQLASTGen.mjs +57 -58
  271. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.cjs +1 -1
  272. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.mjs +2 -3
  273. package/lib/parse/ANTLR/ASTGeneration/snowflake/SnowflakeASTGen.mjs +1 -2
  274. package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.mjs +1 -2
  275. package/lib/parse/ANTLR/parsers/mssql/TSqlParser.mjs +1 -2
  276. package/lib/parse/ANTLR/parsers/mssql/TSqlParserVisitor.mjs +1 -2
  277. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.mjs +1 -2
  278. package/lib/parse/ANTLR/parsers/mysql/MySqlLexerBase.mjs +1 -2
  279. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.mjs +1 -2
  280. package/lib/parse/ANTLR/parsers/mysql/MySqlParserVisitor.mjs +1 -2
  281. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.mjs +1 -2
  282. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexerBase.mjs +1 -2
  283. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.mjs +1 -2
  284. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserBase.mjs +1 -2
  285. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserVisitor.mjs +1 -2
  286. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.mjs +1 -2
  287. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexerBase.mjs +1 -2
  288. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.mjs +1 -2
  289. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserBase.mjs +1 -2
  290. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserVisitor.mjs +1 -2
  291. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.mjs +1 -2
  292. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.mjs +1 -2
  293. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParserVisitor.mjs +1 -2
  294. package/lib/parse/Parser.cjs +1 -1
  295. package/lib/parse/Parser.mjs +37 -38
  296. package/lib/parse/databaseGenerator.mjs +1 -2
  297. package/lib/parse/deprecated/dbmlParser.mjs +1 -2
  298. package/lib/parse/deprecated/mssql/base_parsers.cjs +1 -1
  299. package/lib/parse/deprecated/mssql/base_parsers.mjs +27 -28
  300. package/lib/parse/deprecated/mssql/column_definition/actions.mjs +1 -2
  301. package/lib/parse/deprecated/mssql/column_definition/index.cjs +1 -1
  302. package/lib/parse/deprecated/mssql/column_definition/index.mjs +19 -19
  303. package/lib/parse/deprecated/mssql/constraint_definition/actions.mjs +1 -2
  304. package/lib/parse/deprecated/mssql/constraint_definition/index.cjs +1 -1
  305. package/lib/parse/deprecated/mssql/constraint_definition/index.mjs +10 -10
  306. package/lib/parse/deprecated/mssql/expression.cjs +1 -1
  307. package/lib/parse/deprecated/mssql/expression.mjs +17 -18
  308. package/lib/parse/deprecated/mssql/fk_definition/actions.mjs +1 -2
  309. package/lib/parse/deprecated/mssql/fk_definition/index.cjs +1 -1
  310. package/lib/parse/deprecated/mssql/fk_definition/index.mjs +7 -8
  311. package/lib/parse/deprecated/mssql/index.mjs +1 -2
  312. package/lib/parse/deprecated/mssql/index_definition/actions.mjs +1 -2
  313. package/lib/parse/deprecated/mssql/index_definition/index.cjs +1 -1
  314. package/lib/parse/deprecated/mssql/index_definition/index.mjs +13 -14
  315. package/lib/parse/deprecated/mssql/keyword_parsers.mjs +1 -2
  316. package/lib/parse/deprecated/mssql/keyword_utils.mjs +1 -2
  317. package/lib/parse/deprecated/mssql/statements/actions.mjs +1 -2
  318. package/lib/parse/deprecated/mssql/statements/index.cjs +1 -1
  319. package/lib/parse/deprecated/mssql/statements/index.mjs +23 -24
  320. package/lib/parse/deprecated/mssql/statements/statement_types/alter_table/actions.mjs +1 -2
  321. package/lib/parse/deprecated/mssql/statements/statement_types/alter_table/add/actions.mjs +1 -1
  322. package/lib/parse/deprecated/mssql/statements/statement_types/alter_table/add/index.cjs +1 -1
  323. package/lib/parse/deprecated/mssql/statements/statement_types/alter_table/add/index.mjs +13 -14
  324. package/lib/parse/deprecated/mssql/statements/statement_types/alter_table/index.mjs +1 -2
  325. package/lib/parse/deprecated/mssql/statements/statement_types/comments/actions.mjs +1 -2
  326. package/lib/parse/deprecated/mssql/statements/statement_types/comments/index.cjs +1 -1
  327. package/lib/parse/deprecated/mssql/statements/statement_types/comments/index.mjs +5 -6
  328. package/lib/parse/deprecated/mssql/statements/statement_types/create_index/actions.mjs +1 -2
  329. package/lib/parse/deprecated/mssql/statements/statement_types/create_index/index.cjs +1 -1
  330. package/lib/parse/deprecated/mssql/statements/statement_types/create_index/index.mjs +11 -12
  331. package/lib/parse/deprecated/mssql/statements/statement_types/create_table/actions.mjs +1 -2
  332. package/lib/parse/deprecated/mssql/statements/statement_types/create_table/index.cjs +1 -1
  333. package/lib/parse/deprecated/mssql/statements/statement_types/create_table/index.mjs +11 -12
  334. package/lib/parse/deprecated/mssql/statements/statement_types/index.mjs +1 -1
  335. package/lib/parse/deprecated/mssql/utils.cjs +1 -1
  336. package/lib/parse/deprecated/mssql/utils.mjs +10 -11
  337. package/lib/parse/deprecated/mssql/whitespaces.mjs +1 -2
  338. package/lib/parse/deprecated/mssqlParser.mjs +1 -2
  339. package/lib/parse/deprecated/mysqlParser.mjs +1 -2
  340. package/lib/parse/deprecated/postgresParser.mjs +1 -2
  341. package/lib/parse/deprecated/schemarbParser.mjs +1 -2
  342. package/lib/parse/error.mjs +1 -2
  343. package/lib/transform/index.mjs +1 -2
  344. package/lib/transform/relations.mjs +1 -2
  345. package/lib/utils/version.mjs +1 -2
  346. package/package.json +3 -3
  347. package/types/export/DbmlExporter.d.ts +0 -0
  348. package/types/export/JsonExporter.d.ts +0 -0
  349. package/types/export/ModelExporter.d.ts +0 -0
  350. package/types/export/index.d.ts +0 -0
  351. package/types/index.d.ts +3 -3
  352. package/types/model_structure/check.d.ts +0 -0
  353. package/types/model_structure/element.d.ts +0 -0
  354. package/types/model_structure/enum.d.ts +0 -0
  355. package/types/model_structure/enumValue.d.ts +0 -0
  356. package/types/model_structure/index.d.ts +0 -0
  357. package/types/model_structure/indexes.d.ts +0 -0
  358. package/types/model_structure/ref.d.ts +0 -0
  359. package/types/model_structure/tablePartial.d.ts +0 -0
  360. package/types/parse/Parser.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- //#region src/parse/ANTLR/ASTGeneration/AST.js
1
+ // src/parse/ANTLR/ASTGeneration/AST.js
2
2
  var e = class {
3
3
  constructor({ name: e, unique: t, pk: n, type: r, columns: i }) {
4
4
  this.name = e, this.type = r, this.unique = t, this.pk = n, this.columns = i;
@@ -91,5 +91,4 @@ var e = class {
91
91
  };
92
92
  }
93
93
  };
94
- //#endregion
95
94
  export { r as Endpoint, a as Enum, t as Field, e as Index, i as Ref, n as Table, o as TableRecord };
@@ -1,6 +1,6 @@
1
1
  import e from "../../../node_modules/antlr4/dist/antlr4.web.mjs";
2
2
  import t from "./SyntaxError.mjs";
3
- //#region src/parse/ANTLR/ASTGeneration/ParserErrorListener.js
3
+ // src/parse/ANTLR/ASTGeneration/ParserErrorListener.js
4
4
  var n = class extends e.error.ErrorListener {
5
5
  constructor(e) {
6
6
  super(e), this.errors = [];
@@ -9,5 +9,4 @@ var n = class extends e.error.ErrorListener {
9
9
  this.errors.push(new t(r, i, a));
10
10
  }
11
11
  };
12
- //#endregion
13
12
  export { n as default };
@@ -1,4 +1,4 @@
1
- //#region src/parse/ANTLR/ASTGeneration/SyntaxError.js
1
+ // src/parse/ANTLR/ASTGeneration/SyntaxError.js
2
2
  var e = class e extends Error {
3
3
  constructor(t, n, r) {
4
4
  super(r), Error.captureStackTrace && Error.captureStackTrace(this, e), this.text = r, this.location = { start: {
@@ -7,5 +7,4 @@ var e = class e extends Error {
7
7
  } };
8
8
  }
9
9
  };
10
- //#endregion
11
10
  export { e as default };
@@ -1,4 +1,4 @@
1
- //#region src/parse/ANTLR/ASTGeneration/constants.js
1
+ // src/parse/ANTLR/ASTGeneration/constants.js
2
2
  var e = {
3
3
  FIELD: "field",
4
4
  INDEX: "index",
@@ -27,5 +27,4 @@ var e = {
27
27
  STRING: "string",
28
28
  EXPRESSION: "expression"
29
29
  };
30
- //#endregion
31
30
  export { t as COLUMN_CONSTRAINT_KIND, r as CONSTRAINT_TYPE, n as DATA_TYPE, e as TABLE_CONSTRAINT_KIND };
@@ -1,10 +1,9 @@
1
1
  import e from "../../../node_modules/lodash-es/isNil.mjs";
2
2
  import { init_lodash as t } from "../../../node_modules/lodash-es/lodash.mjs";
3
- //#region src/parse/ANTLR/ASTGeneration/helpers.js
3
+ // src/parse/ANTLR/ASTGeneration/helpers.js
4
4
  t();
5
5
  function n(t) {
6
6
  let n = t.start.start, r = t.stop.stop;
7
7
  if (!(e(n) || e(r))) return t.start.getInputStream().getText(n, r);
8
8
  }
9
- //#endregion
10
9
  export { n as getOriginalText };
@@ -15,7 +15,7 @@ import p from "./mysql/MySQLASTGen.mjs";
15
15
  import m from "./oraclesql/OracleSQLASTGen.mjs";
16
16
  import h from "./postgres/PostgresASTGen.mjs";
17
17
  import g from "./snowflake/SnowflakeASTGen.mjs";
18
- //#region src/parse/ANTLR/ASTGeneration/index.js
18
+ // src/parse/ANTLR/ASTGeneration/index.js
19
19
  function _(_, v) {
20
20
  let y = new e.InputStream(_), b = null, x = new d();
21
21
  switch (v) {
@@ -48,5 +48,4 @@ function _(_, v) {
48
48
  }
49
49
  return b;
50
50
  }
51
- //#endregion
52
51
  export { _ as parse };
@@ -11,7 +11,7 @@ import { Field as u, Index as d, Table as f, TableRecord as p } from "../AST.mjs
11
11
  import { COLUMN_CONSTRAINT_KIND as m, DATA_TYPE as h, TABLE_CONSTRAINT_KIND as g } from "../constants.mjs";
12
12
  import { getOriginalText as _ } from "../helpers.mjs";
13
13
  import { CARDINALITY_MANY as v, CARDINALITY_MAYBE as y, normalizeQualifiedName as b } from "@dbml/parse";
14
- //#region src/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js
14
+ // src/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js
15
15
  a();
16
16
  var x = "sp_addextendedproperty", S = "dbo", C = (e) => {
17
17
  let n = t(e);
@@ -590,5 +590,4 @@ var x = "sp_addextendedproperty", S = "dbo", C = (e) => {
590
590
  };
591
591
  }
592
592
  };
593
- //#endregion
594
593
  export { D as default };
@@ -1 +1 @@
1
- require("../../../../_virtual/_rolldown/runtime.cjs");const e=require("../../../../node_modules/lodash-es/flatten.cjs"),t=require("../../../../node_modules/lodash-es/last.cjs"),n=require("../../../../node_modules/lodash-es/flattenDepth.cjs"),r=require("../../../../node_modules/lodash-es/lodash.cjs");require("../../../../model_structure/config.cjs");const i=require("../../../../node_modules/antlr4/dist/antlr4.web.cjs"),a=require("../../parsers/mysql/MySqlParserVisitor.cjs"),o=require("../../parsers/mysql/MySqlParser.cjs"),s=require("../AST.cjs"),c=require("../constants.cjs"),l=require("../helpers.cjs");let u=require("@dbml/parse");r.init_lodash();var d={NOTE:`note`},f={ADD_PK:`add_pk`,ADD_FK:`add_fk`,ADD_CHECK:`add_check`},p={TYPE:`type`},m=e=>({tableName:t.default(e),schemaName:e.length>1?e[e.length-2]:void 0}),h=e=>({fieldName:t.default(e),tableName:e.length>1?e[e.length-2]:void 0,schemaName:e.length>2?e[e.length-3]:void 0}),g=class extends a.default{constructor(){super(),this.data={schemas:[],tables:[],refs:[],deps:[],enums:[],tableGroups:[],aliases:[],project:{},records:[]}}visitCreateView(e){let t=e.fullId(),n=t?t.getText().replace(/`/g,``).split(`.`):[];if(n.length===0)return;let r=n[n.length-1],a=n.length>1?n[n.length-2]:void 0,s=e.getText();this.data.tables.push({name:r,schemaName:a,fields:[],indexes:[],checks:[],note:null,headerColor:null,custom:{query:s,kind:`view`}});let c=e.selectStatement();if(!c)return;let l=new Set,d=new i.ParseTreeListener;d.enterEveryRule=e=>{if(!(e instanceof o.default.TableNameContext))return;let{tableName:t,schemaName:n}=m(e.accept(this)),i=(0,u.normalizeQualifiedName)(n??`public`,t);i!==(0,u.normalizeQualifiedName)(a??`public`,r)&&(l.has(i)||this.findTable(n,t)&&(l.add(i),this.data.deps.push({edges:[{upstream:{schemaName:n,tableName:t,fieldNames:[]},downstream:{schemaName:a,tableName:r,fieldNames:[]}}],note:null,custom:{}})))},i.ParseTreeWalker.DEFAULT.walk(d,c)}findTable(e,t){let n=e??`public`;return this.data.tables.find(e=>(e.schemaName??`public`)===n&&e.name===t)}visitRoot(e){return e.sqlStatements()?.accept(this),this.data}visitSqlStatements(e){e.sqlStatement().forEach(e=>{e.accept(this)})}visitSqlStatement(e){e.ddlStatement()?e.ddlStatement().accept(this):e.dmlStatement()&&e.dmlStatement().accept(this)}visitDdlStatement(t){if(t.createTable()){let n=t.createTable().accept(this);if(!n)return;let{tableName:r,schemaName:i,definitions:a,options:o}=n,[l,u,d,f,p]=a.reduce((e,t)=>{if(t.kind===c.TABLE_CONSTRAINT_KIND.FIELD)e[0].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.INDEX)e[1].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.UNIQUE)e[1].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.FK)e[2].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.CHECK)e[4].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.PK){let n=t.value;n.columns.length>1?e[1].push(t.value):e[3]=n}return e},[[],[],[],null,[]]),m=l.map(e=>{let{field:t,inlineRefs:n}=e;if(t.type.type_name?.toLowerCase()===`enum`){let e=t.type.args.map(e=>({name:e.replace(/'|"|`/g,``).trim()})),n=new s.Enum({name:`${r}_${t.name}_enum`,schemaName:i,values:e});t.type.type_name=n.name,t.type.schemaName=n.schemaName,this.data.enums.push(n)}return n.forEach(e=>{e.endpoints[0].tableName=r,e.endpoints[0].schemaName=i,e.endpoints[0].fieldNames=[t.name]}),n});this.data.refs.push(...e.default(m)),this.data.refs.push(...d.map(e=>(e.endpoints[0].tableName=r,e.endpoints[0].schemaName=i,e)));let h=o.reduce((e,t)=>(e[t.kind]=t.value,e),{}),g=new s.Table({name:r,schemaName:i,fields:l.map(e=>e.field),indexes:u,checks:p,...h});if(f){let e=g.fields.find(e=>e.name===f.columns[0].value);e&&(e.pk=!0)}this.data.tables.push(g.toJSON())}else t.alterTable()?t.alterTable().accept(this):t.createIndex()&&t.createIndex().accept(this)}visitCopyCreateTable(){}visitQueryCreateTable(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this));return e.createDefinitions()?{tableName:t,schemaName:n,definitions:e.createDefinitions().accept(this).filter(e=>e?.kind),options:e.tableOption()?.map(e=>e.accept(this)).filter(e=>e?.kind)||[]}:null}visitColumnCreateTable(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this));return{tableName:t,schemaName:n,definitions:e.createDefinitions().accept(this).filter(e=>e?.kind),options:e.tableOption().map(e=>e.accept(this)).filter(e=>e?.kind)}}visitTableOptionComment(e){let t=e.STRING_LITERAL().getText();return{kind:d.NOTE,value:{value:t.slice(1,t.length-1)}}}visitTableName(e){return e.fullId().accept(this)}visitFullId(e){let t=e.uid().map(e=>e.accept(this));if(e.DOT_ID()){let n=e.DOT_ID().getText();t.push(n.slice(1))}return t}visitUid(e){if(e.simpleId())return e.simpleId().accept(this);let t=e.getChild(0).getText();return t.slice(1,t.length-1)}visitSimpleId(e){return e.getChild(0).getText()}visitCreateDefinitions(e){return e.createDefinition().map(e=>e.accept(this))}visitColumnDeclaration(e){let{fieldName:t}=h(e.fullColumnName().accept(this)),{type:n,constraints:r}=e.columnDefinition().accept(this),i=new s.Field({name:t,type:n,...r});return{kind:c.TABLE_CONSTRAINT_KIND.FIELD,value:{field:i,inlineRefs:r.inlineRefs}}}visitConstraintDeclaration(e){return e.tableConstraint().accept(this)}visitIndexDeclaration(e){return e.indexColumnDefinition().accept(this)}visitFullColumnName(e){let t=[];return e.uid()&&t.push(e.uid().accept(this)),t.push(...e.dottedId().map(e=>e.accept(this))),t}visitDottedId(e){return e.DOT_ID()?e.DOT_ID().getText().slice(1):e.uid().accept(this)}visitColumnDefinition(e){let t=e.dataType().accept(this),n={inlineRefs:[],checks:[]};return e.columnConstraint().forEach(e=>{let t=e.accept(this);t&&(t.kind===c.COLUMN_CONSTRAINT_KIND.INLINE_REF?n.inlineRefs.push(t.value):t.kind===c.COLUMN_CONSTRAINT_KIND.CHECK?n.checks.push(t.value):n[t.kind]=t.value)}),{type:t,constraints:n}}visitStringDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),{type_name:t,schemaName:null}}visitNationalVaryingStringDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),{type_name:t,schemaName:null}}visitNationalStringDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),{type_name:t,schemaName:null}}visitDimensionDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),e.lengthTwoDimension()&&(t+=e.lengthTwoDimension().getText()),e.lengthTwoOptionalDimension()&&(t+=e.lengthTwoOptionalDimension().getText()),{type_name:t,schemaName:null}}visitSimpleDataType(e){return{type_name:e.typeName.text,schemaName:null}}visitCollectionDataType(e){return e.SET()?{type_name:e.typeName.text+e.collectionOptions().getText(),schemaName:null}:{type_name:e.typeName.text,args:e.collectionOptions().accept(this),schemaName:null}}visitCollectionOptions(e){return e.STRING_LITERAL().map(e=>e.getText())}visitSpatialDataType(e){return{type_name:e.typeName.text,schemaName:null}}visitLongVarcharDataType(e){return{type_name:e.typeName.text,schemaName:null}}visitLongVarbinaryDataType(e){return{type_name:`${e.LONG().getText()} ${e.VARBINARY().getText()}`,schemaName:null}}visitNullColumnConstraint(e){return e.nullNotnull().accept(this)}visitNullNotnull(e){let t=!1;return e.NOT()&&(t=!0),{kind:c.COLUMN_CONSTRAINT_KIND.NOT_NULL,value:t}}visitDefaultColumnConstraint(e){return{kind:c.COLUMN_CONSTRAINT_KIND.DEFAULT,value:e.defaultValue().accept(this)}}visitAutoIncrementColumnConstraint(e){return e.AUTO_INCREMENT()?{kind:c.COLUMN_CONSTRAINT_KIND.INCREMENT,value:!0}:null}visitPrimaryKeyColumnConstraint(e){return e.PRIMARY()?{kind:c.COLUMN_CONSTRAINT_KIND.PK,value:!0}:null}visitUniqueKeyColumnConstraint(){return{kind:c.COLUMN_CONSTRAINT_KIND.UNIQUE,value:!0}}visitCommentColumnConstraint(e){let t=e.STRING_LITERAL().getText();return{kind:c.COLUMN_CONSTRAINT_KIND.NOTE,value:{value:t.slice(1,t.length-1)}}}visitReferenceColumnConstraint(e){let t=e.referenceDefinition().accept(this);return{kind:c.COLUMN_CONSTRAINT_KIND.INLINE_REF,value:t}}visitCheckColumnConstraint(e){let t=e.name?.accept(this),n=l.getOriginalText(e.expression());return{kind:c.COLUMN_CONSTRAINT_KIND.CHECK,value:{expression:n,name:t}}}visitDefaultValue(e){if(e.NULL_LITERAL())return{value:e.NULL_LITERAL().getText().toLowerCase(),type:c.DATA_TYPE.BOOLEAN};if(e.expression())return{value:e.expression().getText(),type:c.DATA_TYPE.EXPRESSION};if(e.constant()){if(e.unaryOperator())return{value:e.getText(),type:c.DATA_TYPE.EXPRESSION};let{value:t,type:n}=e.constant().accept(this);return{value:t,type:n}}return e.currentTimestamp()?.length?{value:e.currentTimestamp()[0].getText(),type:c.DATA_TYPE.EXPRESSION}:{value:e.getText(),type:c.DATA_TYPE.EXPRESSION}}visitConstant(e){if(e.stringLiteral()){let t=e.stringLiteral().getText();return{value:t.slice(1,t.length-1),type:c.DATA_TYPE.STRING}}return e.decimalLiteral()?e.getChildCount()>1?{value:e.getText(),type:c.DATA_TYPE.EXPRESSION}:{value:e.decimalLiteral().getText(),type:c.DATA_TYPE.NUMBER}:e.hexadecimalLiteral()?{value:e.hexadecimalLiteral().getText(),type:c.DATA_TYPE.NUMBER}:e.booleanLiteral()?{value:e.booleanLiteral().getText(),type:c.DATA_TYPE.BOOLEAN}:e.REAL_LITERAL()?{value:e.REAL_LITERAL().getText(),type:c.DATA_TYPE.NUMBER}:e.BIT_STRING()?{value:e.BIT_STRING().getText(),type:c.DATA_TYPE.STRING}:e.NULL_LITERAL()?{value:e.NULL_LITERAL().getText().toLowerCase(),type:c.DATA_TYPE.BOOLEAN}:{value:e.getText(),type:c.DATA_TYPE.STRING}}visitReferenceDefinition(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this));if(!e.indexColumnNames())return null;let r=e.referenceAction()?.accept(this)||{},i=e.indexColumnNames().accept(this).map(e=>e.value),a=new s.Endpoint({tableName:null,schemaName:null,fieldNames:null,relation:u.CARDINALITY_MANY}),o=new s.Endpoint({tableName:t,schemaName:n,fieldNames:i,relation:u.CARDINALITY_MAYBE});return new s.Ref({endpoints:[a,o],onUpdate:r.onUpdate,onDelete:r.onDelete})}visitIndexColumnNames(e){return e.indexColumnName().map(e=>e.accept(this))}visitIndexColumnName(e){let t=e.DESC()?{sortOrder:`desc`}:{};if(e.uid())return{type:c.CONSTRAINT_TYPE.COLUMN,value:e.uid().accept(this),...t};if(e.STRING_LITERAL()){let n=e.STRING_LITERAL().getText();return{type:c.CONSTRAINT_TYPE.STRING,value:n.slice(1,n.length-1),...t}}return{type:c.CONSTRAINT_TYPE.EXPRESSION,value:e.expression().getText(),...t}}visitReferenceAction(e){let t={};return t.onDelete=e.onDelete?.accept(this),t.onUpdate=e.onUpdate?.accept(this),t}visitReferenceControlType(e){let t=[...Array(e.getChildCount()).keys()].reduce((t,n)=>`${t}${e.getChild(n).getText()} `,``);return t.slice(0,t.length-1)}visitPrimaryKeyTableConstraint(e){let t=e.name?.accept(this)||e.index?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.PK,value:new s.Index({name:t,pk:!0,columns:r,type:n})}}visitUniqueKeyTableConstraint(e){let t=e.name?.accept(this)||e.index?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.UNIQUE,value:new s.Index({name:t,unique:!0,columns:r,type:n})}}visitForeignKeyTableConstraint(e){let t=e.referenceDefinition().accept(this);return t.name=e.name?.accept(this)||e.index?.accept(this),t.endpoints[0].fieldNames=e.indexColumnNames().accept(this).map(e=>e.value),{kind:c.TABLE_CONSTRAINT_KIND.FK,value:t}}visitCheckTableConstraint(e){let t=e.name?.accept(this),n=l.getOriginalText(e.expression());return{kind:c.TABLE_CONSTRAINT_KIND.CHECK,value:{expression:n,name:t}}}visitIndexType(e){return e.getChild(1).getText()}visitIndexOption(e){return e.indexType()?{kind:p.TYPE,value:e.indexType().accept(this)}:null}visitSimpleIndexDeclaration(e){let t=e.uid()?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.INDEX,value:new s.Index({name:t,columns:r,type:n})}}visitSpecialIndexDeclaration(e){let t=e.uid()?.accept(this),n=null;if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.INDEX,value:new s.Index({name:t,columns:r,type:n})}}visitAlterTable(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this)),r=this.findTable(n,t);r&&(e.alterSpecification()?.map(e=>e.accept(this)).filter(e=>e?.kind)||[]).forEach(e=>{if(e.kind===f.ADD_PK){let t=e.value;if(t.columns.length>1)return r.indexes.push(t);let n=r.fields.find(e=>e.name===t.columns[0].value);n.pk=!0}else if(e.kind===f.ADD_FK){let r=e.value;r.endpoints[0].schemaName=n,r.endpoints[0].tableName=t,this.data.refs.push(r)}else e.kind===f.ADD_CHECK&&r.checks.push(e.value);return null})}visitAlterByAddPrimaryKey(e){let t=e.name?.accept(this)||e.index?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:f.ADD_PK,value:new s.Index({name:t,pk:!0,columns:r,type:n})}}visitAlterByAddForeignKey(e){let t=e.referenceDefinition().accept(this);return t.name=e.name?.accept(this)||e.index?.accept(this),t.endpoints[0].fieldNames=e.indexColumnNames().accept(this).map(e=>e.value),{kind:f.ADD_FK,value:t}}visitAlterByAddCheckTableConstraint(e){let t=e.name?.accept(this),n=l.getOriginalText(e.expression());return{kind:f.ADD_CHECK,value:{expression:n,name:t}}}visitCreateIndex(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this)),r=this.findTable(n,t);if(!r)return;let i=e.uid().accept(this),a=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(a=t.value)}let o=e.indexColumnNames().accept(this),c=new s.Index({name:i,columns:o,unique:!!e.UNIQUE(),type:a});r.indexes.push(c)}visitDmlStatement(e){e.insertStatement()&&e.insertStatement().accept(this)}visitInsertStatement(e){let n=e.tableName().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=e.fullColumnNameList()?e.fullColumnNameList().accept(this):this.findTable(i,r)?.fields.map(e=>e.name)||[],o=e.insertStatementValue().accept(this),c=new s.TableRecord({schemaName:i,tableName:r,columns:a,values:o});this.data.records.push(c)}visitFullColumnNameList(e){let t=e.fullColumnName().map(e=>e.accept(this));return n.default(t,1)}visitInsertStatementValue(e){return e.expressionsWithDefaults().map(e=>{let t=e.accept(this);return n.default(t,1)})}visitExpressionsWithDefaults(e){return e.expressionOrDefault().map(e=>{let t=e.accept(this);return n.default(t,3)})}visitFunctionCallExpressionAtom(e){return{value:e.getText(),type:c.DATA_TYPE.EXPRESSION}}};exports.default=g;
1
+ require("../../../../_virtual/_rolldown/runtime.cjs");const e=require("../../../../node_modules/lodash-es/flatten.cjs"),t=require("../../../../node_modules/lodash-es/last.cjs"),n=require("../../../../node_modules/lodash-es/flattenDepth.cjs"),r=require("../../../../node_modules/lodash-es/lodash.cjs"),i=require("../../../../node_modules/antlr4/dist/antlr4.web.cjs"),a=require("../../parsers/mysql/MySqlParserVisitor.cjs"),o=require("../../parsers/mysql/MySqlParser.cjs"),s=require("../AST.cjs"),c=require("../constants.cjs"),l=require("../helpers.cjs");require("../../../../model_structure/config.cjs");let u=require("@dbml/parse");r.init_lodash();var d={NOTE:`note`},f={ADD_PK:`add_pk`,ADD_FK:`add_fk`,ADD_CHECK:`add_check`},p={TYPE:`type`},m=e=>({tableName:t.default(e),schemaName:e.length>1?e[e.length-2]:void 0}),h=e=>({fieldName:t.default(e),tableName:e.length>1?e[e.length-2]:void 0,schemaName:e.length>2?e[e.length-3]:void 0}),g=class extends a.default{constructor(){super(),this.data={schemas:[],tables:[],refs:[],deps:[],enums:[],tableGroups:[],aliases:[],project:{},records:[]}}visitCreateView(e){let t=e.fullId(),n=t?t.getText().replace(/`/g,``).split(`.`):[];if(n.length===0)return;let r=n[n.length-1],a=n.length>1?n[n.length-2]:void 0,s=e.getText();this.data.tables.push({name:r,schemaName:a,fields:[],indexes:[],checks:[],note:null,headerColor:null,custom:{query:s,kind:`view`}});let c=e.selectStatement();if(!c)return;let l=new Set,d=new i.ParseTreeListener;d.enterEveryRule=e=>{if(!(e instanceof o.default.TableNameContext))return;let{tableName:t,schemaName:n}=m(e.accept(this)),i=(0,u.normalizeQualifiedName)(n??`public`,t);i!==(0,u.normalizeQualifiedName)(a??`public`,r)&&(l.has(i)||this.findTable(n,t)&&(l.add(i),this.data.deps.push({edges:[{upstream:{schemaName:n,tableName:t,fieldNames:[]},downstream:{schemaName:a,tableName:r,fieldNames:[]}}],note:null,custom:{}})))},i.ParseTreeWalker.DEFAULT.walk(d,c)}findTable(e,t){let n=e??`public`;return this.data.tables.find(e=>(e.schemaName??`public`)===n&&e.name===t)}visitRoot(e){return e.sqlStatements()?.accept(this),this.data}visitSqlStatements(e){e.sqlStatement().forEach(e=>{e.accept(this)})}visitSqlStatement(e){e.ddlStatement()?e.ddlStatement().accept(this):e.dmlStatement()&&e.dmlStatement().accept(this)}visitDdlStatement(t){if(t.createTable()){let n=t.createTable().accept(this);if(!n)return;let{tableName:r,schemaName:i,definitions:a,options:o}=n,[l,u,d,f,p]=a.reduce((e,t)=>{if(t.kind===c.TABLE_CONSTRAINT_KIND.FIELD)e[0].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.INDEX)e[1].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.UNIQUE)e[1].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.FK)e[2].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.CHECK)e[4].push(t.value);else if(t.kind===c.TABLE_CONSTRAINT_KIND.PK){let n=t.value;n.columns.length>1?e[1].push(t.value):e[3]=n}return e},[[],[],[],null,[]]),m=l.map(e=>{let{field:t,inlineRefs:n}=e;if(t.type.type_name?.toLowerCase()===`enum`){let e=t.type.args.map(e=>({name:e.replace(/'|"|`/g,``).trim()})),n=new s.Enum({name:`${r}_${t.name}_enum`,schemaName:i,values:e});t.type.type_name=n.name,t.type.schemaName=n.schemaName,this.data.enums.push(n)}return n.forEach(e=>{e.endpoints[0].tableName=r,e.endpoints[0].schemaName=i,e.endpoints[0].fieldNames=[t.name]}),n});this.data.refs.push(...e.default(m)),this.data.refs.push(...d.map(e=>(e.endpoints[0].tableName=r,e.endpoints[0].schemaName=i,e)));let h=o.reduce((e,t)=>(e[t.kind]=t.value,e),{}),g=new s.Table({name:r,schemaName:i,fields:l.map(e=>e.field),indexes:u,checks:p,...h});if(f){let e=g.fields.find(e=>e.name===f.columns[0].value);e&&(e.pk=!0)}this.data.tables.push(g.toJSON())}else t.alterTable()?t.alterTable().accept(this):t.createIndex()&&t.createIndex().accept(this)}visitCopyCreateTable(){}visitQueryCreateTable(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this));return e.createDefinitions()?{tableName:t,schemaName:n,definitions:e.createDefinitions().accept(this).filter(e=>e?.kind),options:e.tableOption()?.map(e=>e.accept(this)).filter(e=>e?.kind)||[]}:null}visitColumnCreateTable(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this));return{tableName:t,schemaName:n,definitions:e.createDefinitions().accept(this).filter(e=>e?.kind),options:e.tableOption().map(e=>e.accept(this)).filter(e=>e?.kind)}}visitTableOptionComment(e){let t=e.STRING_LITERAL().getText();return{kind:d.NOTE,value:{value:t.slice(1,t.length-1)}}}visitTableName(e){return e.fullId().accept(this)}visitFullId(e){let t=e.uid().map(e=>e.accept(this));if(e.DOT_ID()){let n=e.DOT_ID().getText();t.push(n.slice(1))}return t}visitUid(e){if(e.simpleId())return e.simpleId().accept(this);let t=e.getChild(0).getText();return t.slice(1,t.length-1)}visitSimpleId(e){return e.getChild(0).getText()}visitCreateDefinitions(e){return e.createDefinition().map(e=>e.accept(this))}visitColumnDeclaration(e){let{fieldName:t}=h(e.fullColumnName().accept(this)),{type:n,constraints:r}=e.columnDefinition().accept(this),i=new s.Field({name:t,type:n,...r});return{kind:c.TABLE_CONSTRAINT_KIND.FIELD,value:{field:i,inlineRefs:r.inlineRefs}}}visitConstraintDeclaration(e){return e.tableConstraint().accept(this)}visitIndexDeclaration(e){return e.indexColumnDefinition().accept(this)}visitFullColumnName(e){let t=[];return e.uid()&&t.push(e.uid().accept(this)),t.push(...e.dottedId().map(e=>e.accept(this))),t}visitDottedId(e){return e.DOT_ID()?e.DOT_ID().getText().slice(1):e.uid().accept(this)}visitColumnDefinition(e){let t=e.dataType().accept(this),n={inlineRefs:[],checks:[]};return e.columnConstraint().forEach(e=>{let t=e.accept(this);t&&(t.kind===c.COLUMN_CONSTRAINT_KIND.INLINE_REF?n.inlineRefs.push(t.value):t.kind===c.COLUMN_CONSTRAINT_KIND.CHECK?n.checks.push(t.value):n[t.kind]=t.value)}),{type:t,constraints:n}}visitStringDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),{type_name:t,schemaName:null}}visitNationalVaryingStringDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),{type_name:t,schemaName:null}}visitNationalStringDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),{type_name:t,schemaName:null}}visitDimensionDataType(e){let t=e.typeName.text;return e.lengthOneDimension()&&(t+=e.lengthOneDimension().getText()),e.lengthTwoDimension()&&(t+=e.lengthTwoDimension().getText()),e.lengthTwoOptionalDimension()&&(t+=e.lengthTwoOptionalDimension().getText()),{type_name:t,schemaName:null}}visitSimpleDataType(e){return{type_name:e.typeName.text,schemaName:null}}visitCollectionDataType(e){return e.SET()?{type_name:e.typeName.text+e.collectionOptions().getText(),schemaName:null}:{type_name:e.typeName.text,args:e.collectionOptions().accept(this),schemaName:null}}visitCollectionOptions(e){return e.STRING_LITERAL().map(e=>e.getText())}visitSpatialDataType(e){return{type_name:e.typeName.text,schemaName:null}}visitLongVarcharDataType(e){return{type_name:e.typeName.text,schemaName:null}}visitLongVarbinaryDataType(e){return{type_name:`${e.LONG().getText()} ${e.VARBINARY().getText()}`,schemaName:null}}visitNullColumnConstraint(e){return e.nullNotnull().accept(this)}visitNullNotnull(e){let t=!1;return e.NOT()&&(t=!0),{kind:c.COLUMN_CONSTRAINT_KIND.NOT_NULL,value:t}}visitDefaultColumnConstraint(e){return{kind:c.COLUMN_CONSTRAINT_KIND.DEFAULT,value:e.defaultValue().accept(this)}}visitAutoIncrementColumnConstraint(e){return e.AUTO_INCREMENT()?{kind:c.COLUMN_CONSTRAINT_KIND.INCREMENT,value:!0}:null}visitPrimaryKeyColumnConstraint(e){return e.PRIMARY()?{kind:c.COLUMN_CONSTRAINT_KIND.PK,value:!0}:null}visitUniqueKeyColumnConstraint(){return{kind:c.COLUMN_CONSTRAINT_KIND.UNIQUE,value:!0}}visitCommentColumnConstraint(e){let t=e.STRING_LITERAL().getText();return{kind:c.COLUMN_CONSTRAINT_KIND.NOTE,value:{value:t.slice(1,t.length-1)}}}visitReferenceColumnConstraint(e){let t=e.referenceDefinition().accept(this);return{kind:c.COLUMN_CONSTRAINT_KIND.INLINE_REF,value:t}}visitCheckColumnConstraint(e){let t=e.name?.accept(this),n=l.getOriginalText(e.expression());return{kind:c.COLUMN_CONSTRAINT_KIND.CHECK,value:{expression:n,name:t}}}visitDefaultValue(e){if(e.NULL_LITERAL())return{value:e.NULL_LITERAL().getText().toLowerCase(),type:c.DATA_TYPE.BOOLEAN};if(e.expression())return{value:e.expression().getText(),type:c.DATA_TYPE.EXPRESSION};if(e.constant()){if(e.unaryOperator())return{value:e.getText(),type:c.DATA_TYPE.EXPRESSION};let{value:t,type:n}=e.constant().accept(this);return{value:t,type:n}}return e.currentTimestamp()?.length?{value:e.currentTimestamp()[0].getText(),type:c.DATA_TYPE.EXPRESSION}:{value:e.getText(),type:c.DATA_TYPE.EXPRESSION}}visitConstant(e){if(e.stringLiteral()){let t=e.stringLiteral().getText();return{value:t.slice(1,t.length-1),type:c.DATA_TYPE.STRING}}return e.decimalLiteral()?e.getChildCount()>1?{value:e.getText(),type:c.DATA_TYPE.EXPRESSION}:{value:e.decimalLiteral().getText(),type:c.DATA_TYPE.NUMBER}:e.hexadecimalLiteral()?{value:e.hexadecimalLiteral().getText(),type:c.DATA_TYPE.NUMBER}:e.booleanLiteral()?{value:e.booleanLiteral().getText(),type:c.DATA_TYPE.BOOLEAN}:e.REAL_LITERAL()?{value:e.REAL_LITERAL().getText(),type:c.DATA_TYPE.NUMBER}:e.BIT_STRING()?{value:e.BIT_STRING().getText(),type:c.DATA_TYPE.STRING}:e.NULL_LITERAL()?{value:e.NULL_LITERAL().getText().toLowerCase(),type:c.DATA_TYPE.BOOLEAN}:{value:e.getText(),type:c.DATA_TYPE.STRING}}visitReferenceDefinition(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this));if(!e.indexColumnNames())return null;let r=e.referenceAction()?.accept(this)||{},i=e.indexColumnNames().accept(this).map(e=>e.value),a=new s.Endpoint({tableName:null,schemaName:null,fieldNames:null,relation:u.CARDINALITY_MANY}),o=new s.Endpoint({tableName:t,schemaName:n,fieldNames:i,relation:u.CARDINALITY_MAYBE});return new s.Ref({endpoints:[a,o],onUpdate:r.onUpdate,onDelete:r.onDelete})}visitIndexColumnNames(e){return e.indexColumnName().map(e=>e.accept(this))}visitIndexColumnName(e){let t=e.DESC()?{sortOrder:`desc`}:{};if(e.uid())return{type:c.CONSTRAINT_TYPE.COLUMN,value:e.uid().accept(this),...t};if(e.STRING_LITERAL()){let n=e.STRING_LITERAL().getText();return{type:c.CONSTRAINT_TYPE.STRING,value:n.slice(1,n.length-1),...t}}return{type:c.CONSTRAINT_TYPE.EXPRESSION,value:e.expression().getText(),...t}}visitReferenceAction(e){let t={};return t.onDelete=e.onDelete?.accept(this),t.onUpdate=e.onUpdate?.accept(this),t}visitReferenceControlType(e){let t=[...Array(e.getChildCount()).keys()].reduce((t,n)=>`${t}${e.getChild(n).getText()} `,``);return t.slice(0,t.length-1)}visitPrimaryKeyTableConstraint(e){let t=e.name?.accept(this)||e.index?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.PK,value:new s.Index({name:t,pk:!0,columns:r,type:n})}}visitUniqueKeyTableConstraint(e){let t=e.name?.accept(this)||e.index?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.UNIQUE,value:new s.Index({name:t,unique:!0,columns:r,type:n})}}visitForeignKeyTableConstraint(e){let t=e.referenceDefinition().accept(this);return t.name=e.name?.accept(this)||e.index?.accept(this),t.endpoints[0].fieldNames=e.indexColumnNames().accept(this).map(e=>e.value),{kind:c.TABLE_CONSTRAINT_KIND.FK,value:t}}visitCheckTableConstraint(e){let t=e.name?.accept(this),n=l.getOriginalText(e.expression());return{kind:c.TABLE_CONSTRAINT_KIND.CHECK,value:{expression:n,name:t}}}visitIndexType(e){return e.getChild(1).getText()}visitIndexOption(e){return e.indexType()?{kind:p.TYPE,value:e.indexType().accept(this)}:null}visitSimpleIndexDeclaration(e){let t=e.uid()?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.INDEX,value:new s.Index({name:t,columns:r,type:n})}}visitSpecialIndexDeclaration(e){let t=e.uid()?.accept(this),n=null;if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:c.TABLE_CONSTRAINT_KIND.INDEX,value:new s.Index({name:t,columns:r,type:n})}}visitAlterTable(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this)),r=this.findTable(n,t);r&&(e.alterSpecification()?.map(e=>e.accept(this)).filter(e=>e?.kind)||[]).forEach(e=>{if(e.kind===f.ADD_PK){let t=e.value;if(t.columns.length>1)return r.indexes.push(t);let n=r.fields.find(e=>e.name===t.columns[0].value);n.pk=!0}else if(e.kind===f.ADD_FK){let r=e.value;r.endpoints[0].schemaName=n,r.endpoints[0].tableName=t,this.data.refs.push(r)}else e.kind===f.ADD_CHECK&&r.checks.push(e.value);return null})}visitAlterByAddPrimaryKey(e){let t=e.name?.accept(this)||e.index?.accept(this),n=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(n=t.value)}let r=e.indexColumnNames().accept(this);return{kind:f.ADD_PK,value:new s.Index({name:t,pk:!0,columns:r,type:n})}}visitAlterByAddForeignKey(e){let t=e.referenceDefinition().accept(this);return t.name=e.name?.accept(this)||e.index?.accept(this),t.endpoints[0].fieldNames=e.indexColumnNames().accept(this).map(e=>e.value),{kind:f.ADD_FK,value:t}}visitAlterByAddCheckTableConstraint(e){let t=e.name?.accept(this),n=l.getOriginalText(e.expression());return{kind:f.ADD_CHECK,value:{expression:n,name:t}}}visitCreateIndex(e){let{tableName:t,schemaName:n}=m(e.tableName().accept(this)),r=this.findTable(n,t);if(!r)return;let i=e.uid().accept(this),a=e.indexType()?.accept(this);if(e.indexOption()?.length){let t=e.indexOption().map(e=>e.accept(this)).find(e=>e?.kind===p.TYPE);t&&(a=t.value)}let o=e.indexColumnNames().accept(this),c=new s.Index({name:i,columns:o,unique:!!e.UNIQUE(),type:a});r.indexes.push(c)}visitDmlStatement(e){e.insertStatement()&&e.insertStatement().accept(this)}visitInsertStatement(e){let n=e.tableName().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=e.fullColumnNameList()?e.fullColumnNameList().accept(this):this.findTable(i,r)?.fields.map(e=>e.name)||[],o=e.insertStatementValue().accept(this),c=new s.TableRecord({schemaName:i,tableName:r,columns:a,values:o});this.data.records.push(c)}visitFullColumnNameList(e){let t=e.fullColumnName().map(e=>e.accept(this));return n.default(t,1)}visitInsertStatementValue(e){return e.expressionsWithDefaults().map(e=>{let t=e.accept(this);return n.default(t,1)})}visitExpressionsWithDefaults(e){return e.expressionOrDefault().map(e=>{let t=e.accept(this);return n.default(t,3)})}visitFunctionCallExpressionAtom(e){return{value:e.getText(),type:c.DATA_TYPE.EXPRESSION}}};exports.default=g;
@@ -2,15 +2,15 @@ import e from "../../../../node_modules/lodash-es/flatten.mjs";
2
2
  import t from "../../../../node_modules/lodash-es/last.mjs";
3
3
  import n from "../../../../node_modules/lodash-es/flattenDepth.mjs";
4
4
  import { init_lodash as r } from "../../../../node_modules/lodash-es/lodash.mjs";
5
- import "../../../../model_structure/config.mjs";
6
5
  import { ParseTreeListener as i, ParseTreeWalker as a } from "../../../../node_modules/antlr4/dist/antlr4.web.mjs";
7
6
  import o from "../../parsers/mysql/MySqlParserVisitor.mjs";
8
7
  import s from "../../parsers/mysql/MySqlParser.mjs";
9
8
  import { Endpoint as c, Enum as l, Field as u, Index as d, Ref as f, Table as p, TableRecord as m } from "../AST.mjs";
10
9
  import { COLUMN_CONSTRAINT_KIND as h, CONSTRAINT_TYPE as g, DATA_TYPE as _, TABLE_CONSTRAINT_KIND as v } from "../constants.mjs";
11
10
  import { getOriginalText as y } from "../helpers.mjs";
11
+ import "../../../../model_structure/config.mjs";
12
12
  import { CARDINALITY_MANY as b, CARDINALITY_MAYBE as x, normalizeQualifiedName as S } from "@dbml/parse";
13
- //#region src/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js
13
+ // src/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js
14
14
  r();
15
15
  var C = { NOTE: "note" }, w = {
16
16
  ADD_PK: "add_pk",
@@ -661,5 +661,4 @@ var C = { NOTE: "note" }, w = {
661
661
  };
662
662
  }
663
663
  };
664
- //#endregion
665
664
  export { O as default };
@@ -1 +1 @@
1
- require("../../../../_virtual/_rolldown/runtime.cjs");const e=require("../../../../node_modules/lodash-es/flatten.cjs"),t=require("../../../../node_modules/lodash-es/last.cjs"),n=require("../../../../node_modules/lodash-es/lodash.cjs"),r=require("../../../../node_modules/antlr4/dist/antlr4.web.cjs"),i=require("../../parsers/oraclesql/OracleSqlParserVisitor.cjs"),a=require("../../parsers/oraclesql/OracleSqlParser.cjs"),o=require("../AST.cjs"),s=require("../constants.cjs"),c=require("../helpers.cjs"),l=require("../../../error.cjs");let u=require("@dbml/parse");n.init_lodash();var d={FIELD:`table_field`,INDEX:`table_index`,FK:`table_fk`,UNIQUE:`table_unique`,PK:`table_pk`,DEFAULT:`table_default`,CHECK:`table_check`},f={NOT_NULL:`col_not_null`,NULLABLE:`col_nullable`,UNIQUE:`col_unique`,PK:`col_pk`,DEFAULT:`col_dbdefault`,INCREMENT:`col_increment`,INLINE_REF:`col_inline_ref`,NOTE:`col_note`,CHECK:`col_check`},p=(e,t,n)=>{let r=t??null;return e.find(e=>(e.schemaName??null)===r&&e.name===n)},m=(e,t)=>e.fields.find(e=>e.name===t),h=e=>({value:e.type===s.CONSTRAINT_TYPE.COLUMN?e.rawValue:e.value,type:e.type===s.CONSTRAINT_TYPE.COLUMN?s.DATA_TYPE.EXPRESSION:e.type}),g=e=>{let t;switch(e.type){case s.CONSTRAINT_TYPE.COLUMN:t=s.CONSTRAINT_TYPE.COLUMN;break;case s.DATA_TYPE.STRING:t=s.CONSTRAINT_TYPE.STRING;break;default:t=s.CONSTRAINT_TYPE.EXPRESSION}return{value:e.value.toString(),type:t}},_=(e,t)=>l.CompilerDiagnostics.create([{message:t,location:{start:{line:e.start.line,column:e.start.column+1},end:{line:e.stop.line,column:e.stop.column+c.getOriginalText(e).length+1}}}]),v=(e,t=`"`)=>e.startsWith(t)?e.slice(1,-1).replaceAll(`${t}${t}`,t):e,y=class extends i.default{constructor(){super(),this.data={schemas:[],tables:[],refs:[],deps:[],enums:[],tableGroups:[],aliases:[],project:{},records:[]}}visitCreate_view(e){let t=e.id_expression?e.id_expression():null;if(!t)return;let n=t.getText().replace(/"/g,``),r=e.schema_name?e.schema_name():null,i=r?r.getText().replace(/"/g,``):void 0,a=c.getOriginalText(e);this.data.tables.push({name:n,schemaName:i,fields:[],indexes:[],checks:[],note:null,headerColor:null,custom:{query:a,kind:`view`}}),b(this,e.select_only_statement(),n,i)}visitCreate_materialized_view(e){let t=(e.getText?e.getText():``).match(/MATERIALIZEDVIEW(?:IFNOTEXISTS)?(?:"([^"]+)"\.)?"?([^("\s]+)"?/i);if(!t)return;let n=t[1]||void 0,r=t[2],i=c.getOriginalText(e);this.data.tables.push({name:r,schemaName:n,fields:[],indexes:[],checks:[],note:null,headerColor:null,custom:{query:i,kind:`materialized_view`,materialized:!0}}),b(this,e.select_only_statement(),r,n)}visitSql_script(e){return e.unit_statement()?.forEach(e=>e.accept(this)),this.data}visitUnit_statement(e){e.create_table()?e.create_table().accept(this):e.comment_on_table()?e.comment_on_table().accept(this):e.comment_on_column()?e.comment_on_column().accept(this):e.alter_table()?e.alter_table().accept(this):e.create_index()?e.create_index().accept(this):e.data_manipulation_language_statements()&&e.data_manipulation_language_statements().accept(this)}visitData_manipulation_language_statements(e){e.insert_statement()&&e.insert_statement().accept(this)}visitCreate_table(t){let n=t.table_name().accept(this),r=t.schema_name()?t.schema_name().accept(this):void 0;if(t.relational_table()){let[i,a,s,c]=t.relational_table().accept(this).reduce((e,t)=>(t.type===d.FIELD?e[0].push(t.value):[d.INDEX,d.UNIQUE,d.PK].includes(t.type)?e[1].push(t.value):t.type===d.FK?e[2].push(t.value):t.type===d.CHECK&&e[3].push(...t.value.checks),e),[[],[],[],[]]);this.data.refs.push(...e.default(i.map(e=>e.inline_refs.map(t=>(t.endpoints[0].tableName=n,t.endpoints[0].schemaName=r,t.endpoints[0].fieldNames=[e.field.name],t))))),this.data.refs.push(...s.map(e=>(e.endpoints[0].tableName=n,e.endpoints[0].schemaName=r,e))),this.data.tables.push(new o.Table({name:n,schemaName:r,fields:i.map(e=>e.field),indexes:a,checks:c}))}}visitRelational_table(e){return e.relational_property()?e.relational_property().map(e=>e.accept(this)):[]}visitRelational_property(e){return e.column_definition()?e.column_definition().accept(this):e.out_of_line_constraint()?e.out_of_line_constraint().accept(this):e.out_of_line_ref_constraint()?e.out_of_line_ref_constraint().accept(this):null}visitColumn_definition(e){let n=t.default(e.column_name().accept(this)),r=e.datatype()?.accept(this)||e.type_name()?.accept(this);if(!r)throw _(e,`Importing a column definition without a type is not supported`);let i=(e.inline_constraint()||[]).map(e=>e.accept(this)).filter(Boolean);if(e.DEFAULT()){let t=e.expression().accept(this);i.push({type:f.DEFAULT,value:{dbdefault:h(t)}})}e.identity_clause()&&i.push({type:f.INCREMENT,value:{increment:!0}});let a={checks:[],inline_refs:[]};i.forEach(e=>{switch(e.type){case f.DEFAULT:a.dbdefault=e.value.dbdefault;break;case f.NOT_NULL:a.not_null=!0;break;case f.NULLABLE:a.not_null=!1;break;case f.PK:a.pk=!0;break;case f.UNIQUE:a.unique=!0;break;case f.CHECK:a.checks.push(...e.value.checks);break;case f.INCREMENT:a.increment=!0;break;case f.FK:a.inline_refs.push(...e.value.inline_refs)}});let s=new o.Field({name:n,type:r,...a});return{type:d.FIELD,value:{field:s,inline_refs:a.inline_refs||[]}}}visitInline_constraint(e){if(e.NULL_()&&e.NOT())return{type:f.NOT_NULL,value:{not_null:!0}};if(e.NULL_())return{type:f.NULLABLE,value:{not_null:!1}};if(e.UNIQUE())return{type:f.UNIQUE,value:{unique:!0}};if(e.PRIMARY())return{type:f.PK,value:{pk:!0}};let t=e.constraint_name()?.accept(this);if(e.references_clause()){let n=e.references_clause().accept(this);return n.name=t,{type:f.FK,value:{inline_refs:[n]}}}if(e.check_constraint()){let n=e.check_constraint();n.isColumn=!0;let r=n.accept(this);return r.value.checks[0].name=t,r}return null}visitOut_of_line_constraint(e){if(e.UNIQUE()){let n=e.column_name().map(e=>({value:t.default(e.accept(this)),type:s.CONSTRAINT_TYPE.COLUMN}));return{type:d.UNIQUE,value:new o.Index({columns:n,unique:!0,name:e.constraint_name()?.accept(this)})}}if(e.PRIMARY()){let n=e.column_name().map(e=>({value:t.default(e.accept(this)),type:s.CONSTRAINT_TYPE.COLUMN}));return{type:d.PK,value:new o.Index({columns:n,pk:!0,name:e.constraint_name()?.accept(this)})}}if(e.foreign_key_clause()){let t=e.foreign_key_clause().accept(this);return t.value.name=e.constraint_name()?.accept(this),t}if(e.condition()){let t=c.getOriginalText(e.condition());return{type:d.CHECK,value:{checks:[{name:e.constraint_name()?.accept(this),expression:t}]}}}return null}visitOut_of_line_ref_constraint(e){let t=e.constraint_name()?.accept(this),n=e.regular_id().map(e=>e.accept(this)),r=e.references_clause().accept(this);return r.endpoints[0].fieldNames=n,t&&(r.name=t),{type:d.FK,value:r}}visitForeign_key_clause(e){let n=e.paren_column_list().accept(this).map(e=>t.default(e)),r=e.references_clause().accept(this);return r.endpoints[0].fieldNames=n,e.on_delete_clause()&&(r.onDelete=e.on_delete_clause().accept(this)),{type:d.FK,value:r}}visitReferences_clause(e){if(!e.paren_column_list())throw _(e.tableview_name(),`Importing a foreign key with implicit referenced columns is not supported`);let n=e.tableview_name().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=e.paren_column_list().accept(this).map(e=>t.default(e));return new o.Ref({endpoints:[new o.Endpoint({tableName:null,schemaName:null,fieldNames:[],relation:u.CARDINALITY_MANY}),new o.Endpoint({tableName:r,schemaName:i,fieldNames:a,relation:u.CARDINALITY_MAYBE})]})}visitOn_delete_clause(e){return e.CASCADE()?`cascade`:e.SET()&&e.NULL_()?`set null`:null}visitCheck_constraint(e){let t=c.getOriginalText(e.condition());return{type:e.isColumn?f.CHECK:d.CHECK,value:{checks:[{expression:t}]}}}visitColumn_list(e){return e.column_name().map(e=>e.accept(this))}visitTableview_name(e){let t=e.id_expression()?[e.identifier().accept(this)]:[],n=e.id_expression()?e.id_expression().accept(this):e.identifier().accept(this);return[...t,n]}visitSchema_name(e){return e.identifier().accept(this)}visitTable_name(e){return e.identifier().accept(this)}visitColumn_name(e){return[e.identifier().accept(this)].concat(e.id_expression().map(e=>e.accept(this)))}visitIdentifier(e){return v(c.getOriginalText(e))}visitType_name(e){let n=e.id_expression().map(e=>e.accept(this));return{type_name:t.default(n),schemaName:n.length>1?n[n.length-2]:void 0}}visitDatatype(e){return{type_name:v(c.getOriginalText(e))}}visitComment_on_table(e){let n=e.tableview_name().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=p(this.data.tables,i,r);if(!a)throw _(e.tableview_name(),`Table "${r}" not found`);a.note={value:e.quoted_string().accept(this)}}visitComment_on_column(e){let n=e.column_name().accept(this),r=t.default(n);n.pop();let i=t.default(n);n.pop();let a=t.default(n),o=p(this.data.tables,a,i);if(!o)throw _(e.column_name(),`Table "${i}" not found`);let s=m(o,r);if(!s)throw _(e.column_name(),`Column "${r}" not found in table "${i}"`);s.note={value:e.quoted_string().accept(this)}}visitAlter_table(e){let n=e.tableview_name().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=p(this.data.tables,i,r);if(!a)throw _(e.tableview_name(),`Table "${r}" not found`);function o(e,t){switch(t.type){case d.FK:case f.FK:t.value.endpoints[0].tableName=r,t.value.endpoints[0].schemaName=i,this.data.refs.push(t.value);break;case d.CHECK:a.checks||=[],a.checks.push(...t.value.checks);break;case f.CHECK:e.checks||(a.checks=[]),e.checks.push(...t.value.checks);break;case f.PK:e.pk=!0,e.unique=void 0;break;case f.UNIQUE:e.unique=!0;break;case d.UNIQUE:case d.INDEX:case d.PK:a.indexes||=[],a.indexes.push(t.value);break;case f.DEFAULT:e.dbdefault=t.value.dbdefault;break;case f.NOT_NULL:e.not_null=!0;break;case f.NULLABLE:e.not_null=!1;break;case f.INCREMENT:e.increment=!0}}(e.constraint_clauses()||e.column_clauses())&&(e.constraint_clauses()?[{column:null,constraints:e.constraint_clauses().accept(this)}]:e.column_clauses().accept(this)).forEach(t=>{let n=t.column===null?null:m(a,t.column);if(t.column!==null&&!n)throw _(e.tableview_name(),`Column "${t.column}" not found on Table "${r}"`);t.constraints.forEach(e=>o.bind(this)(n,e))})}visitColumn_clauses(e){return e.add_modify_drop_column_clauses()?e.add_modify_drop_column_clauses().accept(this):[]}visitAdd_modify_drop_column_clauses(e){let t=[];return e.constraint_clauses()&&t.push({column:null,constraints:e.constraint_clauses().flatMap(e=>e.accept(this))}),e.modify_column_clauses()&&t.push(...e.modify_column_clauses().flatMap(e=>e.accept(this))),t}visitModify_column_clauses(e){return e.modify_col_properties().map(e=>e.accept(this))}visitModify_col_properties(e){let n=[],r=t.default(e.column_name().accept(this));if(e.DEFAULT()){let t=e.expression().accept(this);n.push({type:f.DEFAULT,value:{dbdefault:h(t)}})}else e.inline_constraint()&&n.push(...e.inline_constraint().map(e=>e.accept(this)));return{column:r,constraints:n}}visitConstraint_clauses(e){return e.out_of_line_constraint()?e.out_of_line_constraint().map(e=>e.accept(this)).filter(Boolean):e.out_of_line_ref_constraint()?[e.out_of_line_ref_constraint().accept(this)]:[]}visitCreate_index(e){if(!e.table_index_clause())return;let n=!!e.UNIQUE(),r=!!e.BITMAP(),i=e.index_name().accept(this),{names:a,columns:s}=e.table_index_clause().accept(this),c=t.default(a),l=a.length>1?a[a.length-2]:void 0,u=p(this.data.tables,l,c);if(!u)throw _(e.table_index_clause(),`Table ${c} not found`);u.indexes||=[],u.indexes.push(new o.Index({name:i,columns:s,unique:n,type:r?`bitmap`:void 0}))}visitTable_index_clause(e){return{names:e.tableview_name().accept(this),columns:e.index_expr().map(t=>({...t.accept(this),...e.children[e.children.indexOf(t)+1]?.symbol?.type===a.default.DESC&&{sortOrder:`desc`}}))}}visitConstraint_name(e){return v(c.getOriginalText(e))}visitIndex_name(e){return e.identifier().accept(this)}visitIndex_expr(e){if(e.expression()){let t=g(e.expression().accept(this));return{value:t.value,type:t.type}}return{value:t.default(e.column_name().accept(this)),type:s.CONSTRAINT_TYPE.COLUMN}}visitInsert_statement(e){e.single_table_insert()?e.single_table_insert().accept(this):e.multi_table_insert()&&e.multi_table_insert().accept(this)}visitSingle_table_insert(e){let t=e.insert_into_clause().accept(this),n=e.values_clause().accept(this);if(t&&n){let{tableName:e,schemaName:r,columns:i}=t,{values:a}=n,s=new o.TableRecord({schemaName:r,tableName:e,columns:i,values:a});this.data.records.push(s)}}visitMulti_table_insert(e){if(!e.multi_table_element())return;let t=e.multi_table_element().map(e=>e.accept(this)).filter(Boolean),n=new Map;t.forEach(e=>{let{tableName:t,schemaName:r,columns:i,values:a}=e,o=`${r||``}.${t}.${i.join(`,`)}`;n.has(o)?n.get(o).values.push(...a):n.set(o,{tableName:t,schemaName:r,columns:i,values:a})}),n.forEach(e=>{let t=new o.TableRecord({schemaName:e.schemaName,tableName:e.tableName,columns:e.columns,values:e.values});this.data.records.push(t)})}visitMulti_table_element(e){let t=e.insert_into_clause().accept(this),n=e.values_clause()?.accept(this);if(t&&n){let{tableName:e,schemaName:r,columns:i}=t,{values:a}=n;return{tableName:e,schemaName:r,columns:i,values:a}}return null}visitInsert_into_clause(e){let n=e.general_table_ref().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0;return{tableName:r,schemaName:i,columns:e.paren_column_list()?e.paren_column_list().accept(this).map(e=>t.default(e)):p(this.data.tables,i,r)?.fields.map(e=>e.name)}}visitGeneral_table_ref(e){return e.dml_table_expression_clause().accept(this)}visitDml_table_expression_clause(e){return e.tableview_name()?e.tableview_name().accept(this):[]}visitParen_column_list(e){return e.column_list().accept(this)}visitValues_clause(e){return{values:[e.expressions_().accept(this).map(e=>({value:e.type===s.CONSTRAINT_TYPE.COLUMN?e.rawValue:e.value,type:e.type===s.CONSTRAINT_TYPE.COLUMN?s.DATA_TYPE.EXPRESSION:e.type}))]}}visitExpressions_(e){return e.expression().map(e=>e.accept(this))}visitId_expression(e){return v(c.getOriginalText(e))}visitExpression(e){let t=c.getOriginalText(e);return e.CHAR_STRING()?{type:s.DATA_TYPE.STRING,value:v(t,`'`)}:e.TRUE()?{type:s.DATA_TYPE.BOOLEAN,value:!0}:e.FALSE()?{type:s.DATA_TYPE.BOOLEAN,value:!1}:e.NULL_()?{type:s.DATA_TYPE.BOOLEAN,value:null}:e.APPROXIMATE_NUM_LIT()||e.UNSIGNED_INTEGER()?{type:s.DATA_TYPE.NUMBER,value:parseFloat(t)}:e.column_name()?{type:s.CONSTRAINT_TYPE.COLUMN,rawValue:v(t),value:v(c.getOriginalText(e.column_name()))}:{type:s.CONSTRAINT_TYPE.EXPRESSION,value:t}}visitQuoted_string(e){return v(c.getOriginalText(e),`'`)}visitRegular_id(e){return v(c.getOriginalText(e),`"`)}};function b(e,n,i,o){if(!n)return;let s=new Set,c=(0,u.normalizeQualifiedName)(o??``,i),l=new r.ParseTreeListener;l.enterEveryRule=n=>{if(!(n instanceof a.default.Tableview_nameContext))return;let r=n.accept(e),l=Array.isArray(r)?t.default(r):r,d=Array.isArray(r)&&r.length>1?r[r.length-2]:void 0,f=(0,u.normalizeQualifiedName)(d??``,l);f!==c&&(s.has(f)||p(e.data.tables,d,l)&&(s.add(f),e.data.deps.push({edges:[{upstream:{schemaName:d,tableName:l,fieldNames:[]},downstream:{schemaName:o,tableName:i,fieldNames:[]}}],note:null,custom:{}})))},r.ParseTreeWalker.DEFAULT.walk(l,n)}exports.default=y;
1
+ require("../../../../_virtual/_rolldown/runtime.cjs");const e=require("../../../../node_modules/lodash-es/flatten.cjs"),t=require("../../../../node_modules/lodash-es/last.cjs"),n=require("../../../../node_modules/lodash-es/lodash.cjs"),r=require("../../../../node_modules/antlr4/dist/antlr4.web.cjs"),i=require("../../../error.cjs"),a=require("../../parsers/oraclesql/OracleSqlParserVisitor.cjs"),o=require("../../parsers/oraclesql/OracleSqlParser.cjs"),s=require("../AST.cjs"),c=require("../constants.cjs"),l=require("../helpers.cjs");let u=require("@dbml/parse");n.init_lodash();var d={FIELD:`table_field`,INDEX:`table_index`,FK:`table_fk`,UNIQUE:`table_unique`,PK:`table_pk`,DEFAULT:`table_default`,CHECK:`table_check`},f={NOT_NULL:`col_not_null`,NULLABLE:`col_nullable`,UNIQUE:`col_unique`,PK:`col_pk`,DEFAULT:`col_dbdefault`,INCREMENT:`col_increment`,INLINE_REF:`col_inline_ref`,NOTE:`col_note`,CHECK:`col_check`},p=(e,t,n)=>{let r=t??null;return e.find(e=>(e.schemaName??null)===r&&e.name===n)},m=(e,t)=>e.fields.find(e=>e.name===t),h=e=>({value:e.type===c.CONSTRAINT_TYPE.COLUMN?e.rawValue:e.value,type:e.type===c.CONSTRAINT_TYPE.COLUMN?c.DATA_TYPE.EXPRESSION:e.type}),g=e=>{let t;switch(e.type){case c.CONSTRAINT_TYPE.COLUMN:t=c.CONSTRAINT_TYPE.COLUMN;break;case c.DATA_TYPE.STRING:t=c.CONSTRAINT_TYPE.STRING;break;default:t=c.CONSTRAINT_TYPE.EXPRESSION}return{value:e.value.toString(),type:t}},_=(e,t)=>i.CompilerDiagnostics.create([{message:t,location:{start:{line:e.start.line,column:e.start.column+1},end:{line:e.stop.line,column:e.stop.column+l.getOriginalText(e).length+1}}}]),v=(e,t=`"`)=>e.startsWith(t)?e.slice(1,-1).replaceAll(`${t}${t}`,t):e,y=class extends a.default{constructor(){super(),this.data={schemas:[],tables:[],refs:[],deps:[],enums:[],tableGroups:[],aliases:[],project:{},records:[]}}visitCreate_view(e){let t=e.id_expression?e.id_expression():null;if(!t)return;let n=t.getText().replace(/"/g,``),r=e.schema_name?e.schema_name():null,i=r?r.getText().replace(/"/g,``):void 0,a=l.getOriginalText(e);this.data.tables.push({name:n,schemaName:i,fields:[],indexes:[],checks:[],note:null,headerColor:null,custom:{query:a,kind:`view`}}),b(this,e.select_only_statement(),n,i)}visitCreate_materialized_view(e){let t=(e.getText?e.getText():``).match(/MATERIALIZEDVIEW(?:IFNOTEXISTS)?(?:"([^"]+)"\.)?"?([^("\s]+)"?/i);if(!t)return;let n=t[1]||void 0,r=t[2],i=l.getOriginalText(e);this.data.tables.push({name:r,schemaName:n,fields:[],indexes:[],checks:[],note:null,headerColor:null,custom:{query:i,kind:`materialized_view`,materialized:!0}}),b(this,e.select_only_statement(),r,n)}visitSql_script(e){return e.unit_statement()?.forEach(e=>e.accept(this)),this.data}visitUnit_statement(e){e.create_table()?e.create_table().accept(this):e.comment_on_table()?e.comment_on_table().accept(this):e.comment_on_column()?e.comment_on_column().accept(this):e.alter_table()?e.alter_table().accept(this):e.create_index()?e.create_index().accept(this):e.data_manipulation_language_statements()&&e.data_manipulation_language_statements().accept(this)}visitData_manipulation_language_statements(e){e.insert_statement()&&e.insert_statement().accept(this)}visitCreate_table(t){let n=t.table_name().accept(this),r=t.schema_name()?t.schema_name().accept(this):void 0;if(t.relational_table()){let[i,a,o,c]=t.relational_table().accept(this).reduce((e,t)=>(t.type===d.FIELD?e[0].push(t.value):[d.INDEX,d.UNIQUE,d.PK].includes(t.type)?e[1].push(t.value):t.type===d.FK?e[2].push(t.value):t.type===d.CHECK&&e[3].push(...t.value.checks),e),[[],[],[],[]]);this.data.refs.push(...e.default(i.map(e=>e.inline_refs.map(t=>(t.endpoints[0].tableName=n,t.endpoints[0].schemaName=r,t.endpoints[0].fieldNames=[e.field.name],t))))),this.data.refs.push(...o.map(e=>(e.endpoints[0].tableName=n,e.endpoints[0].schemaName=r,e))),this.data.tables.push(new s.Table({name:n,schemaName:r,fields:i.map(e=>e.field),indexes:a,checks:c}))}}visitRelational_table(e){return e.relational_property()?e.relational_property().map(e=>e.accept(this)):[]}visitRelational_property(e){return e.column_definition()?e.column_definition().accept(this):e.out_of_line_constraint()?e.out_of_line_constraint().accept(this):e.out_of_line_ref_constraint()?e.out_of_line_ref_constraint().accept(this):null}visitColumn_definition(e){let n=t.default(e.column_name().accept(this)),r=e.datatype()?.accept(this)||e.type_name()?.accept(this);if(!r)throw _(e,`Importing a column definition without a type is not supported`);let i=(e.inline_constraint()||[]).map(e=>e.accept(this)).filter(Boolean);if(e.DEFAULT()){let t=e.expression().accept(this);i.push({type:f.DEFAULT,value:{dbdefault:h(t)}})}e.identity_clause()&&i.push({type:f.INCREMENT,value:{increment:!0}});let a={checks:[],inline_refs:[]};i.forEach(e=>{switch(e.type){case f.DEFAULT:a.dbdefault=e.value.dbdefault;break;case f.NOT_NULL:a.not_null=!0;break;case f.NULLABLE:a.not_null=!1;break;case f.PK:a.pk=!0;break;case f.UNIQUE:a.unique=!0;break;case f.CHECK:a.checks.push(...e.value.checks);break;case f.INCREMENT:a.increment=!0;break;case f.FK:a.inline_refs.push(...e.value.inline_refs)}});let o=new s.Field({name:n,type:r,...a});return{type:d.FIELD,value:{field:o,inline_refs:a.inline_refs||[]}}}visitInline_constraint(e){if(e.NULL_()&&e.NOT())return{type:f.NOT_NULL,value:{not_null:!0}};if(e.NULL_())return{type:f.NULLABLE,value:{not_null:!1}};if(e.UNIQUE())return{type:f.UNIQUE,value:{unique:!0}};if(e.PRIMARY())return{type:f.PK,value:{pk:!0}};let t=e.constraint_name()?.accept(this);if(e.references_clause()){let n=e.references_clause().accept(this);return n.name=t,{type:f.FK,value:{inline_refs:[n]}}}if(e.check_constraint()){let n=e.check_constraint();n.isColumn=!0;let r=n.accept(this);return r.value.checks[0].name=t,r}return null}visitOut_of_line_constraint(e){if(e.UNIQUE()){let n=e.column_name().map(e=>({value:t.default(e.accept(this)),type:c.CONSTRAINT_TYPE.COLUMN}));return{type:d.UNIQUE,value:new s.Index({columns:n,unique:!0,name:e.constraint_name()?.accept(this)})}}if(e.PRIMARY()){let n=e.column_name().map(e=>({value:t.default(e.accept(this)),type:c.CONSTRAINT_TYPE.COLUMN}));return{type:d.PK,value:new s.Index({columns:n,pk:!0,name:e.constraint_name()?.accept(this)})}}if(e.foreign_key_clause()){let t=e.foreign_key_clause().accept(this);return t.value.name=e.constraint_name()?.accept(this),t}if(e.condition()){let t=l.getOriginalText(e.condition());return{type:d.CHECK,value:{checks:[{name:e.constraint_name()?.accept(this),expression:t}]}}}return null}visitOut_of_line_ref_constraint(e){let t=e.constraint_name()?.accept(this),n=e.regular_id().map(e=>e.accept(this)),r=e.references_clause().accept(this);return r.endpoints[0].fieldNames=n,t&&(r.name=t),{type:d.FK,value:r}}visitForeign_key_clause(e){let n=e.paren_column_list().accept(this).map(e=>t.default(e)),r=e.references_clause().accept(this);return r.endpoints[0].fieldNames=n,e.on_delete_clause()&&(r.onDelete=e.on_delete_clause().accept(this)),{type:d.FK,value:r}}visitReferences_clause(e){if(!e.paren_column_list())throw _(e.tableview_name(),`Importing a foreign key with implicit referenced columns is not supported`);let n=e.tableview_name().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=e.paren_column_list().accept(this).map(e=>t.default(e));return new s.Ref({endpoints:[new s.Endpoint({tableName:null,schemaName:null,fieldNames:[],relation:u.CARDINALITY_MANY}),new s.Endpoint({tableName:r,schemaName:i,fieldNames:a,relation:u.CARDINALITY_MAYBE})]})}visitOn_delete_clause(e){return e.CASCADE()?`cascade`:e.SET()&&e.NULL_()?`set null`:null}visitCheck_constraint(e){let t=l.getOriginalText(e.condition());return{type:e.isColumn?f.CHECK:d.CHECK,value:{checks:[{expression:t}]}}}visitColumn_list(e){return e.column_name().map(e=>e.accept(this))}visitTableview_name(e){let t=e.id_expression()?[e.identifier().accept(this)]:[],n=e.id_expression()?e.id_expression().accept(this):e.identifier().accept(this);return[...t,n]}visitSchema_name(e){return e.identifier().accept(this)}visitTable_name(e){return e.identifier().accept(this)}visitColumn_name(e){return[e.identifier().accept(this)].concat(e.id_expression().map(e=>e.accept(this)))}visitIdentifier(e){return v(l.getOriginalText(e))}visitType_name(e){let n=e.id_expression().map(e=>e.accept(this));return{type_name:t.default(n),schemaName:n.length>1?n[n.length-2]:void 0}}visitDatatype(e){return{type_name:v(l.getOriginalText(e))}}visitComment_on_table(e){let n=e.tableview_name().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=p(this.data.tables,i,r);if(!a)throw _(e.tableview_name(),`Table "${r}" not found`);a.note={value:e.quoted_string().accept(this)}}visitComment_on_column(e){let n=e.column_name().accept(this),r=t.default(n);n.pop();let i=t.default(n);n.pop();let a=t.default(n),o=p(this.data.tables,a,i);if(!o)throw _(e.column_name(),`Table "${i}" not found`);let s=m(o,r);if(!s)throw _(e.column_name(),`Column "${r}" not found in table "${i}"`);s.note={value:e.quoted_string().accept(this)}}visitAlter_table(e){let n=e.tableview_name().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0,a=p(this.data.tables,i,r);if(!a)throw _(e.tableview_name(),`Table "${r}" not found`);function o(e,t){switch(t.type){case d.FK:case f.FK:t.value.endpoints[0].tableName=r,t.value.endpoints[0].schemaName=i,this.data.refs.push(t.value);break;case d.CHECK:a.checks||=[],a.checks.push(...t.value.checks);break;case f.CHECK:e.checks||(a.checks=[]),e.checks.push(...t.value.checks);break;case f.PK:e.pk=!0,e.unique=void 0;break;case f.UNIQUE:e.unique=!0;break;case d.UNIQUE:case d.INDEX:case d.PK:a.indexes||=[],a.indexes.push(t.value);break;case f.DEFAULT:e.dbdefault=t.value.dbdefault;break;case f.NOT_NULL:e.not_null=!0;break;case f.NULLABLE:e.not_null=!1;break;case f.INCREMENT:e.increment=!0}}(e.constraint_clauses()||e.column_clauses())&&(e.constraint_clauses()?[{column:null,constraints:e.constraint_clauses().accept(this)}]:e.column_clauses().accept(this)).forEach(t=>{let n=t.column===null?null:m(a,t.column);if(t.column!==null&&!n)throw _(e.tableview_name(),`Column "${t.column}" not found on Table "${r}"`);t.constraints.forEach(e=>o.bind(this)(n,e))})}visitColumn_clauses(e){return e.add_modify_drop_column_clauses()?e.add_modify_drop_column_clauses().accept(this):[]}visitAdd_modify_drop_column_clauses(e){let t=[];return e.constraint_clauses()&&t.push({column:null,constraints:e.constraint_clauses().flatMap(e=>e.accept(this))}),e.modify_column_clauses()&&t.push(...e.modify_column_clauses().flatMap(e=>e.accept(this))),t}visitModify_column_clauses(e){return e.modify_col_properties().map(e=>e.accept(this))}visitModify_col_properties(e){let n=[],r=t.default(e.column_name().accept(this));if(e.DEFAULT()){let t=e.expression().accept(this);n.push({type:f.DEFAULT,value:{dbdefault:h(t)}})}else e.inline_constraint()&&n.push(...e.inline_constraint().map(e=>e.accept(this)));return{column:r,constraints:n}}visitConstraint_clauses(e){return e.out_of_line_constraint()?e.out_of_line_constraint().map(e=>e.accept(this)).filter(Boolean):e.out_of_line_ref_constraint()?[e.out_of_line_ref_constraint().accept(this)]:[]}visitCreate_index(e){if(!e.table_index_clause())return;let n=!!e.UNIQUE(),r=!!e.BITMAP(),i=e.index_name().accept(this),{names:a,columns:o}=e.table_index_clause().accept(this),c=t.default(a),l=a.length>1?a[a.length-2]:void 0,u=p(this.data.tables,l,c);if(!u)throw _(e.table_index_clause(),`Table ${c} not found`);u.indexes||=[],u.indexes.push(new s.Index({name:i,columns:o,unique:n,type:r?`bitmap`:void 0}))}visitTable_index_clause(e){return{names:e.tableview_name().accept(this),columns:e.index_expr().map(t=>({...t.accept(this),...e.children[e.children.indexOf(t)+1]?.symbol?.type===o.default.DESC&&{sortOrder:`desc`}}))}}visitConstraint_name(e){return v(l.getOriginalText(e))}visitIndex_name(e){return e.identifier().accept(this)}visitIndex_expr(e){if(e.expression()){let t=g(e.expression().accept(this));return{value:t.value,type:t.type}}return{value:t.default(e.column_name().accept(this)),type:c.CONSTRAINT_TYPE.COLUMN}}visitInsert_statement(e){e.single_table_insert()?e.single_table_insert().accept(this):e.multi_table_insert()&&e.multi_table_insert().accept(this)}visitSingle_table_insert(e){let t=e.insert_into_clause().accept(this),n=e.values_clause().accept(this);if(t&&n){let{tableName:e,schemaName:r,columns:i}=t,{values:a}=n,o=new s.TableRecord({schemaName:r,tableName:e,columns:i,values:a});this.data.records.push(o)}}visitMulti_table_insert(e){if(!e.multi_table_element())return;let t=e.multi_table_element().map(e=>e.accept(this)).filter(Boolean),n=new Map;t.forEach(e=>{let{tableName:t,schemaName:r,columns:i,values:a}=e,o=`${r||``}.${t}.${i.join(`,`)}`;n.has(o)?n.get(o).values.push(...a):n.set(o,{tableName:t,schemaName:r,columns:i,values:a})}),n.forEach(e=>{let t=new s.TableRecord({schemaName:e.schemaName,tableName:e.tableName,columns:e.columns,values:e.values});this.data.records.push(t)})}visitMulti_table_element(e){let t=e.insert_into_clause().accept(this),n=e.values_clause()?.accept(this);if(t&&n){let{tableName:e,schemaName:r,columns:i}=t,{values:a}=n;return{tableName:e,schemaName:r,columns:i,values:a}}return null}visitInsert_into_clause(e){let n=e.general_table_ref().accept(this),r=t.default(n),i=n.length>1?n[n.length-2]:void 0;return{tableName:r,schemaName:i,columns:e.paren_column_list()?e.paren_column_list().accept(this).map(e=>t.default(e)):p(this.data.tables,i,r)?.fields.map(e=>e.name)}}visitGeneral_table_ref(e){return e.dml_table_expression_clause().accept(this)}visitDml_table_expression_clause(e){return e.tableview_name()?e.tableview_name().accept(this):[]}visitParen_column_list(e){return e.column_list().accept(this)}visitValues_clause(e){return{values:[e.expressions_().accept(this).map(e=>({value:e.type===c.CONSTRAINT_TYPE.COLUMN?e.rawValue:e.value,type:e.type===c.CONSTRAINT_TYPE.COLUMN?c.DATA_TYPE.EXPRESSION:e.type}))]}}visitExpressions_(e){return e.expression().map(e=>e.accept(this))}visitId_expression(e){return v(l.getOriginalText(e))}visitExpression(e){let t=l.getOriginalText(e);return e.CHAR_STRING()?{type:c.DATA_TYPE.STRING,value:v(t,`'`)}:e.TRUE()?{type:c.DATA_TYPE.BOOLEAN,value:!0}:e.FALSE()?{type:c.DATA_TYPE.BOOLEAN,value:!1}:e.NULL_()?{type:c.DATA_TYPE.BOOLEAN,value:null}:e.APPROXIMATE_NUM_LIT()||e.UNSIGNED_INTEGER()?{type:c.DATA_TYPE.NUMBER,value:parseFloat(t)}:e.column_name()?{type:c.CONSTRAINT_TYPE.COLUMN,rawValue:v(t),value:v(l.getOriginalText(e.column_name()))}:{type:c.CONSTRAINT_TYPE.EXPRESSION,value:t}}visitQuoted_string(e){return v(l.getOriginalText(e),`'`)}visitRegular_id(e){return v(l.getOriginalText(e),`"`)}};function b(e,n,i,a){if(!n)return;let s=new Set,c=(0,u.normalizeQualifiedName)(a??``,i),l=new r.ParseTreeListener;l.enterEveryRule=n=>{if(!(n instanceof o.default.Tableview_nameContext))return;let r=n.accept(e),l=Array.isArray(r)?t.default(r):r,d=Array.isArray(r)&&r.length>1?r[r.length-2]:void 0,f=(0,u.normalizeQualifiedName)(d??``,l);f!==c&&(s.has(f)||p(e.data.tables,d,l)&&(s.add(f),e.data.deps.push({edges:[{upstream:{schemaName:d,tableName:l,fieldNames:[]},downstream:{schemaName:a,tableName:i,fieldNames:[]}}],note:null,custom:{}})))},r.ParseTreeWalker.DEFAULT.walk(l,n)}exports.default=y;
@@ -2,14 +2,14 @@ import e from "../../../../node_modules/lodash-es/flatten.mjs";
2
2
  import t from "../../../../node_modules/lodash-es/last.mjs";
3
3
  import { init_lodash as n } from "../../../../node_modules/lodash-es/lodash.mjs";
4
4
  import { ParseTreeListener as r, ParseTreeWalker as i } from "../../../../node_modules/antlr4/dist/antlr4.web.mjs";
5
- import a from "../../parsers/oraclesql/OracleSqlParserVisitor.mjs";
6
- import o from "../../parsers/oraclesql/OracleSqlParser.mjs";
7
- import { Endpoint as s, Field as c, Index as l, Ref as u, Table as d, TableRecord as f } from "../AST.mjs";
8
- import { CONSTRAINT_TYPE as p, DATA_TYPE as m } from "../constants.mjs";
9
- import { getOriginalText as h } from "../helpers.mjs";
10
- import { CompilerDiagnostics as g } from "../../../error.mjs";
5
+ import { CompilerDiagnostics as a } from "../../../error.mjs";
6
+ import o from "../../parsers/oraclesql/OracleSqlParserVisitor.mjs";
7
+ import s from "../../parsers/oraclesql/OracleSqlParser.mjs";
8
+ import { Endpoint as c, Field as l, Index as u, Ref as d, Table as f, TableRecord as p } from "../AST.mjs";
9
+ import { CONSTRAINT_TYPE as m, DATA_TYPE as h } from "../constants.mjs";
10
+ import { getOriginalText as g } from "../helpers.mjs";
11
11
  import { CARDINALITY_MANY as _, CARDINALITY_MAYBE as v, normalizeQualifiedName as y } from "@dbml/parse";
12
- //#region src/parse/ANTLR/ASTGeneration/oraclesql/OracleSQLASTGen.js
12
+ // src/parse/ANTLR/ASTGeneration/oraclesql/OracleSQLASTGen.js
13
13
  n();
14
14
  var b = {
15
15
  FIELD: "table_field",
@@ -33,24 +33,24 @@ var b = {
33
33
  let r = t ?? null;
34
34
  return e.find((e) => (e.schemaName ?? null) === r && e.name === n);
35
35
  }, C = (e, t) => e.fields.find((e) => e.name === t), w = (e) => ({
36
- value: e.type === p.COLUMN ? e.rawValue : e.value,
37
- type: e.type === p.COLUMN ? m.EXPRESSION : e.type
36
+ value: e.type === m.COLUMN ? e.rawValue : e.value,
37
+ type: e.type === m.COLUMN ? h.EXPRESSION : e.type
38
38
  }), T = (e) => {
39
39
  let t;
40
40
  switch (e.type) {
41
- case p.COLUMN:
42
- t = p.COLUMN;
41
+ case m.COLUMN:
42
+ t = m.COLUMN;
43
43
  break;
44
- case m.STRING:
45
- t = p.STRING;
44
+ case h.STRING:
45
+ t = m.STRING;
46
46
  break;
47
- default: t = p.EXPRESSION;
47
+ default: t = m.EXPRESSION;
48
48
  }
49
49
  return {
50
50
  value: e.value.toString(),
51
51
  type: t
52
52
  };
53
- }, E = (e, t) => g.create([{
53
+ }, E = (e, t) => a.create([{
54
54
  message: t,
55
55
  location: {
56
56
  start: {
@@ -59,10 +59,10 @@ var b = {
59
59
  },
60
60
  end: {
61
61
  line: e.stop.line,
62
- column: e.stop.column + h(e).length + 1
62
+ column: e.stop.column + g(e).length + 1
63
63
  }
64
64
  }
65
- }]), D = (e, t = "\"") => e.startsWith(t) ? e.slice(1, -1).replaceAll(`${t}${t}`, t) : e, O = class extends a {
65
+ }]), D = (e, t = "\"") => e.startsWith(t) ? e.slice(1, -1).replaceAll(`${t}${t}`, t) : e, O = class extends o {
66
66
  constructor() {
67
67
  super(), this.data = {
68
68
  schemas: [],
@@ -79,7 +79,7 @@ var b = {
79
79
  visitCreate_view(e) {
80
80
  let t = e.id_expression ? e.id_expression() : null;
81
81
  if (!t) return;
82
- let n = t.getText().replace(/"/g, ""), r = e.schema_name ? e.schema_name() : null, i = r ? r.getText().replace(/"/g, "") : void 0, a = h(e);
82
+ let n = t.getText().replace(/"/g, ""), r = e.schema_name ? e.schema_name() : null, i = r ? r.getText().replace(/"/g, "") : void 0, a = g(e);
83
83
  this.data.tables.push({
84
84
  name: n,
85
85
  schemaName: i,
@@ -97,7 +97,7 @@ var b = {
97
97
  visitCreate_materialized_view(e) {
98
98
  let t = (e.getText ? e.getText() : "").match(/MATERIALIZEDVIEW(?:IFNOTEXISTS)?(?:"([^"]+)"\.)?"?([^("\s]+)"?/i);
99
99
  if (!t) return;
100
- let n = t[1] || void 0, r = t[2], i = h(e);
100
+ let n = t[1] || void 0, r = t[2], i = g(e);
101
101
  this.data.tables.push({
102
102
  name: r,
103
103
  schemaName: n,
@@ -135,7 +135,7 @@ var b = {
135
135
  [],
136
136
  []
137
137
  ]);
138
- this.data.refs.push(...e(i.map((e) => e.inline_refs.map((t) => (t.endpoints[0].tableName = n, t.endpoints[0].schemaName = r, t.endpoints[0].fieldNames = [e.field.name], t))))), this.data.refs.push(...o.map((e) => (e.endpoints[0].tableName = n, e.endpoints[0].schemaName = r, e))), this.data.tables.push(new d({
138
+ this.data.refs.push(...e(i.map((e) => e.inline_refs.map((t) => (t.endpoints[0].tableName = n, t.endpoints[0].schemaName = r, t.endpoints[0].fieldNames = [e.field.name], t))))), this.data.refs.push(...o.map((e) => (e.endpoints[0].tableName = n, e.endpoints[0].schemaName = r, e))), this.data.tables.push(new f({
139
139
  name: n,
140
140
  schemaName: r,
141
141
  fields: i.map((e) => e.field),
@@ -195,7 +195,7 @@ var b = {
195
195
  case x.FK: a.inline_refs.push(...e.value.inline_refs);
196
196
  }
197
197
  });
198
- let o = new c({
198
+ let o = new l({
199
199
  name: n,
200
200
  type: r,
201
201
  ...a
@@ -245,11 +245,11 @@ var b = {
245
245
  if (e.UNIQUE()) {
246
246
  let n = e.column_name().map((e) => ({
247
247
  value: t(e.accept(this)),
248
- type: p.COLUMN
248
+ type: m.COLUMN
249
249
  }));
250
250
  return {
251
251
  type: b.UNIQUE,
252
- value: new l({
252
+ value: new u({
253
253
  columns: n,
254
254
  unique: !0,
255
255
  name: e.constraint_name()?.accept(this)
@@ -259,11 +259,11 @@ var b = {
259
259
  if (e.PRIMARY()) {
260
260
  let n = e.column_name().map((e) => ({
261
261
  value: t(e.accept(this)),
262
- type: p.COLUMN
262
+ type: m.COLUMN
263
263
  }));
264
264
  return {
265
265
  type: b.PK,
266
- value: new l({
266
+ value: new u({
267
267
  columns: n,
268
268
  pk: !0,
269
269
  name: e.constraint_name()?.accept(this)
@@ -275,7 +275,7 @@ var b = {
275
275
  return t.value.name = e.constraint_name()?.accept(this), t;
276
276
  }
277
277
  if (e.condition()) {
278
- let t = h(e.condition());
278
+ let t = g(e.condition());
279
279
  return {
280
280
  type: b.CHECK,
281
281
  value: { checks: [{
@@ -303,12 +303,12 @@ var b = {
303
303
  visitReferences_clause(e) {
304
304
  if (!e.paren_column_list()) throw E(e.tableview_name(), "Importing a foreign key with implicit referenced columns is not supported");
305
305
  let n = e.tableview_name().accept(this), r = t(n), i = n.length > 1 ? n[n.length - 2] : void 0, a = e.paren_column_list().accept(this).map((e) => t(e));
306
- return new u({ endpoints: [new s({
306
+ return new d({ endpoints: [new c({
307
307
  tableName: null,
308
308
  schemaName: null,
309
309
  fieldNames: [],
310
310
  relation: _
311
- }), new s({
311
+ }), new c({
312
312
  tableName: r,
313
313
  schemaName: i,
314
314
  fieldNames: a,
@@ -319,7 +319,7 @@ var b = {
319
319
  return e.CASCADE() ? "cascade" : e.SET() && e.NULL_() ? "set null" : null;
320
320
  }
321
321
  visitCheck_constraint(e) {
322
- let t = h(e.condition());
322
+ let t = g(e.condition());
323
323
  return {
324
324
  type: e.isColumn ? x.CHECK : b.CHECK,
325
325
  value: { checks: [{ expression: t }] }
@@ -342,7 +342,7 @@ var b = {
342
342
  return [e.identifier().accept(this)].concat(e.id_expression().map((e) => e.accept(this)));
343
343
  }
344
344
  visitIdentifier(e) {
345
- return D(h(e));
345
+ return D(g(e));
346
346
  }
347
347
  visitType_name(e) {
348
348
  let n = e.id_expression().map((e) => e.accept(this));
@@ -352,7 +352,7 @@ var b = {
352
352
  };
353
353
  }
354
354
  visitDatatype(e) {
355
- return { type_name: D(h(e)) };
355
+ return { type_name: D(g(e)) };
356
356
  }
357
357
  visitComment_on_table(e) {
358
358
  let n = e.tableview_name().accept(this), r = t(n), i = n.length > 1 ? n[n.length - 2] : void 0, a = S(this.data.tables, i, r);
@@ -449,9 +449,9 @@ var b = {
449
449
  }
450
450
  visitCreate_index(e) {
451
451
  if (!e.table_index_clause()) return;
452
- let n = !!e.UNIQUE(), r = !!e.BITMAP(), i = e.index_name().accept(this), { names: a, columns: o } = e.table_index_clause().accept(this), s = t(a), c = a.length > 1 ? a[a.length - 2] : void 0, u = S(this.data.tables, c, s);
453
- if (!u) throw E(e.table_index_clause(), `Table ${s} not found`);
454
- u.indexes ||= [], u.indexes.push(new l({
452
+ let n = !!e.UNIQUE(), r = !!e.BITMAP(), i = e.index_name().accept(this), { names: a, columns: o } = e.table_index_clause().accept(this), s = t(a), c = a.length > 1 ? a[a.length - 2] : void 0, l = S(this.data.tables, c, s);
453
+ if (!l) throw E(e.table_index_clause(), `Table ${s} not found`);
454
+ l.indexes ||= [], l.indexes.push(new u({
455
455
  name: i,
456
456
  columns: o,
457
457
  unique: n,
@@ -463,12 +463,12 @@ var b = {
463
463
  names: e.tableview_name().accept(this),
464
464
  columns: e.index_expr().map((t) => ({
465
465
  ...t.accept(this),
466
- ...e.children[e.children.indexOf(t) + 1]?.symbol?.type === o.DESC && { sortOrder: "desc" }
466
+ ...e.children[e.children.indexOf(t) + 1]?.symbol?.type === s.DESC && { sortOrder: "desc" }
467
467
  }))
468
468
  };
469
469
  }
470
470
  visitConstraint_name(e) {
471
- return D(h(e));
471
+ return D(g(e));
472
472
  }
473
473
  visitIndex_name(e) {
474
474
  return e.identifier().accept(this);
@@ -483,7 +483,7 @@ var b = {
483
483
  }
484
484
  return {
485
485
  value: t(e.column_name().accept(this)),
486
- type: p.COLUMN
486
+ type: m.COLUMN
487
487
  };
488
488
  }
489
489
  visitInsert_statement(e) {
@@ -492,7 +492,7 @@ var b = {
492
492
  visitSingle_table_insert(e) {
493
493
  let t = e.insert_into_clause().accept(this), n = e.values_clause().accept(this);
494
494
  if (t && n) {
495
- let { tableName: e, schemaName: r, columns: i } = t, { values: a } = n, o = new f({
495
+ let { tableName: e, schemaName: r, columns: i } = t, { values: a } = n, o = new p({
496
496
  schemaName: r,
497
497
  tableName: e,
498
498
  columns: i,
@@ -513,7 +513,7 @@ var b = {
513
513
  values: a
514
514
  });
515
515
  }), n.forEach((e) => {
516
- let t = new f({
516
+ let t = new p({
517
517
  schemaName: e.schemaName,
518
518
  tableName: e.tableName,
519
519
  columns: e.columns,
@@ -554,54 +554,54 @@ var b = {
554
554
  }
555
555
  visitValues_clause(e) {
556
556
  return { values: [e.expressions_().accept(this).map((e) => ({
557
- value: e.type === p.COLUMN ? e.rawValue : e.value,
558
- type: e.type === p.COLUMN ? m.EXPRESSION : e.type
557
+ value: e.type === m.COLUMN ? e.rawValue : e.value,
558
+ type: e.type === m.COLUMN ? h.EXPRESSION : e.type
559
559
  }))] };
560
560
  }
561
561
  visitExpressions_(e) {
562
562
  return e.expression().map((e) => e.accept(this));
563
563
  }
564
564
  visitId_expression(e) {
565
- return D(h(e));
565
+ return D(g(e));
566
566
  }
567
567
  visitExpression(e) {
568
- let t = h(e);
568
+ let t = g(e);
569
569
  return e.CHAR_STRING() ? {
570
- type: m.STRING,
570
+ type: h.STRING,
571
571
  value: D(t, "'")
572
572
  } : e.TRUE() ? {
573
- type: m.BOOLEAN,
573
+ type: h.BOOLEAN,
574
574
  value: !0
575
575
  } : e.FALSE() ? {
576
- type: m.BOOLEAN,
576
+ type: h.BOOLEAN,
577
577
  value: !1
578
578
  } : e.NULL_() ? {
579
- type: m.BOOLEAN,
579
+ type: h.BOOLEAN,
580
580
  value: null
581
581
  } : e.APPROXIMATE_NUM_LIT() || e.UNSIGNED_INTEGER() ? {
582
- type: m.NUMBER,
582
+ type: h.NUMBER,
583
583
  value: parseFloat(t)
584
584
  } : e.column_name() ? {
585
- type: p.COLUMN,
585
+ type: m.COLUMN,
586
586
  rawValue: D(t),
587
- value: D(h(e.column_name()))
587
+ value: D(g(e.column_name()))
588
588
  } : {
589
- type: p.EXPRESSION,
589
+ type: m.EXPRESSION,
590
590
  value: t
591
591
  };
592
592
  }
593
593
  visitQuoted_string(e) {
594
- return D(h(e), "'");
594
+ return D(g(e), "'");
595
595
  }
596
596
  visitRegular_id(e) {
597
- return D(h(e), "\"");
597
+ return D(g(e), "\"");
598
598
  }
599
599
  };
600
- function k(e, n, a, s) {
600
+ function k(e, n, a, o) {
601
601
  if (!n) return;
602
- let c = /* @__PURE__ */ new Set(), l = y(s ?? "", a), u = new r();
602
+ let c = /* @__PURE__ */ new Set(), l = y(o ?? "", a), u = new r();
603
603
  u.enterEveryRule = (n) => {
604
- if (!(n instanceof o.Tableview_nameContext)) return;
604
+ if (!(n instanceof s.Tableview_nameContext)) return;
605
605
  let r = n.accept(e), i = Array.isArray(r) ? t(r) : r, u = Array.isArray(r) && r.length > 1 ? r[r.length - 2] : void 0, d = y(u ?? "", i);
606
606
  d !== l && (c.has(d) || S(e.data.tables, u, i) && (c.add(d), e.data.deps.push({
607
607
  edges: [{
@@ -611,7 +611,7 @@ function k(e, n, a, s) {
611
611
  fieldNames: []
612
612
  },
613
613
  downstream: {
614
- schemaName: s,
614
+ schemaName: o,
615
615
  tableName: a,
616
616
  fieldNames: []
617
617
  }
@@ -621,5 +621,4 @@ function k(e, n, a, s) {
621
621
  })));
622
622
  }, i.DEFAULT.walk(u, n);
623
623
  }
624
- //#endregion
625
624
  export { O as default };