sqlingo 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/CHANGELOG.md +23 -4
  2. package/README.md +7 -7
  3. package/README.npm.md +7 -7
  4. package/README.repo.md +105 -48
  5. package/dist/{chunk-DGV6NM76.js → chunk-2CLRLOWZ.js} +2 -2
  6. package/dist/chunk-2NBCADTA.cjs +2 -0
  7. package/dist/chunk-2NBCADTA.cjs.map +1 -0
  8. package/dist/{chunk-DW3ISHFW.js → chunk-2VXNMR6U.js} +2 -2
  9. package/dist/chunk-3AXRMSOM.js +2 -0
  10. package/dist/chunk-3AXRMSOM.js.map +1 -0
  11. package/dist/chunk-4GGZCF4M.js +2 -0
  12. package/dist/{chunk-NMAMNFRD.js.map → chunk-4GGZCF4M.js.map} +1 -1
  13. package/dist/{chunk-NBRX75ID.js → chunk-4SI6KRDO.js} +2 -2
  14. package/dist/chunk-5NNVJ4H7.cjs +2 -0
  15. package/dist/chunk-5NNVJ4H7.cjs.map +1 -0
  16. package/dist/chunk-6NDABX2K.cjs +2 -0
  17. package/dist/chunk-6NDABX2K.cjs.map +1 -0
  18. package/dist/chunk-7T6422QK.cjs +2 -0
  19. package/dist/chunk-7T6422QK.cjs.map +1 -0
  20. package/dist/chunk-APZJ7NQO.js +19 -0
  21. package/dist/chunk-APZJ7NQO.js.map +1 -0
  22. package/dist/{chunk-PGKNO72J.js → chunk-CFG73UXL.js} +2 -2
  23. package/dist/chunk-E3DG5GKS.cjs +2 -0
  24. package/dist/chunk-E3DG5GKS.cjs.map +1 -0
  25. package/dist/{chunk-WRG5B5DZ.js → chunk-F4QS4D2O.js} +2 -2
  26. package/dist/{chunk-SPWMHIMC.js → chunk-FSCGXYSR.js} +2 -2
  27. package/dist/{chunk-NKPY5IG3.js → chunk-GIZAGTDZ.js} +2 -2
  28. package/dist/{chunk-GFWBSTYA.js → chunk-GOFHIRVB.js} +2 -2
  29. package/dist/{chunk-457OPBHX.js → chunk-H37TXOYX.js} +2 -2
  30. package/dist/chunk-I3RBOQDO.cjs +2 -0
  31. package/dist/chunk-I3RBOQDO.cjs.map +1 -0
  32. package/dist/chunk-KKJ556AW.cjs +4 -0
  33. package/dist/chunk-KKJ556AW.cjs.map +1 -0
  34. package/dist/chunk-KOL64RQH.cjs +2 -0
  35. package/dist/chunk-KOL64RQH.cjs.map +1 -0
  36. package/dist/chunk-NDSBIRFZ.cjs +2 -0
  37. package/dist/chunk-NDSBIRFZ.cjs.map +1 -0
  38. package/dist/{chunk-FYYDDWAY.cjs → chunk-QFERDTPZ.cjs} +2 -2
  39. package/dist/chunk-QFERDTPZ.cjs.map +1 -0
  40. package/dist/chunk-QIQQ2QJR.cjs +2 -0
  41. package/dist/chunk-QIQQ2QJR.cjs.map +1 -0
  42. package/dist/chunk-QS7IOBU6.cjs +2 -0
  43. package/dist/chunk-QS7IOBU6.cjs.map +1 -0
  44. package/dist/{chunk-AKDNSOG6.js → chunk-SLJIOLJ3.js} +2 -2
  45. package/dist/chunk-SWPTLG2E.cjs +2 -0
  46. package/dist/chunk-SWPTLG2E.cjs.map +1 -0
  47. package/dist/{chunk-QWCG55SR.js → chunk-UQR7VDWJ.js} +2 -2
  48. package/dist/chunk-USQPYV24.cjs +3 -0
  49. package/dist/chunk-USQPYV24.cjs.map +1 -0
  50. package/dist/{chunk-5JXGMU6K.js → chunk-UXKF3QRK.js} +2 -2
  51. package/dist/chunk-VGJBK2L5.cjs +2 -0
  52. package/dist/chunk-VGJBK2L5.cjs.map +1 -0
  53. package/dist/chunk-VWKXWLP5.cjs +19 -0
  54. package/dist/chunk-VWKXWLP5.cjs.map +1 -0
  55. package/dist/{chunk-3OVM5ZRR.js → chunk-WDNJ5X7T.js} +2 -2
  56. package/dist/{chunk-R2XOYY2B.js → chunk-WKFDSPAW.js} +2 -2
  57. package/dist/chunk-WT5MI6B6.cjs +2 -0
  58. package/dist/chunk-WT5MI6B6.cjs.map +1 -0
  59. package/dist/chunk-X6GBG5XG.cjs +2 -0
  60. package/dist/chunk-X6GBG5XG.cjs.map +1 -0
  61. package/dist/chunk-XQG53TQM.cjs +2 -0
  62. package/dist/chunk-XQG53TQM.cjs.map +1 -0
  63. package/dist/{chunk-KNRQDMQ7.js → chunk-YGEJLTA7.js} +2 -2
  64. package/dist/{chunk-KZSNUA4U.js → chunk-ZS3L5BUS.js} +2 -2
  65. package/dist/dialects/athena.cjs +1 -1
  66. package/dist/dialects/athena.cjs.map +1 -1
  67. package/dist/dialects/athena.d.cts +1 -1
  68. package/dist/dialects/athena.d.ts +1 -1
  69. package/dist/dialects/athena.js +1 -1
  70. package/dist/dialects/bigquery.cjs +2 -2
  71. package/dist/dialects/bigquery.cjs.map +1 -1
  72. package/dist/dialects/bigquery.d.cts +4 -2
  73. package/dist/dialects/bigquery.d.ts +4 -2
  74. package/dist/dialects/bigquery.js +2 -2
  75. package/dist/dialects/bigquery.js.map +1 -1
  76. package/dist/dialects/clickhouse.cjs +1 -1
  77. package/dist/dialects/clickhouse.cjs.map +1 -1
  78. package/dist/dialects/clickhouse.d.cts +3 -1
  79. package/dist/dialects/clickhouse.d.ts +3 -1
  80. package/dist/dialects/clickhouse.js +1 -1
  81. package/dist/dialects/clickhouse.js.map +1 -1
  82. package/dist/dialects/databricks.cjs +1 -1
  83. package/dist/dialects/databricks.cjs.map +1 -1
  84. package/dist/dialects/databricks.d.cts +2 -1
  85. package/dist/dialects/databricks.d.ts +2 -1
  86. package/dist/dialects/databricks.js +1 -1
  87. package/dist/dialects/databricks.js.map +1 -1
  88. package/dist/dialects/doris.cjs +1 -1
  89. package/dist/dialects/doris.cjs.map +1 -1
  90. package/dist/dialects/doris.d.cts +2 -1
  91. package/dist/dialects/doris.d.ts +2 -1
  92. package/dist/dialects/doris.js +1 -1
  93. package/dist/dialects/dremio.cjs +1 -1
  94. package/dist/dialects/dremio.cjs.map +1 -1
  95. package/dist/dialects/dremio.d.cts +2 -1
  96. package/dist/dialects/dremio.d.ts +2 -1
  97. package/dist/dialects/dremio.js +1 -1
  98. package/dist/dialects/drill.cjs +1 -1
  99. package/dist/dialects/drill.cjs.map +1 -1
  100. package/dist/dialects/drill.d.cts +2 -1
  101. package/dist/dialects/drill.d.ts +2 -1
  102. package/dist/dialects/drill.js +1 -1
  103. package/dist/dialects/druid.cjs +1 -1
  104. package/dist/dialects/druid.cjs.map +1 -1
  105. package/dist/dialects/druid.d.cts +1 -1
  106. package/dist/dialects/druid.d.ts +1 -1
  107. package/dist/dialects/druid.js +1 -1
  108. package/dist/dialects/duckdb.cjs +22 -13
  109. package/dist/dialects/duckdb.cjs.map +1 -1
  110. package/dist/dialects/duckdb.d.cts +5 -1
  111. package/dist/dialects/duckdb.d.ts +5 -1
  112. package/dist/dialects/duckdb.js +22 -13
  113. package/dist/dialects/duckdb.js.map +1 -1
  114. package/dist/dialects/dune.cjs +1 -1
  115. package/dist/dialects/dune.cjs.map +1 -1
  116. package/dist/dialects/dune.d.cts +1 -1
  117. package/dist/dialects/dune.d.ts +1 -1
  118. package/dist/dialects/dune.js +1 -1
  119. package/dist/dialects/exasol.cjs +1 -1
  120. package/dist/dialects/exasol.cjs.map +1 -1
  121. package/dist/dialects/exasol.d.cts +2 -1
  122. package/dist/dialects/exasol.d.ts +2 -1
  123. package/dist/dialects/exasol.js +1 -1
  124. package/dist/dialects/fabric.cjs +1 -1
  125. package/dist/dialects/fabric.cjs.map +1 -1
  126. package/dist/dialects/fabric.d.cts +2 -1
  127. package/dist/dialects/fabric.d.ts +2 -1
  128. package/dist/dialects/fabric.js +1 -1
  129. package/dist/dialects/hive.cjs +1 -1
  130. package/dist/dialects/hive.cjs.map +1 -1
  131. package/dist/dialects/hive.d.cts +2 -1
  132. package/dist/dialects/hive.d.ts +2 -1
  133. package/dist/dialects/hive.js +1 -1
  134. package/dist/dialects/materialize.cjs +1 -1
  135. package/dist/dialects/materialize.cjs.map +1 -1
  136. package/dist/dialects/materialize.d.cts +4 -1
  137. package/dist/dialects/materialize.d.ts +4 -1
  138. package/dist/dialects/materialize.js +1 -1
  139. package/dist/dialects/materialize.js.map +1 -1
  140. package/dist/dialects/mysql.cjs +1 -1
  141. package/dist/dialects/mysql.cjs.map +1 -1
  142. package/dist/dialects/mysql.d.cts +1 -1
  143. package/dist/dialects/mysql.d.ts +1 -1
  144. package/dist/dialects/mysql.js +1 -1
  145. package/dist/dialects/oracle.cjs +1 -1
  146. package/dist/dialects/oracle.cjs.map +1 -1
  147. package/dist/dialects/oracle.d.cts +2 -1
  148. package/dist/dialects/oracle.d.ts +2 -1
  149. package/dist/dialects/oracle.js +1 -1
  150. package/dist/dialects/postgres.cjs +1 -1
  151. package/dist/dialects/postgres.cjs.map +1 -1
  152. package/dist/dialects/postgres.d.cts +2 -1
  153. package/dist/dialects/postgres.d.ts +2 -1
  154. package/dist/dialects/postgres.js +1 -1
  155. package/dist/dialects/presto.cjs +1 -1
  156. package/dist/dialects/presto.cjs.map +1 -1
  157. package/dist/dialects/presto.d.cts +1 -1
  158. package/dist/dialects/presto.d.ts +1 -1
  159. package/dist/dialects/presto.js +1 -1
  160. package/dist/dialects/prql.cjs +1 -1
  161. package/dist/dialects/prql.cjs.map +1 -1
  162. package/dist/dialects/prql.d.cts +2 -1
  163. package/dist/dialects/prql.d.ts +2 -1
  164. package/dist/dialects/prql.js +1 -1
  165. package/dist/dialects/prql.js.map +1 -1
  166. package/dist/dialects/redshift.cjs +1 -1
  167. package/dist/dialects/redshift.cjs.map +1 -1
  168. package/dist/dialects/redshift.d.cts +1 -1
  169. package/dist/dialects/redshift.d.ts +1 -1
  170. package/dist/dialects/redshift.js +1 -1
  171. package/dist/dialects/risingwave.cjs +1 -1
  172. package/dist/dialects/risingwave.cjs.map +1 -1
  173. package/dist/dialects/risingwave.d.cts +2 -1
  174. package/dist/dialects/risingwave.d.ts +2 -1
  175. package/dist/dialects/risingwave.js +1 -1
  176. package/dist/dialects/singlestore.cjs +1 -1
  177. package/dist/dialects/singlestore.cjs.map +1 -1
  178. package/dist/dialects/singlestore.d.cts +1 -1
  179. package/dist/dialects/singlestore.d.ts +1 -1
  180. package/dist/dialects/singlestore.js +1 -1
  181. package/dist/dialects/snowflake.cjs +2 -2
  182. package/dist/dialects/snowflake.cjs.map +1 -1
  183. package/dist/dialects/snowflake.d.cts +5 -2
  184. package/dist/dialects/snowflake.d.ts +5 -2
  185. package/dist/dialects/snowflake.js +2 -2
  186. package/dist/dialects/snowflake.js.map +1 -1
  187. package/dist/dialects/solr.cjs +1 -1
  188. package/dist/dialects/solr.cjs.map +1 -1
  189. package/dist/dialects/solr.d.cts +2 -1
  190. package/dist/dialects/solr.d.ts +2 -1
  191. package/dist/dialects/solr.js +1 -1
  192. package/dist/dialects/spark.cjs +1 -1
  193. package/dist/dialects/spark.cjs.map +1 -1
  194. package/dist/dialects/spark.d.cts +2 -1
  195. package/dist/dialects/spark.d.ts +2 -1
  196. package/dist/dialects/spark.js +1 -1
  197. package/dist/dialects/spark2.cjs +1 -1
  198. package/dist/dialects/spark2.cjs.map +1 -1
  199. package/dist/dialects/spark2.d.cts +2 -1
  200. package/dist/dialects/spark2.d.ts +2 -1
  201. package/dist/dialects/spark2.js +1 -1
  202. package/dist/dialects/sqlite.cjs +1 -1
  203. package/dist/dialects/sqlite.cjs.map +1 -1
  204. package/dist/dialects/sqlite.d.cts +2 -1
  205. package/dist/dialects/sqlite.d.ts +2 -1
  206. package/dist/dialects/sqlite.js +1 -1
  207. package/dist/dialects/starrocks.cjs +1 -1
  208. package/dist/dialects/starrocks.cjs.map +1 -1
  209. package/dist/dialects/starrocks.d.cts +2 -1
  210. package/dist/dialects/starrocks.d.ts +2 -1
  211. package/dist/dialects/starrocks.js +1 -1
  212. package/dist/dialects/tableau.cjs +1 -1
  213. package/dist/dialects/tableau.cjs.map +1 -1
  214. package/dist/dialects/tableau.d.cts +2 -1
  215. package/dist/dialects/tableau.d.ts +2 -1
  216. package/dist/dialects/tableau.js +1 -1
  217. package/dist/dialects/teradata.cjs +1 -1
  218. package/dist/dialects/teradata.cjs.map +1 -1
  219. package/dist/dialects/teradata.d.cts +2 -1
  220. package/dist/dialects/teradata.d.ts +2 -1
  221. package/dist/dialects/teradata.js +1 -1
  222. package/dist/dialects/trino.cjs +1 -1
  223. package/dist/dialects/trino.cjs.map +1 -1
  224. package/dist/dialects/trino.d.cts +2 -1
  225. package/dist/dialects/trino.d.ts +2 -1
  226. package/dist/dialects/trino.js +1 -1
  227. package/dist/dialects/tsql.cjs +1 -1
  228. package/dist/dialects/tsql.cjs.map +1 -1
  229. package/dist/dialects/tsql.d.cts +2 -1
  230. package/dist/dialects/tsql.d.ts +2 -1
  231. package/dist/dialects/tsql.js +1 -1
  232. package/dist/index.cjs +5 -5
  233. package/dist/index.cjs.map +1 -1
  234. package/dist/index.d.cts +2 -2
  235. package/dist/index.d.ts +2 -2
  236. package/dist/index.js +4 -4
  237. package/dist/index.js.map +1 -1
  238. package/dist/{tokens-DOFGCO-T.d.ts → tokens-C2JqKsrn.d.cts} +30 -3
  239. package/dist/{tokens-DOFGCO-T.d.cts → tokens-C2JqKsrn.d.ts} +30 -3
  240. package/package.json +264 -266
  241. package/dist/chunk-47UFIVIO.cjs +0 -2
  242. package/dist/chunk-47UFIVIO.cjs.map +0 -1
  243. package/dist/chunk-5E2DDDMJ.cjs +0 -2
  244. package/dist/chunk-5E2DDDMJ.cjs.map +0 -1
  245. package/dist/chunk-6EWE2PXX.cjs +0 -2
  246. package/dist/chunk-6EWE2PXX.cjs.map +0 -1
  247. package/dist/chunk-AYV6C6YU.cjs +0 -19
  248. package/dist/chunk-AYV6C6YU.cjs.map +0 -1
  249. package/dist/chunk-C4ZR72YB.cjs +0 -3
  250. package/dist/chunk-C4ZR72YB.cjs.map +0 -1
  251. package/dist/chunk-FCFBBB5S.cjs +0 -2
  252. package/dist/chunk-FCFBBB5S.cjs.map +0 -1
  253. package/dist/chunk-FYYDDWAY.cjs.map +0 -1
  254. package/dist/chunk-HQEUEZZE.cjs +0 -2
  255. package/dist/chunk-HQEUEZZE.cjs.map +0 -1
  256. package/dist/chunk-I36ZOBUW.cjs +0 -2
  257. package/dist/chunk-I36ZOBUW.cjs.map +0 -1
  258. package/dist/chunk-KYKSQHLH.cjs +0 -2
  259. package/dist/chunk-KYKSQHLH.cjs.map +0 -1
  260. package/dist/chunk-LDIWFKFA.cjs +0 -2
  261. package/dist/chunk-LDIWFKFA.cjs.map +0 -1
  262. package/dist/chunk-NMAMNFRD.js +0 -2
  263. package/dist/chunk-O4K6VGOH.cjs +0 -2
  264. package/dist/chunk-O4K6VGOH.cjs.map +0 -1
  265. package/dist/chunk-OGPS63WZ.cjs +0 -2
  266. package/dist/chunk-OGPS63WZ.cjs.map +0 -1
  267. package/dist/chunk-OOA5D6BW.cjs +0 -2
  268. package/dist/chunk-OOA5D6BW.cjs.map +0 -1
  269. package/dist/chunk-PC37XGLS.js +0 -2
  270. package/dist/chunk-PC37XGLS.js.map +0 -1
  271. package/dist/chunk-PVJGPE3V.cjs +0 -2
  272. package/dist/chunk-PVJGPE3V.cjs.map +0 -1
  273. package/dist/chunk-QEXGYHWM.cjs +0 -2
  274. package/dist/chunk-QEXGYHWM.cjs.map +0 -1
  275. package/dist/chunk-RGKTYIN3.js +0 -19
  276. package/dist/chunk-RGKTYIN3.js.map +0 -1
  277. package/dist/chunk-UMJ6E4XD.cjs +0 -4
  278. package/dist/chunk-UMJ6E4XD.cjs.map +0 -1
  279. package/dist/chunk-USYIWEPI.cjs +0 -2
  280. package/dist/chunk-USYIWEPI.cjs.map +0 -1
  281. package/dist/chunk-Y2ZD6UO6.cjs +0 -2
  282. package/dist/chunk-Y2ZD6UO6.cjs.map +0 -1
  283. /package/dist/{chunk-DGV6NM76.js.map → chunk-2CLRLOWZ.js.map} +0 -0
  284. /package/dist/{chunk-DW3ISHFW.js.map → chunk-2VXNMR6U.js.map} +0 -0
  285. /package/dist/{chunk-NBRX75ID.js.map → chunk-4SI6KRDO.js.map} +0 -0
  286. /package/dist/{chunk-PGKNO72J.js.map → chunk-CFG73UXL.js.map} +0 -0
  287. /package/dist/{chunk-WRG5B5DZ.js.map → chunk-F4QS4D2O.js.map} +0 -0
  288. /package/dist/{chunk-SPWMHIMC.js.map → chunk-FSCGXYSR.js.map} +0 -0
  289. /package/dist/{chunk-NKPY5IG3.js.map → chunk-GIZAGTDZ.js.map} +0 -0
  290. /package/dist/{chunk-GFWBSTYA.js.map → chunk-GOFHIRVB.js.map} +0 -0
  291. /package/dist/{chunk-457OPBHX.js.map → chunk-H37TXOYX.js.map} +0 -0
  292. /package/dist/{chunk-AKDNSOG6.js.map → chunk-SLJIOLJ3.js.map} +0 -0
  293. /package/dist/{chunk-QWCG55SR.js.map → chunk-UQR7VDWJ.js.map} +0 -0
  294. /package/dist/{chunk-5JXGMU6K.js.map → chunk-UXKF3QRK.js.map} +0 -0
  295. /package/dist/{chunk-3OVM5ZRR.js.map → chunk-WDNJ5X7T.js.map} +0 -0
  296. /package/dist/{chunk-R2XOYY2B.js.map → chunk-WKFDSPAW.js.map} +0 -0
  297. /package/dist/{chunk-KNRQDMQ7.js.map → chunk-YGEJLTA7.js.map} +0 -0
  298. /package/dist/{chunk-KZSNUA4U.js.map → chunk-ZS3L5BUS.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # sqlingo
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1fb6cd0: - Sync to sqlglot version 30.0.3
8
+ - fix(duckdb): FROM pipe syntax in subquery
9
+ - fix: escape comment markers in sanitize_comment for all dialects
10
+ - fix(expressions): restore Expression.alias for non-Identifier alias nodes
11
+ - feat(duckdb): add transpilation support for ARRAY_TO_STRING function
12
+ - fix(parser): ARRAY_INTERSECT builder, UNIQUE constraint, lineage error message
13
+ - perf: optimize parser for nested function calls (parse_atom fast path, TYPED_LAMBDA_ARGS)
14
+ - perf: inline token parsing in parseDisjunction/Conjunction/Equality/Comparison/Exponent
15
+ - feat(snowflake): support transpilation of STRTOK to duckdb
16
+ - feat(duckdb): add transpilation support for neg position args for CHARINDEX
17
+ - fix(clickhouse): lowercase dateTrunc units for versions before 23.12
18
+ - perf: optimize parser fast path for simple table references
19
+ - fix: match Python ifSql (remove parent check), hoist STRTOK_TEMPLATE, remove dead parseTokens
20
+ - fix: add missing tests (lineage error, ARRAY_INTERSECT read, ifSql regression), fix DTS build
21
+
3
22
  ## 0.8.0
4
23
 
5
24
  ### Minor Changes
@@ -144,16 +163,16 @@
144
163
 
145
164
  ### Patch Changes
146
165
 
147
- - 98abe58: Guard against prototype-polluting assignment in `Expression.setArgKey` [#2](https://github.com/huydo862003/sqlingo.js/pull/2)
166
+ - 98abe58: Guard against prototype-polluting assignment in `Expression.setArgKey` [#2](https://github.com/huydo862003/sqlingo/pull/2)
148
167
 
149
168
  ## 0.2.1 (retracted)
150
169
 
151
170
  ### Patch Changes
152
171
 
153
172
  - 7c03a7e:
154
- - Update `dompurify` from 3.2.7 to 3.4.2 to resolve vulnerability issues [#1](https://github.com/huydo862003/sqlingo.js/pull/1)
155
- - Update `picomatch` from 2.3.1 to 4.0.4 to resolve vulnerability issues [#1](https://github.com/huydo862003/sqlingo.js/pull/1)
156
- - Update `postcss` from 8.5.8 to 8.5.14 to resolve vulnerability issues [#1](https://github.com/huydo862003/sqlingo.js/pull/1)
173
+ - Update `dompurify` from 3.2.7 to 3.4.2 to resolve vulnerability issues [#1](https://github.com/huydo862003/sqlingo/pull/1)
174
+ - Update `picomatch` from 2.3.1 to 4.0.4 to resolve vulnerability issues [#1](https://github.com/huydo862003/sqlingo/pull/1)
175
+ - Update `postcss` from 8.5.8 to 8.5.14 to resolve vulnerability issues [#1](https://github.com/huydo862003/sqlingo/pull/1)
157
176
 
158
177
  ## 0.2.0 (retracted)
159
178
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # sqlingo
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/sqlingo)](https://www.npmjs.com/package/sqlingo)
4
- [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/huydo862003/sqlingo.js/blob/master/LICENSE)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/huydo862003/sqlingo/blob/master/LICENSE)
5
5
  ![SQLGlot](https://img.shields.io/badge/SQLGlot-v30.0.0-blue)
6
6
  <a href="https://github.com/huydo862003/Fck-AI-Slop#plan"><img src="https://img.shields.io/badge/human%20slop-90EE90"></a>
7
7
 
@@ -15,9 +15,9 @@ WARNING: This package is still in alpha.
15
15
 
16
16
  NOTICE: AI is not the decision maker, designer or maintainer for this project. It is indeed sometimes used to port straightforward code with less effort. However, the point is to always keep its usage under control & understand what's going on, so I can maintain this project reliably as sqlglot updates.
17
17
 
18
- - [GitHub](https://github.com/huydo862003/sqlingo.js)
19
- - [Issues](https://github.com/huydo862003/sqlingo.js/issues)
20
- - [Changelog](https://github.com/huydo862003/sqlingo.js/blob/master/CHANGELOG.md)
18
+ - [GitHub](https://github.com/huydo862003/sqlingo)
19
+ - [Issues](https://github.com/huydo862003/sqlingo/issues)
20
+ - [Changelog](https://github.com/huydo862003/sqlingo/blob/master/packages/sqlingo/CHANGELOG.md)
21
21
 
22
22
  ## Features
23
23
 
@@ -180,10 +180,10 @@ Athena, BigQuery, ClickHouse, Databricks, Doris, Dremio, Drill, Druid, DuckDB, D
180
180
 
181
181
  ## SQLGlot Compatibility
182
182
 
183
- This package tracks [SQLGlot](https://github.com/tobymao/sqlglot) v30.0.0 (commit `a3929be`). The API surface mirrors SQLGlot's Python API, adapted to TypeScript conventions. See [CONVENTION.md](https://github.com/huydo862003/sqlingo.js/blob/master/CONVENTION.md) for details.
183
+ This package tracks [SQLGlot](https://github.com/tobymao/sqlglot) v30.0.0 (commit `a3929be`). The API surface mirrors SQLGlot's Python API, adapted to TypeScript conventions. See [CONVENTION.md](https://github.com/huydo862003/sqlingo/blob/master/packages/sqlingo/CONVENTION.md) for details.
184
184
 
185
185
  ## License
186
186
 
187
- MIT. See [LICENSE](https://github.com/huydo862003/sqlingo.js/blob/master/LICENSE).
187
+ MIT. See [LICENSE](https://github.com/huydo862003/sqlingo/blob/master/LICENSE).
188
188
 
189
- Based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao (MIT). See [COPYRIGHT_NOTICE](https://github.com/huydo862003/sqlingo.js/blob/master/COPYRIGHT_NOTICE).
189
+ Based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao (MIT). See [COPYRIGHT_NOTICE](https://github.com/huydo862003/sqlingo/blob/master/COPYRIGHT_NOTICE).
package/README.npm.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # sqlingo
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/sqlingo)](https://www.npmjs.com/package/sqlingo)
4
- [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/huydo862003/sqlingo.js/blob/master/LICENSE)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/huydo862003/sqlingo/blob/master/LICENSE)
5
5
  ![SQLGlot](https://img.shields.io/badge/SQLGlot-v30.0.0-blue)
6
6
  <a href="https://github.com/huydo862003/Fck-AI-Slop#plan"><img src="https://img.shields.io/badge/human%20slop-90EE90"></a>
7
7
 
@@ -15,9 +15,9 @@ WARNING: This package is still in alpha.
15
15
 
16
16
  NOTICE: AI is not the decision maker, designer or maintainer for this project. It is indeed sometimes used to port straightforward code with less effort. However, the point is to always keep its usage under control & understand what's going on, so I can maintain this project reliably as sqlglot updates.
17
17
 
18
- - [GitHub](https://github.com/huydo862003/sqlingo.js)
19
- - [Issues](https://github.com/huydo862003/sqlingo.js/issues)
20
- - [Changelog](https://github.com/huydo862003/sqlingo.js/blob/master/CHANGELOG.md)
18
+ - [GitHub](https://github.com/huydo862003/sqlingo)
19
+ - [Issues](https://github.com/huydo862003/sqlingo/issues)
20
+ - [Changelog](https://github.com/huydo862003/sqlingo/blob/master/packages/sqlingo/CHANGELOG.md)
21
21
 
22
22
  ## Features
23
23
 
@@ -180,10 +180,10 @@ Athena, BigQuery, ClickHouse, Databricks, Doris, Dremio, Drill, Druid, DuckDB, D
180
180
 
181
181
  ## SQLGlot Compatibility
182
182
 
183
- This package tracks [SQLGlot](https://github.com/tobymao/sqlglot) v30.0.0 (commit `a3929be`). The API surface mirrors SQLGlot's Python API, adapted to TypeScript conventions. See [CONVENTION.md](https://github.com/huydo862003/sqlingo.js/blob/master/CONVENTION.md) for details.
183
+ This package tracks [SQLGlot](https://github.com/tobymao/sqlglot) v30.0.0 (commit `a3929be`). The API surface mirrors SQLGlot's Python API, adapted to TypeScript conventions. See [CONVENTION.md](https://github.com/huydo862003/sqlingo/blob/master/packages/sqlingo/CONVENTION.md) for details.
184
184
 
185
185
  ## License
186
186
 
187
- MIT. See [LICENSE](https://github.com/huydo862003/sqlingo.js/blob/master/LICENSE).
187
+ MIT. See [LICENSE](https://github.com/huydo862003/sqlingo/blob/master/LICENSE).
188
188
 
189
- Based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao (MIT). See [COPYRIGHT_NOTICE](https://github.com/huydo862003/sqlingo.js/blob/master/COPYRIGHT_NOTICE).
189
+ Based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao (MIT). See [COPYRIGHT_NOTICE](https://github.com/huydo862003/sqlingo/blob/master/COPYRIGHT_NOTICE).
package/README.repo.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # sqlingo
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/sqlingo)](https://www.npmjs.com/package/sqlingo)
4
- [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/huydo862003/sqlingo/blob/master/LICENSE)
5
5
  ![SQLGlot](https://img.shields.io/badge/SQLGlot-v30.0.0-blue)
6
6
  <a href="https://github.com/huydo862003/Fck-AI-Slop#plan"><img src="https://img.shields.io/badge/human%20slop-90EE90"></a>
7
7
 
8
8
  A JavaScript/TypeScript port of [SQLGlot](https://github.com/tobymao/sqlglot) which is compatible with browser and Node runtimes.
9
9
 
10
- This package allows you to parse, transpile, optimize, and execute SQL across **32+ dialects** in JavaScript.
10
+ This package allows you to parse, transpile, optimize, and execute SQL across **32 dialects** in JavaScript.
11
11
 
12
12
  WARNING: This package is still in alpha.
13
13
  - Although the SQLGlot tests have all passed, but finding contrived failures may require me to use this package extensively myself.
@@ -15,11 +15,16 @@ WARNING: This package is still in alpha.
15
15
 
16
16
  NOTICE: AI is not the decision maker, designer or maintainer for this project. It is indeed sometimes used to port straightforward code with less effort. However, the point is to always keep its usage under control & understand what's going on, so I can maintain this project reliably as sqlglot updates.
17
17
 
18
+ - [GitHub](https://github.com/huydo862003/sqlingo)
19
+ - [Issues](https://github.com/huydo862003/sqlingo/issues)
20
+ - [Changelog](https://github.com/huydo862003/sqlingo/blob/master/packages/sqlingo/CHANGELOG.md)
21
+
18
22
  ## Features
19
23
 
20
- - ~32 SQL dialects: Postgres, MySQL, BigQuery, Snowflake, DuckDB, ClickHouse, Redshift, Athena, Spark, and many more
24
+ - 32 SQL dialects: Postgres, MySQL, BigQuery, Snowflake, DuckDB, ClickHouse, Redshift, Athena, Spark, and many more
21
25
  - Some SQLGlot feature set: parsing, transpilation, optimization, column lineage, SQL diffing, and execution
22
- - Written in Typescript
26
+ - Pure JavaScript: no need for WASM or native dependencies
27
+ - TypeScript-first: full type definitions included
23
28
 
24
29
  ## Installation
25
30
 
@@ -57,76 +62,128 @@ console.log(optimized.sql());
57
62
  // Output: SELECT t.a AS a, t.b AS b FROM t AS t WHERE t.a = 1
58
63
  ```
59
64
 
60
- See the [Usage Guide](./README.npm.md) for full API documentation and examples.
65
+ ## Core Usage
61
66
 
62
- ## Supported Dialects
67
+ ### Parsing
63
68
 
64
- Athena, BigQuery, ClickHouse, Databricks, Doris, Dremio, Drill, Druid, DuckDB, Dune, Exasol, Fabric, Hive, Materialize, MySQL, Oracle, Postgres, Presto, PRQL, Redshift, RisingWave, SingleStore, Snowflake, Solr, Spark, Spark2, SQLite, StarRocks, Tableau, Teradata, Trino, TSQL
69
+ Parse SQL strings into expression trees (AST).
70
+
71
+ ```ts
72
+ import { parse, parseOne } from "sqlingo";
65
73
 
66
- ## Goals (& Non-goals)
74
+ // Parse multiple statements
75
+ const expressions = parse("SELECT 1; SELECT 2");
67
76
 
68
- The main goal is that sqlingo should be a close mirror to SQLGlot. This way, it can quickly catch up with SQLGlot bug fixes and new releases.
77
+ // Parse a single statement
78
+ const expr = parseOne("SELECT a, b FROM t WHERE a > 1");
79
+ ```
80
+
81
+ ### Transpiling
69
82
 
70
- Another goal is to stay true to Typescript convention (check [CONVENTION.md](./CONVENTION.md)).
83
+ Convert SQL between different dialects.
71
84
 
72
- Currently, these are non-goals:
85
+ ```ts
86
+ import { transpile } from "sqlingo";
87
+ import { DuckDB } from "sqlingo/duckdb";
88
+ import { Hive } from "sqlingo/hive";
89
+
90
+ const [result] = transpile("SELECT EPOCH_MS(1618088028295)", {
91
+ read: DuckDB,
92
+ write: Hive,
93
+ });
94
+ // Output: "SELECT FROM_UNIXTIME(1618088028295 / POW(10, 3))"
95
+ ```
73
96
 
74
- - Optimized performance.
75
- - Optimized bundle size.
76
- - Compatibility with SQLGlot (but it should be trivial to make the two compatible)
97
+ ### Tokenizing
77
98
 
78
- ## Backstory
99
+ Extract tokens from a SQL string for lower-level analysis.
79
100
 
80
- I'm currenly maintaining [@dbml/core](https://github.com/holistics/dbml), a library that supports converting between DBML and SQL. Under the hood it uses ANTLR for parsing, and honestly it's been a mess:
101
+ ```ts
102
+ import { tokenize } from "sqlingo";
103
+ import { Postgres } from "sqlingo/postgres";
81
104
 
82
- - `@dbml/core` is **33MB**, which is quite insane to be honest. It actually broke our CI with OOM errors.
83
- - We can't add more dialects without making the bundle even larger.
84
- - The parser is feature-incomplete and spits out user-unfriendly error messages like `No viable alternative at...`.
85
- - After all that, we only support **5 dialects**.
105
+ const tokens = tokenize("SELECT 1", {
106
+ dialect: Postgres,
107
+ });
108
+ ```
86
109
 
87
- At a hackathon, I was poking around [Dagster](https://dagster.io/) and stumbled upon SQLGlot. I thought it was amazing that there was a library like this. SQLGlot seems to be trusted by a lots of tools in the Python ecosystems.
110
+ ## SQL Builder
88
111
 
89
- Since then, I was looking for an alternative in Javascript, because I want to run it on the browser. Sadly, at the time, there was none that I knew of.
112
+ Build queries programmatically using a fluent API.
90
113
 
91
- I tried running SQLGlot through [Pyodide](https://pyodide.org/) as a hack, but the runtime is way too heavy to ship anywhere that matters.
114
+ ```ts
115
+ import { select, condition } from "sqlingo";
116
+ import { MySQL } from "sqlingo/mysql";
92
117
 
93
- Therefore, I decided to port it. At 2 weeks into my porting process, [polyglot](https://github.com/tobilg/polyglot) was announced (LOL!). However, I didn't want to waste my effort & also wanted full control - so I just continued anyways.
118
+ const query = select("a", "b").from("t").where(condition("a > 1")).limit(10);
94
119
 
95
- ## Development Setup
120
+ console.log(
121
+ query.sql({
122
+ dialect: MySQL,
123
+ }),
124
+ );
125
+ // Output: SELECT a, b FROM t WHERE a > 1 LIMIT 10
126
+ ```
96
127
 
97
- ### Prerequisites
128
+ ## Optimization & Analysis
98
129
 
99
- Make sure these are installed on your machine:
130
+ ### Optimization
100
131
 
101
- - [`node`](https://nodejs.org/)@^20 - [Installation Guide](https://nodejs.org/en/download/package-manager)
102
- - [`pnpm`](https://pnpm.io/)@^10.26.1 - [Installation Guide](https://pnpm.io/installation)
132
+ Simplify and normalize queries based on schema information.
103
133
 
104
- ### Available Scripts
134
+ ```ts
135
+ import { optimize, MappingSchema } from "sqlingo";
105
136
 
106
- ```bash
107
- pnpm test # Run tests
108
- pnpm test:ui # Run tests with UI
109
- pnpm test:coverage # Run tests with coverage
110
- pnpm build # Build the project
111
- pnpm dev # Build in watch mode
112
- pnpm typecheck # Type check without emitting
113
- pnpm lint # Lint the code
114
- pnpm lint:fix # Lint and auto-fix issues
115
- pnpm run doc # Generate documentation
137
+ const schema = new MappingSchema({
138
+ // define your schema
139
+ });
140
+
141
+ const optimized = optimize(parseOne("SELECT * FROM t"), { schema });
116
142
  ```
117
143
 
118
- ### Mirror Guide
144
+ ### Column Lineage
119
145
 
120
- Check [CONVENTION.md](./CONVENTION.md).
146
+ Trace the origin of columns through subqueries and joins.
121
147
 
122
- I have compiled our convention and lots of pitfalls there. You can use the knowledge there to allow easier debugging.
148
+ ```ts
149
+ import { lineage } from "sqlingo";
123
150
 
124
- ## License
151
+ const node = lineage("b", "SELECT a AS b FROM (SELECT x AS a FROM y)");
152
+ console.log(node.source.name);
153
+ // Output: "y"
154
+ ```
155
+
156
+ ## Registering a Custom Dialect
157
+
158
+ You can extend the library by registering custom dialects or overriding existing behavior.
159
+
160
+ ```ts
161
+ import { Dialect, Generator, transpile } from "sqlingo";
162
+
163
+ class MyDialect extends Dialect {
164
+ static DIALECT_NAME = "my_dialect";
165
+
166
+ static Generator = class extends Generator {
167
+ // Override how specific expressions are generated
168
+ };
169
+ }
125
170
 
126
- sqlingo is licensed under the MIT License. See [LICENSE](LICENSE) for details.
171
+ // Register for string-based lookup
172
+ Dialect.register(MyDialect);
127
173
 
128
- ## Attribution
174
+ const [result] = transpile("SELECT 1", { write: MyDialect });
175
+ ```
176
+
177
+ ## Supported Dialects
178
+
179
+ Athena, BigQuery, ClickHouse, Databricks, Doris, Dremio, Drill, Druid, DuckDB, Dune, Exasol, Fabric, Hive, Materialize, MySQL, Oracle, Postgres, Presto, PRQL, Redshift, RisingWave, SingleStore, Snowflake, Solr, Spark, Spark2, SQLite, StarRocks, Tableau, Teradata, Trino, TSQL
180
+
181
+ ## SQLGlot Compatibility
182
+
183
+ This package tracks [SQLGlot](https://github.com/tobymao/sqlglot) v30.0.0 (commit `a3929be`). The API surface mirrors SQLGlot's Python API, adapted to TypeScript conventions. See [CONVENTION.md](https://github.com/huydo862003/sqlingo/blob/master/packages/sqlingo/CONVENTION.md) for details.
184
+
185
+ ## License
129
186
 
130
- This project is based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao, which is also licensed under the MIT License. The original SQLGlot source code is included as a submodule in this repository.
187
+ MIT. See [LICENSE](https://github.com/huydo862003/sqlingo/blob/master/LICENSE).
131
188
 
132
- See [COPYRIGHT_NOTICE](COPYRIGHT_NOTICE) for full copyright information.
189
+ Based on [SQLGlot](https://github.com/tobymao/sqlglot) by Toby Mao (MIT). See [COPYRIGHT_NOTICE](https://github.com/huydo862003/sqlingo/blob/master/COPYRIGHT_NOTICE).
@@ -1,2 +1,2 @@
1
- import{a as cr}from"./chunk-QWCG55SR.js";import{$b as rt,$v as nr,Ah as V,Ar as _e,Br as Le,Cr as Me,Dr as be,Ej as pe,Fr as N,Fv as ze,Gn as ht,Gv as F,Hm as St,Hn as xe,Hq as me,Ib as Kt,If as Zt,Ir as mt,Js as Be,Jv as $,Kd as Wt,Lf as jt,Ln as Nt,Lr as qe,Lw as lr,Mv as R,Om as Re,Pi as Et,Pr as v,Pv as Qe,Qm as he,Rc as vt,Rk as le,Rm as Ne,Sa as c,Sm as K,Sv as tr,Sw as qt,Tv as er,Uh as re,Um as lt,Up as ft,Vl as ce,Vm as ut,Vv as rr,Wj as Se,Wm as Oe,Wv as sr,Xv as ir,Zq as dt,Zs as Fe,_f as zt,a as s,ae as it,ag as Qt,as as gt,b as M,bc as Ht,bn as ct,c as b,d as q,dn as At,e as E,ee as Xt,en as It,ep as Ce,fm as Ae,fs as Dt,ft as Ge,ge as Jt,gr as ge,gw as ar,hn as Rt,ht as we,id as st,it as Ye,iv as $e,iw as Mt,jd as $t,ji as se,jl as ue,jp as Pe,jr as xt,jt as ye,jv as We,jw as W,kr as Ct,ks as Ut,kx as ur,ls as _t,lv as Xe,lw as bt,mc as kt,ms as Lt,mv as Je,ne as nt,ng as at,nh as te,ni as ie,nr as Pt,nt as Ve,ob as I,ot as Ke,pj as ae,pt as He,rg as B,s as o,sr as De,st as ke,sw as Er,sx as X,tu as ve,tw as or,um as Tt,vh as ee,vj as Ee,vr as k,vw as Tr,wb as Vt,wj as oe,wn as fe,wp as Ot,wv as Ze,ww as pr,xj as Te,xm as pt,xn as de,xv as je,yc as C,yh as y,yn as H,yw as Sr,zi as ne,zk as ot,zm as Ie,zr as Ue}from"./chunk-RGKTYIN3.js";function i(l,a={}){return function(){return this.parseShowMysql(l,a)}}s(i,"showParser");function ss(l){let a=this.sql(l,"this"),t=l.text("unit").toUpperCase(),e,r;if(t==="WEEK")e=`CONCAT(YEAR(${a}), ' ', WEEK(${a}, 1), ' 1')`,r="%Y %u %w";else if(t==="MONTH")e=`CONCAT(YEAR(${a}), ' ', MONTH(${a}), ' 1')`,r="%Y %c %e";else if(t==="QUARTER")e=`CONCAT(YEAR(${a}), ' ', QUARTER(${a}) * 3 - 2, ' 1')`,r="%Y %c %e";else if(t==="YEAR")e=`CONCAT(YEAR(${a}), ' 1 1')`,r="%Y %c %e";else return t!=="DAY"&&this.unsupported(`Unexpected interval unit: ${t}`),this.func("DATE",[a]);return this.func("STR_TO_DATE",[e,`'${r}'`])}s(ss,"dateTruncSql");var is=new Set(["f","H","h","I","i","k","l","p","r","S","s","T"]);function ns(l){let a=0,t=l.length;for(;a<t;){if(l[a]==="%"&&(a+=1,a<t&&is.has(l[a])))return!0;a+=1}return!1}s(ns,"hasTimeSpecifier");function as(l){let a=c(l,1),t=yt.formatTime(a),e=c(l,0);return a&&ns(a instanceof Vt?a.name:a)?new Ct({this:e,format:t||""}):new xt({this:e,format:t})}s(as,"buildStrToDate");function Ft(l){return this.func("STR_TO_DATE",[l.args.this,this.formatTime(l)])}s(Ft,"strToDateSql");function Es(l){let a=l.args.scale,t=l.args.this;return a===void 0||a.toValue()===v.SECONDS.toValue()?this.func("FROM_UNIXTIME",[t,this.formatTime(l)]):this.func("FROM_UNIXTIME",[new ae({this:t,expression:ve("POW","10",a.toString())}),this.formatTime(l)])}s(Es,"unixToTimeSql");function Bt(l){return function(a){return this.func(`DATE_${l}`,[a.args.this,new Et({this:a.args.expression,unit:qt(a)})])}}s(Bt,"dateAddSql");function os(l){return l.args.format?Ft.call(this,l):this.func("DATE",[l.args.this])}s(os,"tsOrDsToDateSql");function d(l,a=["this"]){return function(t){for(let e of a){let r=t.getArgKey(e);(r instanceof N||r instanceof mt)&&!r.getArgKey("format")&&t.setArgKey(e,r.args.this)}return l?l.call(this,t):this.functionFallbackSql(t)}}s(d,"removeTsOrDsToDate");var Ar,Ir,Rr,J,f=class f extends(Rr=X,Ir=[o],Ar=[o],Rr){constructor(){super(...arguments);this.NESTED_COMMENTS=!1}static get ORIGINAL_KEYWORDS(){return{...X.KEYWORDS,BLOB:"blob",CHARSET:"characterSet",DISTINCTROW:"distinct",EXPLAIN:"describe",FORCE:"force",IGNORE:"ignore",KEY:"key","LOCK TABLES":"command",LONGBLOB:"longblob",LONGTEXT:"longtext",MEDIUMBLOB:"mediumblob",MEDIUMINT:"mediumint",MEDIUMTEXT:"mediumtext","MEMBER OF":"memberOf",MOD:"mod",SEPARATOR:"separator",SERIAL:"serial",SIGNED:"bigint","SIGNED INTEGER":"bigint","SOUNDS LIKE":"soundsLike",START:"begin",TIMESTAMP:"timestamptz",TINYBLOB:"tinyblob",TINYTEXT:"tinytext","UNLOCK TABLES":"command",UNSIGNED:"ubigint","UNSIGNED INTEGER":"ubigint",YEAR:"year",_ARMSCII8:"introducer",_ASCII:"introducer",_BIG5:"introducer",_BINARY:"introducer",_CP1250:"introducer",_CP1251:"introducer",_CP1256:"introducer",_CP1257:"introducer",_CP850:"introducer",_CP852:"introducer",_CP866:"introducer",_CP932:"introducer",_DEC8:"introducer",_EUCJPMS:"introducer",_EUCKR:"introducer",_GB18030:"introducer",_GB2312:"introducer",_GBK:"introducer",_GEOSTD8:"introducer",_GREEK:"introducer",_HEBREW:"introducer",_HP8:"introducer",_KEYBCS2:"introducer",_KOI8R:"introducer",_KOI8U:"introducer",_LATIN1:"introducer",_LATIN2:"introducer",_LATIN5:"introducer",_LATIN7:"introducer",_MACCE:"introducer",_MACROMAN:"introducer",_SJIS:"introducer",_SWE7:"introducer",_TIS620:"introducer",_UCS2:"introducer",_UJIS:"introducer",_UTF8:"introducer",_UTF16:"introducer",_UTF16LE:"introducer",_UTF32:"introducer",_UTF8MB3:"introducer",_UTF8MB4:"introducer","@@":"sessionParameter"}}static get COMMANDS(){let t=new Set([...X.COMMANDS,"replace"]);return t.delete("show"),t}};J=M(Rr),E(J,10,"ORIGINAL_KEYWORDS",Ir,f),E(J,10,"COMMANDS",Ar,f),b(J,f),q(J,3,f),s(f,"MySQLTokenizer"),f.QUOTES=["'",'"'],f.COMMENTS=["--","#",["/*","*/"]],f.IDENTIFIERS=["`"],f.STRING_ESCAPES=["'",'"',"\\"],f.BIT_STRINGS=[["b'","'"],["B'","'"],["0b",""]],f.HEX_STRINGS=[["x'","'"],["X'","'"],["0x",""]],f.ESCAPE_FOLLOW_CHARS=["0","b","n","r","t","Z","%","_"];var Gt=f,hr,Nr,Or,fr,dr,xr,Cr,Pr,mr,gr,Dr,Ur,_r,Lr,Mr,br,qr,Br,Fr,Gr,A,T=class T extends(Gr=I,Fr=[o],Br=[o],qr=[o],br=[o],Mr=[o],Lr=[o],_r=[o],Ur=[o],Dr=[o],gr=[o],mr=[o],Pr=[o],Cr=[o],xr=[o],dr=[o],fr=[o],Or=[o],Nr=[o],hr=[o],Gr){static get ID_VAR_TOKENS(){return new Set([...I.ID_VAR_TOKENS,"currentCatalog"])}static get FUNC_TOKENS(){return new Set([...I.FUNC_TOKENS,"database","mod","schema","values","characterSet"])}static get CONJUNCTION(){return{...I.CONJUNCTION,damp:we,xor:ye}}static get DISJUNCTION(){return{...I.DISJUNCTION,dpipe:Ye}}static get TABLE_ALIAS_TOKENS(){return(()=>{let t=new Set(I.TABLE_ALIAS_TOKENS);for(let e of I.TABLE_INDEX_HINT_TOKENS)t.delete(e);return t})()}static get RANGE_PARSERS(){return{...I.RANGE_PARSERS,soundsLike:function(t){return this.expression(Ee,{this:this.expression(dt,{this:t}),expression:this.expression(dt,{this:this.parseTerm()})})},memberOf:function(t){return this.expression(Pe,{this:t,expression:this.parseWrapped(this.parseExpression.bind(this))})}}}static get FUNCTIONS(){return{...I.FUNCTIONS,BIT_AND:s(t=>Ut.fromArgList(t),"BIT_AND"),BIT_OR:s(t=>_t.fromArgList(t),"BIT_OR"),BIT_XOR:s(t=>Lt.fromArgList(t),"BIT_XOR"),BIT_COUNT:s(t=>ot.fromArgList(t),"BIT_COUNT"),CONVERT_TZ:s(t=>new ue({sourceTz:c(t,1),targetTz:c(t,2),timestamp:c(t,0)}),"CONVERT_TZ"),CURDATE:s(t=>pt.fromArgList(t),"CURDATE"),CURTIME:s(t=>Ie.fromArgList(t),"CURTIME"),DATE:s(t=>new N({this:c(t,0)}),"DATE"),DATE_ADD:s(t=>W(K)(t),"DATE_ADD"),DATE_FORMAT:s(t=>new k({this:new mt({this:c(t,0)}),format:$.getOrRaise("mysql")._constructor.formatTime(c(t,1))}),"DATE_FORMAT"),DATE_SUB:s(t=>W(lt)(t),"DATE_SUB"),DAY:s(t=>new Nt({this:new N({this:c(t,0)})}),"DAY"),DAYOFMONTH:s(t=>new At({this:new N({this:c(t,0)})}),"DAYOFMONTH"),DAYOFWEEK:s(t=>new ct({this:new N({this:c(t,0)})}),"DAYOFWEEK"),DAYOFYEAR:s(t=>new It({this:new N({this:c(t,0)})}),"DAYOFYEAR"),FORMAT:s(t=>Pt.fromArgList(t),"FORMAT"),FROM_UNIXTIME:ar(v,{dialect:"mysql"}),ISNULL:lr,LENGTH:s(t=>new Ot({this:c(t,0),binary:!0}),"LENGTH"),MAKETIME:s(t=>ht.fromArgList(t),"MAKETIME"),MONTH:s(t=>new ft({this:new N({this:c(t,0)})}),"MONTH"),MONTHNAME:s(t=>new k({this:new N({this:c(t,0)}),format:new B({this:"%B",isString:!0})}),"MONTHNAME"),SCHEMA:s(t=>St.fromArgList(t),"SCHEMA"),DATABASE:s(t=>St.fromArgList(t),"DATABASE"),STR_TO_DATE:as,TIMESTAMPDIFF:Mt(H,void 0,{defaultUnit:"DAY"}),TO_DAYS:s(t=>{let e=new ut({this:new N({this:c(t,0)}),expression:new N({this:new B({this:"0000-01-01",isString:!0})}),unit:new it({this:"DAY"})});return new Se({this:e.add(1)})},"TO_DAYS"),VERSION:s(t=>Tt.fromArgList(t),"VERSION"),WEEK:s(t=>new gt({this:new N({this:c(t,0)}),mode:c(t,1)}),"WEEK"),WEEKOFYEAR:s(t=>new Rt({this:new N({this:c(t,0)})}),"WEEKOFYEAR"),YEAR:s(t=>new Dt({this:new N({this:c(t,0)})}),"YEAR")}}static get FUNCTION_PARSERS(){return{...I.FUNCTION_PARSERS,GROUP_CONCAT:s(function(){return this.parseGroupConcat()},"GROUP_CONCAT"),VALUES:s(function(){return this.expression(le,{this:"VALUES",expressions:[this.parseIdVar()]})},"VALUES"),JSON_VALUE:s(function(){return this.parseJsonValue()},"JSON_VALUE"),SUBSTR:s(function(){return this.parseSubstring()},"SUBSTR")}}static get STATEMENT_PARSERS(){return{...I.STATEMENT_PARSERS,show:function(){return this.parseShow()}}}static get PROPERTY_PARSERS(){return{...I.PROPERTY_PARSERS,LOCK:s(function(){return this.parsePropertyAssignment(te)},"LOCK"),"PARTITION BY":s(function(){return this.parsePartitionProperty()},"PARTITION BY")}}static get SET_PARSERS(){return{...I.SET_PARSERS,PERSIST:s(function(){return this.parseSetItemAssignment({kind:"persist"})},"PERSIST"),PERSIST_ONLY:s(function(){return this.parseSetItemAssignment({kind:"PERSIST_ONLY"})},"PERSIST_ONLY"),"CHARACTER SET":s(function(){return this.parseSetItemCharset("CHARACTER SET")},"CHARACTER SET"),CHARSET:s(function(){return this.parseSetItemCharset("CHARACTER SET")},"CHARSET"),NAMES:s(function(){return this.parseSetItemNames()},"NAMES")}}static get CONSTRAINT_PARSERS(){return{...I.CONSTRAINT_PARSERS,FULLTEXT:s(function(){return this.parseIndexConstraint("FULLTEXT")},"FULLTEXT"),INDEX:s(function(){return this.parseIndexConstraint()},"INDEX"),KEY:s(function(){return this.parseIndexConstraint()},"KEY"),SPATIAL:s(function(){return this.parseIndexConstraint("SPATIAL")},"SPATIAL"),ZEROFILL:s(function(){return this.expression(jt)},"ZEROFILL")}}static get ALTER_PARSERS(){return{...I.ALTER_PARSERS,MODIFY:s(function(){return this.parseAlterTableAlter()},"MODIFY")}}static get ALTER_ALTER_PARSERS(){return{...I.ALTER_ALTER_PARSERS,INDEX:s(function(){return this.parseAlterTableAlterIndex()},"INDEX")}}static get SCHEMA_UNNAMED_CONSTRAINTS(){return new Set([...I.SCHEMA_UNNAMED_CONSTRAINTS,"FULLTEXT","INDEX","KEY","SPATIAL"])}static get PROFILE_TYPES(){return{ALL:[],CPU:[],IPC:[],MEMORY:[],SOURCE:[],SWAPS:[],BLOCK:["IO"],CONTEXT:["SWITCHES"],PAGE:["FAULTS"]}}static get TYPE_TOKENS(){return new Set([...I.TYPE_TOKENS,"set"])}static get ENUM_TYPE_TOKENS(){return new Set([...I.ENUM_TYPE_TOKENS,"set"])}static get OPERATION_MODIFIERS(){return new Set(["HIGH_PRIORITY","STRAIGHT_JOIN","SQL_SMALL_RESULT","SQL_BIG_RESULT","SQL_BUFFER_RESULT","SQL_NO_CACHE","SQL_CALC_FOUND_ROWS"])}parseGeneratedAsIdentity(){let t=super.parseGeneratedAsIdentity();if(this.matchTexts(["STORED","VIRTUAL"])){let e=this.prev?.text.toUpperCase()==="STORED";t instanceof at?t.setArgKey("persisted",e):t instanceof zt&&(t=this.expression(at,{this:t.args.expression,persisted:e}))}return t}parsePrimaryKeyPart(){let t=this.parseIdVar();if(!this.match("lParen"))return t;let e=this.parseNumber();return this.matchRParen(),this.expression(vt,{this:t,expression:e})}parseIndexConstraint(t){t&&this.matchTexts(["INDEX","KEY"]);let e=this.parseIdVar({anyToken:!1}),r=this.match("using")&&this.advanceAny()&&this.prev?.text,p=this.parseWrappedCsv(this.parseOrdered.bind(this)),S=[];for(;;){let h;if(this.matchTextSeq(["KEY_BLOCK_SIZE"])?(this.match("eq"),h=new C({keyBlockSize:this.parseNumber()})):this.match("using")?h=new C({using:this.advanceAny()&&this.prev?.text}):this.matchTextSeq(["WITH","PARSER"])?h=new C({parser:this.parseVar({anyToken:!0})}):this.match("comment")?h=new C({comment:this.parseString()}):this.matchTextSeq(["VISIBLE"])?h=new C({visible:!0}):this.matchTextSeq(["INVISIBLE"])?h=new C({visible:!1}):this.matchTextSeq(["ENGINE_ATTRIBUTE"])?(this.match("eq"),h=new C({engineAttr:this.parseString()})):this.matchTextSeq(["SECONDARY_ENGINE_ATTRIBUTE"])&&(this.match("eq"),h=new C({secondaryEngineAttr:this.parseString()})),!h)break;S.push(h)}return this.expression(Qt,{this:e,expressions:p,kind:t,indexType:r,options:S})}parseShowMysql(t,e={}){let{target:r=!1,full:p,global:S}=e,h=this.matchTextSeq(["JSON"]),x;r&&(typeof r=="string"&&this.matchTextSeq(r.split(" ")),x=this.parseIdVar());let Z=this.matchTextSeq(["IN"])?this.parseString():void 0,P,D;t==="BINLOG EVENTS"||t==="RELAYLOG EVENTS"?P=this.matchTextSeq(["FROM"])?this.parseNumber():void 0:this.match("from")?D=this.parseIdVar():this.match("dot")&&(D=x,x=this.parseIdVar());let G=this.matchTextSeq(["FOR","CHANNEL"])?this.parseIdVar():void 0,U=this.matchTextSeq(["LIKE"])?this.parseString():void 0,j=this.parseWhere(),w,Y,m,_;t==="PROFILE"?(w=this.parseCsv(()=>this.parseVarFromOptions(T.PROFILE_TYPES)),Y=this.matchTextSeq(["FOR","QUERY"])?this.parseNumber():void 0,m=this.matchTextSeq(["OFFSET"])?this.parseNumber():void 0,_=this.matchTextSeq(["LIMIT"])?this.parseNumber():void 0):[m,_]=this.parseOldstyleLimit();let L;this.matchTextSeq(["MUTEX"])&&(L=!0),this.matchTextSeq(["STATUS"])&&(L=!1);let z=this.matchTextSeq(["FOR","TABLE"])?this.parseIdVar():void 0,Q=this.matchTextSeq(["FOR","GROUP"])?this.parseString():void 0,tt=this.matchTextSeq(["FOR","USER"])?this.parseString():void 0,et=this.matchTextSeq(["FOR","ROLE"])?this.parseString():void 0,rs=this.matchTextSeq(["INTO","OUTFILE"])?this.parseString():void 0;return this.expression(Ht,{this:t,target:x,full:p,log:Z,position:P,db:D,channel:G,like:U,where:j,types:w,query:Y,offset:m,limit:_,mutex:L,forTable:z,forGroup:Q,forUser:tt,forRole:et,intoOutfile:rs,json:h,global:S})}parseOldstyleLimit(){let t,e;if(this.matchTextSeq(["LIMIT"])){let r=this.parseCsv(this.parseNumber.bind(this));r.length===1?t=r[0]:r.length===2&&(t=r[1],e=r[0])}return[e,t]}parseSetItemCharset(t){let e=this.parseString()||this.parseUnquotedField();return this.expression(rt,{this:e,kind:t})}parseSetItemNames(){let t=this.parseString()||this.parseUnquotedField(),e;return this.matchTextSeq(["COLLATE"])&&(e=this.parseString()||this.parseUnquotedField()),this.expression(rt,{this:t,collate:e,kind:"NAMES"})}parseType(t={}){let{parseInterval:e=!0,fallbackToIdentifier:r=!1}=t;if(this.match("binary",{advance:!1})){let p=this.parseTypes({checkFunc:!0,allowIdentifiers:!1});if(p instanceof nt)return this.expression(ce,{this:this.parseColumn(),to:p})}return super.parseType({parseInterval:e,fallbackToIdentifier:r})}parseAlterTableAlterIndex(){let t=this.parseField({anyToken:!0}),e;return this.matchTextSeq(["VISIBLE"])?e=!0:this.matchTextSeq(["INVISIBLE"])&&(e=!1),this.expression(kt,{this:t,visible:e})}parsePartitionProperty(){let t,e;if(this.matchTextSeq(["RANGE"])?(t=y,e=this.parsePartitionRangeValue.bind(this)):this.matchTextSeq(["LIST"])&&(t=V,e=this.parsePartitionListValue.bind(this)),!t||!e)return;let r=this.parseWrappedCsv(this.parseAssignment.bind(this));if(!this.matchTextSeq(["(","PARTITION"],{advance:!1}))return r;let p=this.parseWrappedCsv(e);return this.expression(t,{partitionExpressions:r,createExpressions:p})}parsePartitionRangeValue(){this.matchTextSeq(["PARTITION"]);let t=this.parseIdVar();if(!this.matchTextSeq(["VALUES","LESS","THAN"]))return t;let e=this.parseWrappedCsv(this.parseExpression.bind(this));e.length===1&&e[0]instanceof Zt&&e[0].name.toUpperCase()==="MAXVALUE"&&(e=[new it({this:"MAXVALUE"})]);let r=this.expression($t,{this:t,expressions:e});return this.expression(st,{expressions:[r]})}parsePartitionListValue(){this.matchTextSeq(["PARTITION"]);let t=this.parseIdVar();this.matchTextSeq(["VALUES","IN"]);let e=this.parseWrappedCsv(this.parseExpression.bind(this)),r=this.expression(Wt,{this:t,expressions:e});return this.expression(st,{expressions:[r]})}parsePrimaryKey(t={}){let{wrappedOptional:e=!1,inProps:r=!1,namedPrimaryKey:p=!1}=t;return super.parsePrimaryKey({wrappedOptional:e,inProps:r,namedPrimaryKey:!0})}};A=M(Gr),E(A,10,"ID_VAR_TOKENS",Fr,T),E(A,10,"FUNC_TOKENS",Br,T),E(A,10,"CONJUNCTION",qr,T),E(A,10,"DISJUNCTION",br,T),E(A,10,"TABLE_ALIAS_TOKENS",Mr,T),E(A,10,"RANGE_PARSERS",Lr,T),E(A,10,"FUNCTIONS",_r,T),E(A,10,"FUNCTION_PARSERS",Ur,T),E(A,10,"STATEMENT_PARSERS",Dr,T),E(A,10,"PROPERTY_PARSERS",gr,T),E(A,10,"SET_PARSERS",mr,T),E(A,10,"CONSTRAINT_PARSERS",Pr,T),E(A,10,"ALTER_PARSERS",Cr,T),E(A,10,"ALTER_ALTER_PARSERS",xr,T),E(A,10,"SCHEMA_UNNAMED_CONSTRAINTS",dr,T),E(A,10,"PROFILE_TYPES",fr,T),E(A,10,"TYPE_TOKENS",Or,T),E(A,10,"ENUM_TYPE_TOKENS",Nr,T),E(A,10,"OPERATION_MODIFIERS",hr,T),b(A,T),q(A,3,T),s(T,"MySQLParser"),T.SHOW_PARSERS={"BINARY LOGS":i("BINARY LOGS"),"MASTER LOGS":i("BINARY LOGS"),"BINLOG EVENTS":i("BINLOG EVENTS"),"CHARACTER SET":i("CHARACTER SET"),CHARSET:i("CHARACTER SET"),COLLATION:i("COLLATION"),"FULL COLUMNS":i("COLUMNS",{target:"FROM",full:!0}),COLUMNS:i("COLUMNS",{target:"FROM"}),"CREATE DATABASE":i("CREATE DATABASE",{target:!0}),"CREATE EVENT":i("CREATE EVENT",{target:!0}),"CREATE FUNCTION":i("CREATE FUNCTION",{target:!0}),"CREATE PROCEDURE":i("CREATE PROCEDURE",{target:!0}),"CREATE TABLE":i("CREATE TABLE",{target:!0}),"CREATE TRIGGER":i("CREATE TRIGGER",{target:!0}),"CREATE VIEW":i("CREATE VIEW",{target:!0}),DATABASES:i("DATABASES"),SCHEMAS:i("DATABASES"),ENGINE:i("ENGINE",{target:!0}),"STORAGE ENGINES":i("ENGINES"),ENGINES:i("ENGINES"),ERRORS:i("ERRORS"),EVENTS:i("EVENTS"),"FUNCTION CODE":i("FUNCTION CODE",{target:!0}),"FUNCTION STATUS":i("FUNCTION STATUS"),GRANTS:i("GRANTS",{target:"FOR"}),INDEX:i("INDEX",{target:"FROM"}),"MASTER STATUS":i("MASTER STATUS"),"OPEN TABLES":i("OPEN TABLES"),PLUGINS:i("PLUGINS"),"PROCEDURE CODE":i("PROCEDURE CODE",{target:!0}),"PROCEDURE STATUS":i("PROCEDURE STATUS"),PRIVILEGES:i("PRIVILEGES"),"FULL PROCESSLIST":i("PROCESSLIST",{full:!0}),PROCESSLIST:i("PROCESSLIST"),PROFILE:i("PROFILE"),PROFILES:i("PROFILES"),"RELAYLOG EVENTS":i("RELAYLOG EVENTS"),REPLICAS:i("REPLICAS"),"SLAVE HOSTS":i("REPLICAS"),"REPLICA STATUS":i("REPLICA STATUS"),"SLAVE STATUS":i("REPLICA STATUS"),"GLOBAL STATUS":i("STATUS",{global:!0}),"SESSION STATUS":i("STATUS"),STATUS:i("STATUS"),"TABLE STATUS":i("TABLE STATUS"),"FULL TABLES":i("TABLES",{full:!0}),TABLES:i("TABLES"),TRIGGERS:i("TRIGGERS"),"GLOBAL VARIABLES":i("VARIABLES",{global:!0}),"SESSION VARIABLES":i("VARIABLES"),VARIABLES:i("VARIABLES"),WARNINGS:i("WARNINGS")},T.LOG_DEFAULTS_TO_LN=!0,T.STRING_ALIASES=!0,T.VALUES_FOLLOWED_BY_PAREN=!1,T.SUPPORTS_PARTITION_SELECTION=!0;var wt=T,wr,Yr,yr,Vr,Kr,Hr,kr,vr,$r,Wr,Xr,Jr,Zr,O,n=class n extends(Zr=F,Jr=[o],Xr=[o],Wr=[o],$r=[o],vr=[o],kr=[o],Hr=[o],Kr=[o],Vr=[o],yr=[o],Yr=[o],wr=[o],Zr){static get AFTER_HAVING_MODIFIER_TRANSFORMS(){let t=new Map(super.AFTER_HAVING_MODIFIER_TRANSFORMS);return["cluster","distribute","sort"].forEach(e=>t.delete(e)),t}static get NULL_ORDERING_SUPPORTED(){return"unsupported"}static get ORIGINAL_TRANSFORMS(){return new Map([...F.TRANSFORMS,[Be,R("GROUP_CONCAT")],[Ut,R("BIT_AND")],[_t,R("BIT_OR")],[Lt,R("BIT_XOR")],[ot,R("BIT_COUNT")],[Ae,function(t){return this.chrSql(t,{name:"CHAR"})}],[pt,er],[Tt,R("VERSION")],[ut,d(function(t){return this.func("DATEDIFF",[t.args.this,t.args.expression])},["this","expression"])],[K,d(Bt("ADD"))],[xe,or],[lt,d(Bt("SUB"))],[Oe,ss],[Nt,d()],[At,d(R("DAYOFMONTH"))],[ct,d(R("DAYOFWEEK"))],[It,d(R("DAYOFYEAR"))],[Ge,function(t){return`GROUP_CONCAT(${this.sql(t,"this")} SEPARATOR ${this.sql(t,"separator")||"','"})`}],[pe,tr],[Ce,Qe],[Ot,ur],[Ve,R("MAX")],[Ke,R("MIN")],[He,pr],[ke,Tr],[ft,d()],[oe,function(t){return this.binary(t,"<=>")}],[Te,function(t){return`NOT ${this.binary(t,"<=>")}`}],[Pt,R("FORMAT")],[Jt,sr],[ne,$e([Xe,Ze,Je,je,We])],[ge,function(t){return nr.call(this,t,{funcName:"LOCATE",supportsPosition:!0})}],[xt,Ft],[Ct,Ft],[De,R("INSERT")],[Re,()=>"SESSION_USER()"],[Xt,rr],[ht,R("MAKETIME")],[fe,bt("DATE","ADD")],[H,function(t){return this.func("TIMESTAMPDIFF",[qt(t),t.args.expression,t.args.this])}],[de,bt("DATE","SUB")],[_e,R("UNIX_TIMESTAMP")],[Ue,function(t){return Er.call(this,t,{includePrecision:!t.args.zone})}],[k,d(function(t){return this.func("DATE_FORMAT",[t.args.this,this.formatTime(t)])})],[Le,Sr],[me,R("TRUNCATE")],[Fe,ir],[Me,Bt("ADD")],[be,function(t){return this.func("DATEDIFF",[t.args.this,t.args.expression])}],[N,os],[qe,function(t){return`ORD(CONVERT(${this.sql(t.args.this)} USING utf32))`}],[v,Es],[gt,d()],[Rt,d(R("WEEKOFYEAR"))],[Dt,d()],[Ne,R("UTC_TIMESTAMP")],[he,R("UTC_TIME")]])}static get UNSIGNED_TYPE_MAPPING(){return new Map([["ubigint","BIGINT"],["uint","INT"],["umediumint","MEDIUMINT"],["usmallint","SMALLINT"],["utinyint","TINYINT"],["udecimal","DECIMAL"],["udouble","DOUBLE"]])}static get TIMESTAMP_TYPE_MAPPING(){return new Map([["datetime2","DATETIME"],["smalldatetime","DATETIME"],["timestamp","DATETIME"],["timestampntz","DATETIME"],["timestamptz","TIMESTAMP"],["timestampltz","TIMESTAMP"]])}static get TYPE_MAPPING(){let t=new Map(F.TYPE_MAPPING);for(let[e,r]of n.UNSIGNED_TYPE_MAPPING)t.set(e,r);for(let[e,r]of n.TIMESTAMP_TYPE_MAPPING)t.set(e,r);return t.delete("mediumtext"),t.delete("longtext"),t.delete("tinytext"),t.delete("blob"),t.delete("mediumblob"),t.delete("longblob"),t.delete("tinyblob"),t}static get PROPERTIES_LOCATION(){let t=new Map(F.PROPERTIES_LOCATION);return t.set(se,"unsupported"),t.set(ie,"unsupported"),t.set(ee,"unsupported"),t.set(y,"postSchema"),t.set(V,"postSchema"),t}static get CHAR_CAST_MAPPING(){return["longtext","longblob","mediumblob","mediumtext","text","tinyblob","tinytext","varchar"].reduce((t,e)=>({...t,[e]:"CHAR"}),{})}static get SIGNED_CAST_MAPPING(){return["bigint","boolean","int","smallint","tinyint","mediumint"].reduce((t,e)=>({...t,[e]:"SIGNED"}),{})}static get CAST_MAPPING(){return{...n.CHAR_CAST_MAPPING,...n.SIGNED_CAST_MAPPING,ubigint:"UNSIGNED"}}static get TIMESTAMP_FUNC_TYPES(){return new Set(["timestamptz","timestampltz"])}static get RESERVED_KEYWORDS(){return new Set(["accessible","add","all","alter","analyze","and","as","asc","asensitive","before","between","bigint","binary","blob","both","by","call","cascade","case","change","char","character","check","collate","column","condition","constraint","continue","convert","create","cross","cube","cume_dist","current_date","current_time","current_timestamp","current_user","cursor","database","databases","day_hour","day_microsecond","day_minute","day_second","dec","decimal","declare","default","delayed","delete","dense_rank","desc","describe","deterministic","distinct","distinctrow","div","double","drop","dual","each","else","elseif","empty","enclosed","escaped","except","exists","exit","explain","false","fetch","first_value","float","float4","float8","for","force","foreign","from","fulltext","function","generated","get","grant","group","grouping","groups","having","high_priority","hour_microsecond","hour_minute","hour_second","if","ignore","in","index","infile","inner","inout","insensitive","insert","int","int1","int2","int3","int4","int8","integer","intersect","interval","into","io_after_gtids","io_before_gtids","is","iterate","join","json_table","key","keys","kill","lag","last_value","lateral","lead","leading","leave","left","like","limit","linear","lines","load","localtime","localtimestamp","lock","long","longblob","longtext","loop","low_priority","master_bind","master_ssl_verify_server_cert","match","maxvalue","mediumblob","mediumint","mediumtext","middleint","minute_microsecond","minute_second","mod","modifies","natural","not","no_write_to_binlog","nth_value","ntile","undefined","numeric","of","on","optimize","optimizer_costs","option","optionally","or","order","out","outer","outfile","over","partition","percent_rank","precision","primary","procedure","purge","range","rank","read","reads","read_write","real","recursive","references","regexp","release","rename","repeat","replace","require","resignal","restrict","return","revoke","right","rlike","row","rows","row_number","schema","schemas","second_microsecond","select","sensitive","separator","set","show","signal","smallint","spatial","specific","sql","sqlexception","sqlstate","sqlwarning","sql_big_result","sql_calc_found_rows","sql_small_result","ssl","starting","stored","straight_join","system","table","terminated","then","tinyblob","tinyint","tinytext","to","trailing","trigger","true","undo","union","unique","unlock","unsigned","update","usage","use","using","utc_date","utc_time","utc_timestamp","values","varbinary","varchar","varcharacter","varying","virtual","when","where","while","window","with","write","xor","year_month","zerofill"])}locateProperties(t){let e=super.locateProperties(t),r=t.parent;if(r instanceof Kt&&r.args.kind?.toUpperCase()==="VIEW"){let p=e.get("postSchema");if(p){for(let S=0;S<p.length;S++)if(p[S]instanceof re){let[h]=p.splice(S,1),x=this._constructor.SQL_SECURITY_VIEW_LOCATION;e.has(x)||e.set(x,[]),e.get(x).push(h);break}}}return e}computedColumnConstraintSql(t){let e=t.args.persisted?"STORED":"VIRTUAL";return`GENERATED ALWAYS AS (${this.sql(t.args.this?.unnest())}) ${e}`}arraySql(t){return this.unsupported("Arrays are not supported by MySQL"),this.functionFallbackSql(t)}arrayContainsAllSql(t){return this.unsupported("Array operations are not supported by MySQL"),this.functionFallbackSql(t)}dPipeSql(t){return this.func("CONCAT",[...t.flatten()])}extractSql(t){let e=t.name;return e&&e.toLowerCase()==="epoch"?this.func("UNIX_TIMESTAMP",[t.args.expression]):super.extractSql(t)}dataTypeSql(t){if(this.constructor.VARCHAR_REQUIRES_SIZE&&t.isType("varchar")&&!t.args.expressions?.length)return"TEXT";let e=super.dataTypeSql(t);return n.UNSIGNED_TYPE_MAPPING.has(t.args.this)&&(e=`${e} UNSIGNED`),e}jsonArrayContainsSql(t){return`${this.sql(t,"this")} MEMBER OF(${this.sql(t,"expression")})`}castSql(t,e={}){let r=t.args.to;if(r instanceof nt){let p=r.args.this;if(this._constructor.TIMESTAMP_FUNC_TYPES.has(p))return this.func("TIMESTAMP",[t.args.this]);let S=this._constructor.CAST_MAPPING[p];S&&r.setArgKey("this",S)}return super.castSql(t)}showSql(t){let e=` ${t.name}`,r=t.args.full?" FULL":"",p=t.args.global?" GLOBAL":"",S=this.sql(t,"target");S=S?` ${S}`:"",["COLUMNS","INDEX"].includes(t.name)?S=` FROM${S}`:t.name==="GRANTS"?S=` FOR${S}`:["LINKS","PARTITIONS"].includes(t.name)?S=S?` ON${S}`:"":t.name==="PROJECTIONS"&&(S=S?` ON TABLE${S}`:"");let h=this.prefixedSql("FROM",t,"db"),x=this.prefixedSql("LIKE",t,"like"),Z=this.sql(t,"where"),P=this.expressions(t,{key:"types"});P=P&&` ${P}`;let D=this.prefixedSql("FOR QUERY",t,"query"),G="",U="";t.name==="PROFILE"?(G=this.prefixedSql("OFFSET",t,"offset"),U=this.prefixedSql("LIMIT",t,"limit")):U=this.oldStyleLimitSql(t);let j=this.prefixedSql("IN",t,"log"),w=this.prefixedSql("FROM",t,"position"),Y=this.prefixedSql("FOR CHANNEL",t,"channel"),m="";t.name==="ENGINE"&&(m=t.args.mutex?" MUTEX":" STATUS");let _=this.prefixedSql("FOR TABLE",t,"forTable"),L=this.prefixedSql("FOR GROUP",t,"forGroup"),z=this.prefixedSql("FOR USER",t,"forUser"),Q=this.prefixedSql("FOR ROLE",t,"forRole"),tt=this.prefixedSql("INTO OUTFILE",t,"intoOutfile"),et=t.args.json?" JSON":"";return`SHOW${r}${p}${e}${et}${S}${_}${P}${h}${D}${j}${w}${Y}${m}${x}${Z}${G}${U}${L}${z}${Q}${tt}`}alterRenameSql(t,e={}){return super.alterRenameSql(t,{includeTo:!1})}alterColumnSql(t){let e=this.sql(t,"dtype");return e?`MODIFY COLUMN ${this.sql(t,"this")} ${e}`:super.alterColumnSql(t)}prefixedSql(t,e,r){let p=this.sql(e,r);return p?` ${t} ${p}`:""}oldStyleLimitSql(t){let e=this.sql(t,"limit"),r=this.sql(t,"offset");return e?` LIMIT ${r?`${r}, ${e}`:e}`:""}timestampTruncSql(t){let e=t.args.unit,r="0000-01-01 00:00:00",p=Mt(H)([e,new B({this:r,isString:!0}),t.args.this]),S=new Et({this:p,unit:e}),h=W(K)([new B({this:r,isString:!0}),S]);return this.sql(h)}convertTimezoneSql(t){let e=t.args.sourceTz,r=t.args.targetTz,p=t.args.timestamp;return this.func("CONVERT_TZ",[p,e,r])}atTimeZoneSql(t){return this.unsupported("AT TIME ZONE is not supported by MySQL"),this.sql(t.args.this)}isasciiSql(t){return`REGEXP_LIKE(${this.sql(t.args.this)}, '^[[:ascii:]]*$')`}ignoreNullsSql(t){return this.unsupported("MySQL does not support IGNORE NULLS."),this.sql(t.args.this)}currentSchemaSql(t){return ze.call(this,t,"this"),this.func("SCHEMA",[])}partitionSql(t){let e=t.parent;return e instanceof y||e instanceof V?this.expressions(t,{flat:!0}):super.partitionSql(t)}partitionByRangeOrListSql(t,e){let r=this.expressions(t,{key:"partitionExpressions",flat:!0}),p=this.expressions(t,{key:"createExpressions",flat:!0});return`PARTITION BY ${e} (${r}) (${p})`}partitionByRangePropertySql(t){return this.partitionByRangeOrListSql(t,"RANGE")}partitionByListPropertySql(t){return this.partitionByRangeOrListSql(t,"LIST")}partitionListSql(t){let e=this.sql(t,"this"),r=this.expressions(t,{flat:!0});return`PARTITION ${e} VALUES IN (${r})`}partitionRangeSql(t){let e=this.sql(t,"this"),r=this.expressions(t,{flat:!0});return`PARTITION ${e} VALUES LESS THAN (${r})`}};O=M(Zr),E(O,10,"AFTER_HAVING_MODIFIER_TRANSFORMS",Jr,n),E(O,10,"NULL_ORDERING_SUPPORTED",Xr,n),E(O,10,"ORIGINAL_TRANSFORMS",Wr,n),E(O,10,"UNSIGNED_TYPE_MAPPING",$r,n),E(O,10,"TIMESTAMP_TYPE_MAPPING",vr,n),E(O,10,"TYPE_MAPPING",kr,n),E(O,10,"PROPERTIES_LOCATION",Hr,n),E(O,10,"CHAR_CAST_MAPPING",Kr,n),E(O,10,"SIGNED_CAST_MAPPING",Vr,n),E(O,10,"CAST_MAPPING",yr,n),E(O,10,"TIMESTAMP_FUNC_TYPES",Yr,n),E(O,10,"RESERVED_KEYWORDS",wr,n),b(O,n),q(O,3,n),s(n,"MySQLGenerator"),n.SUPPORTS_DECODE_CASE=!1,n.SELECT_KINDS=[],n.TRY_SUPPORTED=!1,n.SUPPORTS_UESCAPE=!1,n.INTERVAL_ALLOWS_PLURAL_FORM=!1,n.LOCKING_READS_SUPPORTED=!0,n.JOIN_HINTS=!1,n.TABLE_HINTS=!0,n.DUPLICATE_KEY_UPDATE_WITH_SET=!1,n.QUERY_HINT_SEP=" ",n.VALUES_AS_TABLE=!1,n.NVL2_SUPPORTED=!1,n.LAST_DAY_SUPPORTS_DATE_PART=!1,n.JSON_TYPE_REQUIRED_FOR_EXTRACTION=!0,n.JSON_PATH_BRACKETED_KEY_SUPPORTED=!1,n.JSON_KEY_VALUE_PAIR_SEP=",",n.SUPPORTS_TO_NUMBER=!1,n.PARSE_JSON_NAME=void 0,n.PAD_FILL_PATTERN_IS_REQUIRED=!0,n.WRAP_DERIVED_VALUES=!1,n.VARCHAR_REQUIRES_SIZE=!0,n.SUPPORTS_MEDIAN=!1,n.UPDATE_STATEMENT_SUPPORTS_FROM=!1,n.SUPPORTS_CONVERT_TIMEZONE=!0,n.SQL_SECURITY_VIEW_LOCATION="postCreate",n.LIMIT_FETCH="LIMIT",n.LIMIT_ONLY_LITERALS=!0;var Yt=n,jr,zr,Qr,ts,es,g,u=class u extends(es=$,ts=[o],Qr=[o],zr=[o],jr=[o],es){static get NORMALIZATION_STRATEGY(){return"caseSensitive"}static get EXPRESSION_METADATA(){return new Map(cr.EXPRESSION_METADATA)}static get TIME_MAPPING(){return{"%M":"%B","%c":"%-m","%e":"%-d","%h":"%I","%i":"%M","%s":"%S","%u":"%W","%k":"%-H","%l":"%-I","%T":"%H:%M:%S","%W":"%A"}}static get VALID_INTERVAL_UNITS(){return new Set([...$.VALID_INTERVAL_UNITS,"SECOND_MICROSECOND","MINUTE_MICROSECOND","MINUTE_SECOND","HOUR_MICROSECOND","HOUR_SECOND","HOUR_MINUTE","DAY_MICROSECOND","DAY_SECOND","DAY_MINUTE","DAY_HOUR","YEAR_MONTH"])}};g=M(es),E(g,10,"NORMALIZATION_STRATEGY",ts,u),E(g,10,"EXPRESSION_METADATA",Qr,u),E(g,10,"TIME_MAPPING",zr,u),E(g,10,"VALID_INTERVAL_UNITS",jr,u),b(g,u),q(g,3,u),s(u,"MySQL"),u.DIALECT_NAME="mysql",u.PROMOTE_TO_INFERRED_DATETIME_TYPE=!0,u.IDENTIFIERS_CAN_START_WITH_DIGIT=!0,u.TIME_FORMAT="'%Y-%m-%d %T'",u.DPIPE_IS_STRING_CONCAT=!1,u.SUPPORTS_USER_DEFINED_TYPES=!1,u.SUPPORTS_SEMI_ANTI_JOIN=!1,u.SAFE_DIVISION=!0,u.SAFE_TO_ELIMINATE_DOUBLE_NEGATION=!1,u.LEAST_GREATEST_IGNORES_NULLS=!1,u.Tokenizer=Gt,u.Parser=wt,u.Generator=Yt;var yt=u;export{i as a,ss as b,is as c,as as d,Ft as e,Es as f,Bt as g,os as h,d as i,yt as j};
2
- //# sourceMappingURL=chunk-DGV6NM76.js.map
1
+ import{a as cr}from"./chunk-UQR7VDWJ.js";import{$b as rt,Ah as V,Ar as Ue,Br as _e,Cr as Le,Dr as Me,Ej as pe,Er as be,Gn as ht,Gr as N,Gv as ze,Hm as St,Hn as xe,Hq as me,Hv as F,Ib as Kt,If as Zt,Jr as mt,Kd as Wt,Ks as Be,Kv as $,Lf as jt,Ln as Nt,Mr as qe,Mw as lr,Nv as R,Om as Re,Pi as Et,Qm as he,Qr as v,Qv as Qe,Rc as vt,Rk as le,Rm as Ne,Sa as c,Sm as K,Tv as tr,Tw as qt,Uh as re,Um as lt,Up as ft,Uv as er,Vl as ce,Vm as ut,Wj as Se,Wm as Oe,Wv as rr,Xv as sr,Yv as ir,Zq as dt,_f as zt,_s as Fe,a as s,ae as it,ag as Qt,aw as nr,b as M,bc as Ht,bn as ct,bs as gt,c as b,d as q,dn as At,e as E,ee as Xt,en as It,ep as Ce,fm as Ae,ge as Jt,gs as Dt,gt as Ge,hn as Rt,hr as ge,hw as ar,id as st,it as we,jd as $t,ji as se,jl as ue,jp as Pe,jt as Ye,jv as $e,jw as Mt,kr as xt,kt as ye,kv as We,kw as W,lr as Ct,ls as Ut,lx as ur,mc as kt,ms as _t,mv as Xe,mw as bt,ne as nt,ng as at,nh as te,ni as ie,ns as Lt,nv as Je,ob as I,or as Pt,ot as Ve,pj as ae,pt as Ke,qt as He,rg as B,s as o,tr as De,tt as ke,tw as Er,tx as X,um as Tt,uu as ve,uw as or,vh as ee,vj as Ee,wb as Vt,wj as oe,wn as fe,wp as Ot,wr as k,ww as Tr,xj as Te,xm as pt,xn as de,xv as Ze,xw as pr,yc as C,yh as y,yn as H,yv as je,zi as ne,zk as ot,zm as Ie,zw as Sr}from"./chunk-APZJ7NQO.js";function i(l,a={}){return function(){return this.parseShowMysql(l,a)}}s(i,"showParser");function ss(l){let a=this.sql(l,"this"),t=l.text("unit").toUpperCase(),e,r;if(t==="WEEK")e=`CONCAT(YEAR(${a}), ' ', WEEK(${a}, 1), ' 1')`,r="%Y %u %w";else if(t==="MONTH")e=`CONCAT(YEAR(${a}), ' ', MONTH(${a}), ' 1')`,r="%Y %c %e";else if(t==="QUARTER")e=`CONCAT(YEAR(${a}), ' ', QUARTER(${a}) * 3 - 2, ' 1')`,r="%Y %c %e";else if(t==="YEAR")e=`CONCAT(YEAR(${a}), ' 1 1')`,r="%Y %c %e";else return t!=="DAY"&&this.unsupported(`Unexpected interval unit: ${t}`),this.func("DATE",[a]);return this.func("STR_TO_DATE",[e,`'${r}'`])}s(ss,"dateTruncSql");var is=new Set(["f","H","h","I","i","k","l","p","r","S","s","T"]);function ns(l){let a=0,t=l.length;for(;a<t;){if(l[a]==="%"&&(a+=1,a<t&&is.has(l[a])))return!0;a+=1}return!1}s(ns,"hasTimeSpecifier");function as(l){let a=c(l,1),t=yt.formatTime(a),e=c(l,0);return a&&ns(a instanceof Vt?a.name:a)?new Ct({this:e,format:t||""}):new xt({this:e,format:t})}s(as,"buildStrToDate");function Ft(l){return this.func("STR_TO_DATE",[l.args.this,this.formatTime(l)])}s(Ft,"strToDateSql");function Es(l){let a=l.args.scale,t=l.args.this;return a===void 0||a.toValue()===v.SECONDS.toValue()?this.func("FROM_UNIXTIME",[t,this.formatTime(l)]):this.func("FROM_UNIXTIME",[new ae({this:t,expression:ve("POW","10",a.toString())}),this.formatTime(l)])}s(Es,"unixToTimeSql");function Bt(l){return function(a){return this.func(`DATE_${l}`,[a.args.this,new Et({this:a.args.expression,unit:qt(a)})])}}s(Bt,"dateAddSql");function os(l){return l.args.format?Ft.call(this,l):this.func("DATE",[l.args.this])}s(os,"tsOrDsToDateSql");function d(l,a=["this"]){return function(t){for(let e of a){let r=t.getArgKey(e);(r instanceof N||r instanceof mt)&&!r.getArgKey("format")&&t.setArgKey(e,r.args.this)}return l?l.call(this,t):this.functionFallbackSql(t)}}s(d,"removeTsOrDsToDate");var Ar,Ir,Rr,J,f=class f extends(Rr=X,Ir=[o],Ar=[o],Rr){constructor(){super(...arguments);this.NESTED_COMMENTS=!1}static get ORIGINAL_KEYWORDS(){return{...X.KEYWORDS,BLOB:"blob",CHARSET:"characterSet",DISTINCTROW:"distinct",EXPLAIN:"describe",FORCE:"force",IGNORE:"ignore",KEY:"key","LOCK TABLES":"command",LONGBLOB:"longblob",LONGTEXT:"longtext",MEDIUMBLOB:"mediumblob",MEDIUMINT:"mediumint",MEDIUMTEXT:"mediumtext","MEMBER OF":"memberOf",MOD:"mod",SEPARATOR:"separator",SERIAL:"serial",SIGNED:"bigint","SIGNED INTEGER":"bigint","SOUNDS LIKE":"soundsLike",START:"begin",TIMESTAMP:"timestamptz",TINYBLOB:"tinyblob",TINYTEXT:"tinytext","UNLOCK TABLES":"command",UNSIGNED:"ubigint","UNSIGNED INTEGER":"ubigint",YEAR:"year",_ARMSCII8:"introducer",_ASCII:"introducer",_BIG5:"introducer",_BINARY:"introducer",_CP1250:"introducer",_CP1251:"introducer",_CP1256:"introducer",_CP1257:"introducer",_CP850:"introducer",_CP852:"introducer",_CP866:"introducer",_CP932:"introducer",_DEC8:"introducer",_EUCJPMS:"introducer",_EUCKR:"introducer",_GB18030:"introducer",_GB2312:"introducer",_GBK:"introducer",_GEOSTD8:"introducer",_GREEK:"introducer",_HEBREW:"introducer",_HP8:"introducer",_KEYBCS2:"introducer",_KOI8R:"introducer",_KOI8U:"introducer",_LATIN1:"introducer",_LATIN2:"introducer",_LATIN5:"introducer",_LATIN7:"introducer",_MACCE:"introducer",_MACROMAN:"introducer",_SJIS:"introducer",_SWE7:"introducer",_TIS620:"introducer",_UCS2:"introducer",_UJIS:"introducer",_UTF8:"introducer",_UTF16:"introducer",_UTF16LE:"introducer",_UTF32:"introducer",_UTF8MB3:"introducer",_UTF8MB4:"introducer","@@":"sessionParameter"}}static get COMMANDS(){let t=new Set([...X.COMMANDS,"replace"]);return t.delete("show"),t}};J=M(Rr),E(J,10,"ORIGINAL_KEYWORDS",Ir,f),E(J,10,"COMMANDS",Ar,f),b(J,f),q(J,3,f),s(f,"MySQLTokenizer"),f.QUOTES=["'",'"'],f.COMMENTS=["--","#",["/*","*/"]],f.IDENTIFIERS=["`"],f.STRING_ESCAPES=["'",'"',"\\"],f.BIT_STRINGS=[["b'","'"],["B'","'"],["0b",""]],f.HEX_STRINGS=[["x'","'"],["X'","'"],["0x",""]],f.ESCAPE_FOLLOW_CHARS=["0","b","n","r","t","Z","%","_"];var Gt=f,hr,Nr,Or,fr,dr,xr,Cr,Pr,mr,gr,Dr,Ur,_r,Lr,Mr,br,qr,Br,Fr,Gr,A,T=class T extends(Gr=I,Fr=[o],Br=[o],qr=[o],br=[o],Mr=[o],Lr=[o],_r=[o],Ur=[o],Dr=[o],gr=[o],mr=[o],Pr=[o],Cr=[o],xr=[o],dr=[o],fr=[o],Or=[o],Nr=[o],hr=[o],Gr){static get ID_VAR_TOKENS(){return new Set([...I.ID_VAR_TOKENS,"currentCatalog"])}static get FUNC_TOKENS(){return new Set([...I.FUNC_TOKENS,"database","mod","schema","values","characterSet"])}static get CONJUNCTION(){return{...I.CONJUNCTION,damp:we,xor:ye}}static get DISJUNCTION(){return{...I.DISJUNCTION,dpipe:Ye}}static get TABLE_ALIAS_TOKENS(){return(()=>{let t=new Set(I.TABLE_ALIAS_TOKENS);for(let e of I.TABLE_INDEX_HINT_TOKENS)t.delete(e);return t})()}static get RANGE_PARSERS(){return{...I.RANGE_PARSERS,soundsLike:function(t){return this.expression(Ee,{this:this.expression(dt,{this:t}),expression:this.expression(dt,{this:this.parseTerm()})})},memberOf:function(t){return this.expression(Pe,{this:t,expression:this.parseWrapped(this.parseExpression.bind(this))})}}}static get FUNCTIONS(){return{...I.FUNCTIONS,BIT_AND:s(t=>Ut.fromArgList(t),"BIT_AND"),BIT_OR:s(t=>_t.fromArgList(t),"BIT_OR"),BIT_XOR:s(t=>Lt.fromArgList(t),"BIT_XOR"),BIT_COUNT:s(t=>ot.fromArgList(t),"BIT_COUNT"),CONVERT_TZ:s(t=>new ue({sourceTz:c(t,1),targetTz:c(t,2),timestamp:c(t,0)}),"CONVERT_TZ"),CURDATE:s(t=>pt.fromArgList(t),"CURDATE"),CURTIME:s(t=>Ie.fromArgList(t),"CURTIME"),DATE:s(t=>new N({this:c(t,0)}),"DATE"),DATE_ADD:s(t=>W(K)(t),"DATE_ADD"),DATE_FORMAT:s(t=>new k({this:new mt({this:c(t,0)}),format:$.getOrRaise("mysql")._constructor.formatTime(c(t,1))}),"DATE_FORMAT"),DATE_SUB:s(t=>W(lt)(t),"DATE_SUB"),DAY:s(t=>new Nt({this:new N({this:c(t,0)})}),"DAY"),DAYOFMONTH:s(t=>new At({this:new N({this:c(t,0)})}),"DAYOFMONTH"),DAYOFWEEK:s(t=>new ct({this:new N({this:c(t,0)})}),"DAYOFWEEK"),DAYOFYEAR:s(t=>new It({this:new N({this:c(t,0)})}),"DAYOFYEAR"),FORMAT:s(t=>Pt.fromArgList(t),"FORMAT"),FROM_UNIXTIME:ar(v,{dialect:"mysql"}),ISNULL:lr,LENGTH:s(t=>new Ot({this:c(t,0),binary:!0}),"LENGTH"),MAKETIME:s(t=>ht.fromArgList(t),"MAKETIME"),MONTH:s(t=>new ft({this:new N({this:c(t,0)})}),"MONTH"),MONTHNAME:s(t=>new k({this:new N({this:c(t,0)}),format:new B({this:"%B",isString:!0})}),"MONTHNAME"),SCHEMA:s(t=>St.fromArgList(t),"SCHEMA"),DATABASE:s(t=>St.fromArgList(t),"DATABASE"),STR_TO_DATE:as,TIMESTAMPDIFF:Mt(H,void 0,{defaultUnit:"DAY"}),TO_DAYS:s(t=>{let e=new ut({this:new N({this:c(t,0)}),expression:new N({this:new B({this:"0000-01-01",isString:!0})}),unit:new it({this:"DAY"})});return new Se({this:e.add(1)})},"TO_DAYS"),VERSION:s(t=>Tt.fromArgList(t),"VERSION"),WEEK:s(t=>new gt({this:new N({this:c(t,0)}),mode:c(t,1)}),"WEEK"),WEEKOFYEAR:s(t=>new Rt({this:new N({this:c(t,0)})}),"WEEKOFYEAR"),YEAR:s(t=>new Dt({this:new N({this:c(t,0)})}),"YEAR")}}static get FUNCTION_PARSERS(){return{...I.FUNCTION_PARSERS,GROUP_CONCAT:s(function(){return this.parseGroupConcat()},"GROUP_CONCAT"),VALUES:s(function(){return this.expression(le,{this:"VALUES",expressions:[this.parseIdVar()]})},"VALUES"),JSON_VALUE:s(function(){return this.parseJsonValue()},"JSON_VALUE"),SUBSTR:s(function(){return this.parseSubstring()},"SUBSTR")}}static get STATEMENT_PARSERS(){return{...I.STATEMENT_PARSERS,show:function(){return this.parseShow()}}}static get PROPERTY_PARSERS(){return{...I.PROPERTY_PARSERS,LOCK:s(function(){return this.parsePropertyAssignment(te)},"LOCK"),"PARTITION BY":s(function(){return this.parsePartitionProperty()},"PARTITION BY")}}static get SET_PARSERS(){return{...I.SET_PARSERS,PERSIST:s(function(){return this.parseSetItemAssignment({kind:"persist"})},"PERSIST"),PERSIST_ONLY:s(function(){return this.parseSetItemAssignment({kind:"PERSIST_ONLY"})},"PERSIST_ONLY"),"CHARACTER SET":s(function(){return this.parseSetItemCharset("CHARACTER SET")},"CHARACTER SET"),CHARSET:s(function(){return this.parseSetItemCharset("CHARACTER SET")},"CHARSET"),NAMES:s(function(){return this.parseSetItemNames()},"NAMES")}}static get CONSTRAINT_PARSERS(){return{...I.CONSTRAINT_PARSERS,FULLTEXT:s(function(){return this.parseIndexConstraint("FULLTEXT")},"FULLTEXT"),INDEX:s(function(){return this.parseIndexConstraint()},"INDEX"),KEY:s(function(){return this.parseIndexConstraint()},"KEY"),SPATIAL:s(function(){return this.parseIndexConstraint("SPATIAL")},"SPATIAL"),ZEROFILL:s(function(){return this.expression(jt)},"ZEROFILL")}}static get ALTER_PARSERS(){return{...I.ALTER_PARSERS,MODIFY:s(function(){return this.parseAlterTableAlter()},"MODIFY")}}static get ALTER_ALTER_PARSERS(){return{...I.ALTER_ALTER_PARSERS,INDEX:s(function(){return this.parseAlterTableAlterIndex()},"INDEX")}}static get SCHEMA_UNNAMED_CONSTRAINTS(){return new Set([...I.SCHEMA_UNNAMED_CONSTRAINTS,"FULLTEXT","INDEX","KEY","SPATIAL"])}static get PROFILE_TYPES(){return{ALL:[],CPU:[],IPC:[],MEMORY:[],SOURCE:[],SWAPS:[],BLOCK:["IO"],CONTEXT:["SWITCHES"],PAGE:["FAULTS"]}}static get TYPE_TOKENS(){return new Set([...I.TYPE_TOKENS,"set"])}static get ENUM_TYPE_TOKENS(){return new Set([...I.ENUM_TYPE_TOKENS,"set"])}static get OPERATION_MODIFIERS(){return new Set(["HIGH_PRIORITY","STRAIGHT_JOIN","SQL_SMALL_RESULT","SQL_BIG_RESULT","SQL_BUFFER_RESULT","SQL_NO_CACHE","SQL_CALC_FOUND_ROWS"])}parseGeneratedAsIdentity(){let t=super.parseGeneratedAsIdentity();if(this.matchTexts(["STORED","VIRTUAL"])){let e=this.prev?.text.toUpperCase()==="STORED";t instanceof at?t.setArgKey("persisted",e):t instanceof zt&&(t=this.expression(at,{this:t.args.expression,persisted:e}))}return t}parsePrimaryKeyPart(){let t=this.parseIdVar();if(!this.match("lParen"))return t;let e=this.parseNumber();return this.matchRParen(),this.expression(vt,{this:t,expression:e})}parseIndexConstraint(t){t&&this.matchTexts(["INDEX","KEY"]);let e=this.parseIdVar({anyToken:!1}),r=this.match("using")&&this.advanceAny()&&this.prev?.text,p=this.parseWrappedCsv(this.parseOrdered.bind(this)),S=[];for(;;){let h;if(this.matchTextSeq(["KEY_BLOCK_SIZE"])?(this.match("eq"),h=new C({keyBlockSize:this.parseNumber()})):this.match("using")?h=new C({using:this.advanceAny()&&this.prev?.text}):this.matchTextSeq(["WITH","PARSER"])?h=new C({parser:this.parseVar({anyToken:!0})}):this.match("comment")?h=new C({comment:this.parseString()}):this.matchTextSeq(["VISIBLE"])?h=new C({visible:!0}):this.matchTextSeq(["INVISIBLE"])?h=new C({visible:!1}):this.matchTextSeq(["ENGINE_ATTRIBUTE"])?(this.match("eq"),h=new C({engineAttr:this.parseString()})):this.matchTextSeq(["SECONDARY_ENGINE_ATTRIBUTE"])&&(this.match("eq"),h=new C({secondaryEngineAttr:this.parseString()})),!h)break;S.push(h)}return this.expression(Qt,{this:e,expressions:p,kind:t,indexType:r,options:S})}parseShowMysql(t,e={}){let{target:r=!1,full:p,global:S}=e,h=this.matchTextSeq(["JSON"]),x;r&&(typeof r=="string"&&this.matchTextSeq(r.split(" ")),x=this.parseIdVar());let Z=this.matchTextSeq(["IN"])?this.parseString():void 0,P,D;t==="BINLOG EVENTS"||t==="RELAYLOG EVENTS"?P=this.matchTextSeq(["FROM"])?this.parseNumber():void 0:this.match("from")?D=this.parseIdVar():this.match("dot")&&(D=x,x=this.parseIdVar());let G=this.matchTextSeq(["FOR","CHANNEL"])?this.parseIdVar():void 0,U=this.matchTextSeq(["LIKE"])?this.parseString():void 0,j=this.parseWhere(),w,Y,m,_;t==="PROFILE"?(w=this.parseCsv(()=>this.parseVarFromOptions(T.PROFILE_TYPES)),Y=this.matchTextSeq(["FOR","QUERY"])?this.parseNumber():void 0,m=this.matchTextSeq(["OFFSET"])?this.parseNumber():void 0,_=this.matchTextSeq(["LIMIT"])?this.parseNumber():void 0):[m,_]=this.parseOldstyleLimit();let L;this.matchTextSeq(["MUTEX"])&&(L=!0),this.matchTextSeq(["STATUS"])&&(L=!1);let z=this.matchTextSeq(["FOR","TABLE"])?this.parseIdVar():void 0,Q=this.matchTextSeq(["FOR","GROUP"])?this.parseString():void 0,tt=this.matchTextSeq(["FOR","USER"])?this.parseString():void 0,et=this.matchTextSeq(["FOR","ROLE"])?this.parseString():void 0,rs=this.matchTextSeq(["INTO","OUTFILE"])?this.parseString():void 0;return this.expression(Ht,{this:t,target:x,full:p,log:Z,position:P,db:D,channel:G,like:U,where:j,types:w,query:Y,offset:m,limit:_,mutex:L,forTable:z,forGroup:Q,forUser:tt,forRole:et,intoOutfile:rs,json:h,global:S})}parseOldstyleLimit(){let t,e;if(this.matchTextSeq(["LIMIT"])){let r=this.parseCsv(this.parseNumber.bind(this));r.length===1?t=r[0]:r.length===2&&(t=r[1],e=r[0])}return[e,t]}parseSetItemCharset(t){let e=this.parseString()||this.parseUnquotedField();return this.expression(rt,{this:e,kind:t})}parseSetItemNames(){let t=this.parseString()||this.parseUnquotedField(),e;return this.matchTextSeq(["COLLATE"])&&(e=this.parseString()||this.parseUnquotedField()),this.expression(rt,{this:t,collate:e,kind:"NAMES"})}parseType(t={}){let{parseInterval:e=!0,fallbackToIdentifier:r=!1}=t;if(this.match("binary",{advance:!1})){let p=this.parseTypes({checkFunc:!0,allowIdentifiers:!1});if(p instanceof nt)return this.expression(ce,{this:this.parseColumn(),to:p})}return super.parseType({parseInterval:e,fallbackToIdentifier:r})}parseAlterTableAlterIndex(){let t=this.parseField({anyToken:!0}),e;return this.matchTextSeq(["VISIBLE"])?e=!0:this.matchTextSeq(["INVISIBLE"])&&(e=!1),this.expression(kt,{this:t,visible:e})}parsePartitionProperty(){let t,e;if(this.matchTextSeq(["RANGE"])?(t=y,e=this.parsePartitionRangeValue.bind(this)):this.matchTextSeq(["LIST"])&&(t=V,e=this.parsePartitionListValue.bind(this)),!t||!e)return;let r=this.parseWrappedCsv(this.parseAssignment.bind(this));if(!this.matchTextSeq(["(","PARTITION"],{advance:!1}))return r;let p=this.parseWrappedCsv(e);return this.expression(t,{partitionExpressions:r,createExpressions:p})}parsePartitionRangeValue(){this.matchTextSeq(["PARTITION"]);let t=this.parseIdVar();if(!this.matchTextSeq(["VALUES","LESS","THAN"]))return t;let e=this.parseWrappedCsv(this.parseExpression.bind(this));e.length===1&&e[0]instanceof Zt&&e[0].name.toUpperCase()==="MAXVALUE"&&(e=[new it({this:"MAXVALUE"})]);let r=this.expression($t,{this:t,expressions:e});return this.expression(st,{expressions:[r]})}parsePartitionListValue(){this.matchTextSeq(["PARTITION"]);let t=this.parseIdVar();this.matchTextSeq(["VALUES","IN"]);let e=this.parseWrappedCsv(this.parseExpression.bind(this)),r=this.expression(Wt,{this:t,expressions:e});return this.expression(st,{expressions:[r]})}parsePrimaryKey(t={}){let{wrappedOptional:e=!1,inProps:r=!1,namedPrimaryKey:p=!1}=t;return super.parsePrimaryKey({wrappedOptional:e,inProps:r,namedPrimaryKey:!0})}};A=M(Gr),E(A,10,"ID_VAR_TOKENS",Fr,T),E(A,10,"FUNC_TOKENS",Br,T),E(A,10,"CONJUNCTION",qr,T),E(A,10,"DISJUNCTION",br,T),E(A,10,"TABLE_ALIAS_TOKENS",Mr,T),E(A,10,"RANGE_PARSERS",Lr,T),E(A,10,"FUNCTIONS",_r,T),E(A,10,"FUNCTION_PARSERS",Ur,T),E(A,10,"STATEMENT_PARSERS",Dr,T),E(A,10,"PROPERTY_PARSERS",gr,T),E(A,10,"SET_PARSERS",mr,T),E(A,10,"CONSTRAINT_PARSERS",Pr,T),E(A,10,"ALTER_PARSERS",Cr,T),E(A,10,"ALTER_ALTER_PARSERS",xr,T),E(A,10,"SCHEMA_UNNAMED_CONSTRAINTS",dr,T),E(A,10,"PROFILE_TYPES",fr,T),E(A,10,"TYPE_TOKENS",Or,T),E(A,10,"ENUM_TYPE_TOKENS",Nr,T),E(A,10,"OPERATION_MODIFIERS",hr,T),b(A,T),q(A,3,T),s(T,"MySQLParser"),T.SHOW_PARSERS={"BINARY LOGS":i("BINARY LOGS"),"MASTER LOGS":i("BINARY LOGS"),"BINLOG EVENTS":i("BINLOG EVENTS"),"CHARACTER SET":i("CHARACTER SET"),CHARSET:i("CHARACTER SET"),COLLATION:i("COLLATION"),"FULL COLUMNS":i("COLUMNS",{target:"FROM",full:!0}),COLUMNS:i("COLUMNS",{target:"FROM"}),"CREATE DATABASE":i("CREATE DATABASE",{target:!0}),"CREATE EVENT":i("CREATE EVENT",{target:!0}),"CREATE FUNCTION":i("CREATE FUNCTION",{target:!0}),"CREATE PROCEDURE":i("CREATE PROCEDURE",{target:!0}),"CREATE TABLE":i("CREATE TABLE",{target:!0}),"CREATE TRIGGER":i("CREATE TRIGGER",{target:!0}),"CREATE VIEW":i("CREATE VIEW",{target:!0}),DATABASES:i("DATABASES"),SCHEMAS:i("DATABASES"),ENGINE:i("ENGINE",{target:!0}),"STORAGE ENGINES":i("ENGINES"),ENGINES:i("ENGINES"),ERRORS:i("ERRORS"),EVENTS:i("EVENTS"),"FUNCTION CODE":i("FUNCTION CODE",{target:!0}),"FUNCTION STATUS":i("FUNCTION STATUS"),GRANTS:i("GRANTS",{target:"FOR"}),INDEX:i("INDEX",{target:"FROM"}),"MASTER STATUS":i("MASTER STATUS"),"OPEN TABLES":i("OPEN TABLES"),PLUGINS:i("PLUGINS"),"PROCEDURE CODE":i("PROCEDURE CODE",{target:!0}),"PROCEDURE STATUS":i("PROCEDURE STATUS"),PRIVILEGES:i("PRIVILEGES"),"FULL PROCESSLIST":i("PROCESSLIST",{full:!0}),PROCESSLIST:i("PROCESSLIST"),PROFILE:i("PROFILE"),PROFILES:i("PROFILES"),"RELAYLOG EVENTS":i("RELAYLOG EVENTS"),REPLICAS:i("REPLICAS"),"SLAVE HOSTS":i("REPLICAS"),"REPLICA STATUS":i("REPLICA STATUS"),"SLAVE STATUS":i("REPLICA STATUS"),"GLOBAL STATUS":i("STATUS",{global:!0}),"SESSION STATUS":i("STATUS"),STATUS:i("STATUS"),"TABLE STATUS":i("TABLE STATUS"),"FULL TABLES":i("TABLES",{full:!0}),TABLES:i("TABLES"),TRIGGERS:i("TRIGGERS"),"GLOBAL VARIABLES":i("VARIABLES",{global:!0}),"SESSION VARIABLES":i("VARIABLES"),VARIABLES:i("VARIABLES"),WARNINGS:i("WARNINGS")},T.LOG_DEFAULTS_TO_LN=!0,T.STRING_ALIASES=!0,T.VALUES_FOLLOWED_BY_PAREN=!1,T.SUPPORTS_PARTITION_SELECTION=!0;var wt=T,wr,Yr,yr,Vr,Kr,Hr,kr,vr,$r,Wr,Xr,Jr,Zr,O,n=class n extends(Zr=F,Jr=[o],Xr=[o],Wr=[o],$r=[o],vr=[o],kr=[o],Hr=[o],Kr=[o],Vr=[o],yr=[o],Yr=[o],wr=[o],Zr){static get AFTER_HAVING_MODIFIER_TRANSFORMS(){let t=new Map(super.AFTER_HAVING_MODIFIER_TRANSFORMS);return["cluster","distribute","sort"].forEach(e=>t.delete(e)),t}static get NULL_ORDERING_SUPPORTED(){return"unsupported"}static get ORIGINAL_TRANSFORMS(){return new Map([...F.TRANSFORMS,[Be,R("GROUP_CONCAT")],[Ut,R("BIT_AND")],[_t,R("BIT_OR")],[Lt,R("BIT_XOR")],[ot,R("BIT_COUNT")],[Ae,function(t){return this.chrSql(t,{name:"CHAR"})}],[pt,er],[Tt,R("VERSION")],[ut,d(function(t){return this.func("DATEDIFF",[t.args.this,t.args.expression])},["this","expression"])],[K,d(Bt("ADD"))],[xe,or],[lt,d(Bt("SUB"))],[Oe,ss],[Nt,d()],[At,d(R("DAYOFMONTH"))],[ct,d(R("DAYOFWEEK"))],[It,d(R("DAYOFYEAR"))],[Ge,function(t){return`GROUP_CONCAT(${this.sql(t,"this")} SEPARATOR ${this.sql(t,"separator")||"','"})`}],[pe,tr],[Ce,Qe],[Ot,ur],[Ve,R("MAX")],[Ke,R("MIN")],[He,pr],[ke,Tr],[ft,d()],[oe,function(t){return this.binary(t,"<=>")}],[Te,function(t){return`NOT ${this.binary(t,"<=>")}`}],[Pt,R("FORMAT")],[Jt,sr],[ne,$e([Xe,Ze,Je,je,We])],[ge,function(t){return nr.call(this,t,{funcName:"LOCATE",supportsPosition:!0})}],[xt,Ft],[Ct,Ft],[De,R("INSERT")],[Re,()=>"SESSION_USER()"],[Xt,rr],[ht,R("MAKETIME")],[fe,bt("DATE","ADD")],[H,function(t){return this.func("TIMESTAMPDIFF",[qt(t),t.args.expression,t.args.this])}],[de,bt("DATE","SUB")],[_e,R("UNIX_TIMESTAMP")],[Ue,function(t){return Er.call(this,t,{includePrecision:!t.args.zone})}],[k,d(function(t){return this.func("DATE_FORMAT",[t.args.this,this.formatTime(t)])})],[Le,Sr],[me,R("TRUNCATE")],[Fe,ir],[Me,Bt("ADD")],[be,function(t){return this.func("DATEDIFF",[t.args.this,t.args.expression])}],[N,os],[qe,function(t){return`ORD(CONVERT(${this.sql(t.args.this)} USING utf32))`}],[v,Es],[gt,d()],[Rt,d(R("WEEKOFYEAR"))],[Dt,d()],[Ne,R("UTC_TIMESTAMP")],[he,R("UTC_TIME")]])}static get UNSIGNED_TYPE_MAPPING(){return new Map([["ubigint","BIGINT"],["uint","INT"],["umediumint","MEDIUMINT"],["usmallint","SMALLINT"],["utinyint","TINYINT"],["udecimal","DECIMAL"],["udouble","DOUBLE"]])}static get TIMESTAMP_TYPE_MAPPING(){return new Map([["datetime2","DATETIME"],["smalldatetime","DATETIME"],["timestamp","DATETIME"],["timestampntz","DATETIME"],["timestamptz","TIMESTAMP"],["timestampltz","TIMESTAMP"]])}static get TYPE_MAPPING(){let t=new Map(F.TYPE_MAPPING);for(let[e,r]of n.UNSIGNED_TYPE_MAPPING)t.set(e,r);for(let[e,r]of n.TIMESTAMP_TYPE_MAPPING)t.set(e,r);return t.delete("mediumtext"),t.delete("longtext"),t.delete("tinytext"),t.delete("blob"),t.delete("mediumblob"),t.delete("longblob"),t.delete("tinyblob"),t}static get PROPERTIES_LOCATION(){let t=new Map(F.PROPERTIES_LOCATION);return t.set(se,"unsupported"),t.set(ie,"unsupported"),t.set(ee,"unsupported"),t.set(y,"postSchema"),t.set(V,"postSchema"),t}static get CHAR_CAST_MAPPING(){return["longtext","longblob","mediumblob","mediumtext","text","tinyblob","tinytext","varchar"].reduce((t,e)=>({...t,[e]:"CHAR"}),{})}static get SIGNED_CAST_MAPPING(){return["bigint","boolean","int","smallint","tinyint","mediumint"].reduce((t,e)=>({...t,[e]:"SIGNED"}),{})}static get CAST_MAPPING(){return{...n.CHAR_CAST_MAPPING,...n.SIGNED_CAST_MAPPING,ubigint:"UNSIGNED"}}static get TIMESTAMP_FUNC_TYPES(){return new Set(["timestamptz","timestampltz"])}static get RESERVED_KEYWORDS(){return new Set(["accessible","add","all","alter","analyze","and","as","asc","asensitive","before","between","bigint","binary","blob","both","by","call","cascade","case","change","char","character","check","collate","column","condition","constraint","continue","convert","create","cross","cube","cume_dist","current_date","current_time","current_timestamp","current_user","cursor","database","databases","day_hour","day_microsecond","day_minute","day_second","dec","decimal","declare","default","delayed","delete","dense_rank","desc","describe","deterministic","distinct","distinctrow","div","double","drop","dual","each","else","elseif","empty","enclosed","escaped","except","exists","exit","explain","false","fetch","first_value","float","float4","float8","for","force","foreign","from","fulltext","function","generated","get","grant","group","grouping","groups","having","high_priority","hour_microsecond","hour_minute","hour_second","if","ignore","in","index","infile","inner","inout","insensitive","insert","int","int1","int2","int3","int4","int8","integer","intersect","interval","into","io_after_gtids","io_before_gtids","is","iterate","join","json_table","key","keys","kill","lag","last_value","lateral","lead","leading","leave","left","like","limit","linear","lines","load","localtime","localtimestamp","lock","long","longblob","longtext","loop","low_priority","master_bind","master_ssl_verify_server_cert","match","maxvalue","mediumblob","mediumint","mediumtext","middleint","minute_microsecond","minute_second","mod","modifies","natural","not","no_write_to_binlog","nth_value","ntile","undefined","numeric","of","on","optimize","optimizer_costs","option","optionally","or","order","out","outer","outfile","over","partition","percent_rank","precision","primary","procedure","purge","range","rank","read","reads","read_write","real","recursive","references","regexp","release","rename","repeat","replace","require","resignal","restrict","return","revoke","right","rlike","row","rows","row_number","schema","schemas","second_microsecond","select","sensitive","separator","set","show","signal","smallint","spatial","specific","sql","sqlexception","sqlstate","sqlwarning","sql_big_result","sql_calc_found_rows","sql_small_result","ssl","starting","stored","straight_join","system","table","terminated","then","tinyblob","tinyint","tinytext","to","trailing","trigger","true","undo","union","unique","unlock","unsigned","update","usage","use","using","utc_date","utc_time","utc_timestamp","values","varbinary","varchar","varcharacter","varying","virtual","when","where","while","window","with","write","xor","year_month","zerofill"])}locateProperties(t){let e=super.locateProperties(t),r=t.parent;if(r instanceof Kt&&r.args.kind?.toUpperCase()==="VIEW"){let p=e.get("postSchema");if(p){for(let S=0;S<p.length;S++)if(p[S]instanceof re){let[h]=p.splice(S,1),x=this._constructor.SQL_SECURITY_VIEW_LOCATION;e.has(x)||e.set(x,[]),e.get(x).push(h);break}}}return e}computedColumnConstraintSql(t){let e=t.args.persisted?"STORED":"VIRTUAL";return`GENERATED ALWAYS AS (${this.sql(t.args.this?.unnest())}) ${e}`}arraySql(t){return this.unsupported("Arrays are not supported by MySQL"),this.functionFallbackSql(t)}arrayContainsAllSql(t){return this.unsupported("Array operations are not supported by MySQL"),this.functionFallbackSql(t)}dPipeSql(t){return this.func("CONCAT",[...t.flatten()])}extractSql(t){let e=t.name;return e&&e.toLowerCase()==="epoch"?this.func("UNIX_TIMESTAMP",[t.args.expression]):super.extractSql(t)}dataTypeSql(t){if(this.constructor.VARCHAR_REQUIRES_SIZE&&t.isType("varchar")&&!t.args.expressions?.length)return"TEXT";let e=super.dataTypeSql(t);return n.UNSIGNED_TYPE_MAPPING.has(t.args.this)&&(e=`${e} UNSIGNED`),e}jsonArrayContainsSql(t){return`${this.sql(t,"this")} MEMBER OF(${this.sql(t,"expression")})`}castSql(t,e={}){let r=t.args.to;if(r instanceof nt){let p=r.args.this;if(this._constructor.TIMESTAMP_FUNC_TYPES.has(p))return this.func("TIMESTAMP",[t.args.this]);let S=this._constructor.CAST_MAPPING[p];S&&r.setArgKey("this",S)}return super.castSql(t)}showSql(t){let e=` ${t.name}`,r=t.args.full?" FULL":"",p=t.args.global?" GLOBAL":"",S=this.sql(t,"target");S=S?` ${S}`:"",["COLUMNS","INDEX"].includes(t.name)?S=` FROM${S}`:t.name==="GRANTS"?S=` FOR${S}`:["LINKS","PARTITIONS"].includes(t.name)?S=S?` ON${S}`:"":t.name==="PROJECTIONS"&&(S=S?` ON TABLE${S}`:"");let h=this.prefixedSql("FROM",t,"db"),x=this.prefixedSql("LIKE",t,"like"),Z=this.sql(t,"where"),P=this.expressions(t,{key:"types"});P=P&&` ${P}`;let D=this.prefixedSql("FOR QUERY",t,"query"),G="",U="";t.name==="PROFILE"?(G=this.prefixedSql("OFFSET",t,"offset"),U=this.prefixedSql("LIMIT",t,"limit")):U=this.oldStyleLimitSql(t);let j=this.prefixedSql("IN",t,"log"),w=this.prefixedSql("FROM",t,"position"),Y=this.prefixedSql("FOR CHANNEL",t,"channel"),m="";t.name==="ENGINE"&&(m=t.args.mutex?" MUTEX":" STATUS");let _=this.prefixedSql("FOR TABLE",t,"forTable"),L=this.prefixedSql("FOR GROUP",t,"forGroup"),z=this.prefixedSql("FOR USER",t,"forUser"),Q=this.prefixedSql("FOR ROLE",t,"forRole"),tt=this.prefixedSql("INTO OUTFILE",t,"intoOutfile"),et=t.args.json?" JSON":"";return`SHOW${r}${p}${e}${et}${S}${_}${P}${h}${D}${j}${w}${Y}${m}${x}${Z}${G}${U}${L}${z}${Q}${tt}`}alterRenameSql(t,e={}){return super.alterRenameSql(t,{includeTo:!1})}alterColumnSql(t){let e=this.sql(t,"dtype");return e?`MODIFY COLUMN ${this.sql(t,"this")} ${e}`:super.alterColumnSql(t)}prefixedSql(t,e,r){let p=this.sql(e,r);return p?` ${t} ${p}`:""}oldStyleLimitSql(t){let e=this.sql(t,"limit"),r=this.sql(t,"offset");return e?` LIMIT ${r?`${r}, ${e}`:e}`:""}timestampTruncSql(t){let e=t.args.unit,r="0000-01-01 00:00:00",p=Mt(H)([e,new B({this:r,isString:!0}),t.args.this]),S=new Et({this:p,unit:e}),h=W(K)([new B({this:r,isString:!0}),S]);return this.sql(h)}convertTimezoneSql(t){let e=t.args.sourceTz,r=t.args.targetTz,p=t.args.timestamp;return this.func("CONVERT_TZ",[p,e,r])}atTimeZoneSql(t){return this.unsupported("AT TIME ZONE is not supported by MySQL"),this.sql(t.args.this)}isasciiSql(t){return`REGEXP_LIKE(${this.sql(t.args.this)}, '^[[:ascii:]]*$')`}ignoreNullsSql(t){return this.unsupported("MySQL does not support IGNORE NULLS."),this.sql(t.args.this)}currentSchemaSql(t){return ze.call(this,t,"this"),this.func("SCHEMA",[])}partitionSql(t){let e=t.parent;return e instanceof y||e instanceof V?this.expressions(t,{flat:!0}):super.partitionSql(t)}partitionByRangeOrListSql(t,e){let r=this.expressions(t,{key:"partitionExpressions",flat:!0}),p=this.expressions(t,{key:"createExpressions",flat:!0});return`PARTITION BY ${e} (${r}) (${p})`}partitionByRangePropertySql(t){return this.partitionByRangeOrListSql(t,"RANGE")}partitionByListPropertySql(t){return this.partitionByRangeOrListSql(t,"LIST")}partitionListSql(t){let e=this.sql(t,"this"),r=this.expressions(t,{flat:!0});return`PARTITION ${e} VALUES IN (${r})`}partitionRangeSql(t){let e=this.sql(t,"this"),r=this.expressions(t,{flat:!0});return`PARTITION ${e} VALUES LESS THAN (${r})`}};O=M(Zr),E(O,10,"AFTER_HAVING_MODIFIER_TRANSFORMS",Jr,n),E(O,10,"NULL_ORDERING_SUPPORTED",Xr,n),E(O,10,"ORIGINAL_TRANSFORMS",Wr,n),E(O,10,"UNSIGNED_TYPE_MAPPING",$r,n),E(O,10,"TIMESTAMP_TYPE_MAPPING",vr,n),E(O,10,"TYPE_MAPPING",kr,n),E(O,10,"PROPERTIES_LOCATION",Hr,n),E(O,10,"CHAR_CAST_MAPPING",Kr,n),E(O,10,"SIGNED_CAST_MAPPING",Vr,n),E(O,10,"CAST_MAPPING",yr,n),E(O,10,"TIMESTAMP_FUNC_TYPES",Yr,n),E(O,10,"RESERVED_KEYWORDS",wr,n),b(O,n),q(O,3,n),s(n,"MySQLGenerator"),n.SUPPORTS_DECODE_CASE=!1,n.SELECT_KINDS=[],n.TRY_SUPPORTED=!1,n.SUPPORTS_UESCAPE=!1,n.INTERVAL_ALLOWS_PLURAL_FORM=!1,n.LOCKING_READS_SUPPORTED=!0,n.JOIN_HINTS=!1,n.TABLE_HINTS=!0,n.DUPLICATE_KEY_UPDATE_WITH_SET=!1,n.QUERY_HINT_SEP=" ",n.VALUES_AS_TABLE=!1,n.NVL2_SUPPORTED=!1,n.LAST_DAY_SUPPORTS_DATE_PART=!1,n.JSON_TYPE_REQUIRED_FOR_EXTRACTION=!0,n.JSON_PATH_BRACKETED_KEY_SUPPORTED=!1,n.JSON_KEY_VALUE_PAIR_SEP=",",n.SUPPORTS_TO_NUMBER=!1,n.PARSE_JSON_NAME=void 0,n.PAD_FILL_PATTERN_IS_REQUIRED=!0,n.WRAP_DERIVED_VALUES=!1,n.VARCHAR_REQUIRES_SIZE=!0,n.SUPPORTS_MEDIAN=!1,n.UPDATE_STATEMENT_SUPPORTS_FROM=!1,n.SUPPORTS_CONVERT_TIMEZONE=!0,n.SQL_SECURITY_VIEW_LOCATION="postCreate",n.LIMIT_FETCH="LIMIT",n.LIMIT_ONLY_LITERALS=!0;var Yt=n,jr,zr,Qr,ts,es,g,u=class u extends(es=$,ts=[o],Qr=[o],zr=[o],jr=[o],es){static get NORMALIZATION_STRATEGY(){return"caseSensitive"}static get EXPRESSION_METADATA(){return new Map(cr.EXPRESSION_METADATA)}static get TIME_MAPPING(){return{"%M":"%B","%c":"%-m","%e":"%-d","%h":"%I","%i":"%M","%s":"%S","%u":"%W","%k":"%-H","%l":"%-I","%T":"%H:%M:%S","%W":"%A"}}static get VALID_INTERVAL_UNITS(){return new Set([...$.VALID_INTERVAL_UNITS,"SECOND_MICROSECOND","MINUTE_MICROSECOND","MINUTE_SECOND","HOUR_MICROSECOND","HOUR_SECOND","HOUR_MINUTE","DAY_MICROSECOND","DAY_SECOND","DAY_MINUTE","DAY_HOUR","YEAR_MONTH"])}};g=M(es),E(g,10,"NORMALIZATION_STRATEGY",ts,u),E(g,10,"EXPRESSION_METADATA",Qr,u),E(g,10,"TIME_MAPPING",zr,u),E(g,10,"VALID_INTERVAL_UNITS",jr,u),b(g,u),q(g,3,u),s(u,"MySQL"),u.DIALECT_NAME="mysql",u.PROMOTE_TO_INFERRED_DATETIME_TYPE=!0,u.IDENTIFIERS_CAN_START_WITH_DIGIT=!0,u.TIME_FORMAT="'%Y-%m-%d %T'",u.DPIPE_IS_STRING_CONCAT=!1,u.SUPPORTS_USER_DEFINED_TYPES=!1,u.SUPPORTS_SEMI_ANTI_JOIN=!1,u.SAFE_DIVISION=!0,u.SAFE_TO_ELIMINATE_DOUBLE_NEGATION=!1,u.LEAST_GREATEST_IGNORES_NULLS=!1,u.Tokenizer=Gt,u.Parser=wt,u.Generator=Yt;var yt=u;export{i as a,ss as b,is as c,as as d,Ft as e,Es as f,Bt as g,os as h,d as i,yt as j};
2
+ //# sourceMappingURL=chunk-2CLRLOWZ.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVWKXWLP5cjs = require('./chunk-VWKXWLP5.cjs');var N,p;N=[_chunkVWKXWLP5cjs.s];var e=class e{static get EXPRESSION_METADATA(){let n=new Map(_chunkVWKXWLP5cjs.Jv.EXPRESSION_METADATA),s=_chunkVWKXWLP5cjs.a.call(void 0, (r,t)=>{for(let O of r)n.set(O,t)},"extend");return s([_chunkVWKXWLP5cjs.kj,_chunkVWKXWLP5cjs.Uj,_chunkVWKXWLP5cjs.mj,_chunkVWKXWLP5cjs.oj,_chunkVWKXWLP5cjs.wp,_chunkVWKXWLP5cjs.zp,_chunkVWKXWLP5cjs.hr,_chunkVWKXWLP5cjs.as],{returns:"bigint"}),s([_chunkVWKXWLP5cjs.dm,_chunkVWKXWLP5cjs._n,_chunkVWKXWLP5cjs.Gq,_chunkVWKXWLP5cjs.Xq],{annotator:_chunkVWKXWLP5cjs.a.call(void 0, (r,t)=>r.annotateByArgs(t,["this"]),"annotator")}),n.set(_chunkVWKXWLP5cjs.Mj,{annotator:_chunkVWKXWLP5cjs.a.call(void 0, (r,t)=>r.annotateByArgs(t,["this","expression"]),"annotator")}),n.set(_chunkVWKXWLP5cjs.mq,{annotator:_chunkVWKXWLP5cjs.a.call(void 0, (r,t)=>t.args.this?r.annotateByArgs(t,["this"]):r.setType(t,"double"),"annotator")}),n.set(_chunkVWKXWLP5cjs.Rp,{returns:"varbinary"}),n}};p=_chunkVWKXWLP5cjs.b.call(void 0, null),_chunkVWKXWLP5cjs.e.call(void 0, p,10,"EXPRESSION_METADATA",N,e),_chunkVWKXWLP5cjs.c.call(void 0, p,e),_chunkVWKXWLP5cjs.d.call(void 0, p,3,e),_chunkVWKXWLP5cjs.a.call(void 0, e,"PrestoTyping");var I=e;exports.a = I;
2
+ //# sourceMappingURL=chunk-2NBCADTA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/huydna/projects/sqlingo.js/packages/sqlingo/dist/chunk-2NBCADTA.cjs","../src/typing/presto.ts"],"names":["_EXPRESSION_METADATA_dec","_init","cache","_PrestoTyping","map","DialectTyping","extend","__name","types","data","type","BitwiseAndExpr","BitwiseNotExpr","BitwiseOrExpr","BitwiseXorExpr","LengthExpr","LevenshteinExpr","StrPositionExpr","WidthBucketExpr","CeilExpr","FloorExpr","RoundExpr","SignExpr","s","e","ModExpr","RandExpr","Md5DigestExpr","__decoratorStart","__decorateElement","__decoratorMetadata","__runInitializers","PrestoTyping"],"mappings":"AAAA,iIAA2M,ICA3MA,CAAAA,CAAAC,CAAAA,CAqCED,CAAAA,CAAA,CAACE,mBAAAA,CAAAA,CADI,IAAMC,CAAAA,CAAN,MAAMA,CAAa,CAExB,OAAA,IAAW,mBAAA,CAAA,CAA2C,CAEpD,IAAMC,CAAAA,CAA0B,IAAI,GAAA,CAAIC,oBAAAA,CAAc,mBAAmB,CAAA,CAEnEC,CAAAA,CAASC,iCAAAA,CAACC,CAAAA,CAA8BC,CAAAA,CAAAA,EAAkC,CAC9E,GAAA,CAAA,IAAWC,EAAAA,GAAQF,CAAAA,CAAOJ,CAAAA,CAAI,GAAA,CAAIM,CAAAA,CAAMD,CAAI,CAC9C,CAAA,CAFe,QAAA,CAAA,CAIf,OAAAH,CAAAA,CAAO,CACLK,oBAAAA,CACAC,oBAAAA,CACAC,oBAAAA,CACAC,oBAAAA,CACAC,oBAAAA,CACAC,oBAAAA,CACAC,oBAAAA,CACAC,oBACF,CAAA,CAAG,CACD,OAAA,CAAA,QACF,CAAC,CAAA,CAEDZ,CAAAA,CAAO,CACLa,oBAAAA,CACAC,oBAAAA,CACAC,oBAAAA,CACAC,oBACF,CAAA,CAAG,CACD,SAAA,CAAWf,iCAAAA,CAACgB,CAAAA,CAAkBC,CAAAA,CAAAA,EAAkBD,CAAAA,CAAE,cAAA,CAAeC,CAAAA,CAAG,CAAC,MAAM,CAAC,CAAA,CAAjE,WAAA,CACb,CAAC,CAAA,CAEDpB,CAAAA,CAAI,GAAA,CAAIqB,oBAAAA,CAAS,CACf,SAAA,CAAWlB,iCAAAA,CAACgB,CAAAA,CAAkBC,CAAAA,CAAAA,EAAeD,CAAAA,CAAE,cAAA,CAAeC,CAAAA,CAAG,CAC/D,MAAA,CACA,YACF,CAAC,CAAA,CAHU,WAAA,CAIb,CAAC,CAAA,CAEDpB,CAAAA,CAAI,GAAA,CAAIsB,oBAAAA,CAAU,CAChB,SAAA,CAAWnB,iCAAAA,CAACgB,CAAAA,CAAkBC,CAAAA,CAAAA,EAC5BA,CAAAA,CAAE,IAAA,CAAK,IAAA,CACHD,CAAAA,CAAE,cAAA,CAAeC,CAAAA,CAAG,CAAC,MAAM,CAAC,CAAA,CAC5BD,CAAAA,CAAE,OAAA,CAAQC,CAAAA,CAAAA,QAA0B,CAAA,CAH/B,WAAA,CAIb,CAAC,CAAA,CAEDpB,CAAAA,CAAI,GAAA,CAAIuB,oBAAAA,CAAe,CACrB,OAAA,CAAA,WACF,CAAC,CAAA,CAEMvB,CACT,CACF,CAAA,CApDOH,CAAAA,CAAA2B,iCAAAA,IAAA,CAAA,CAELC,iCAAAA,CAAA5B,CAAA,EAAA,CAAW,qBAAA,CADXD,CAAAA,CADWG,CAAAA,CAAAA,CAAN2B,iCAAAA,CAAA7B,CAAME,CAAAA,CAAAA,CAAN4B,iCAAAA,CAAA9B,CAAA,CAAA,CAAME,CAAAA,CAAAA,CAAaI,iCAAAA,CAAAJ,CAAA,cAAA,CAAA,CAAnB,IAAM6B,CAAAA,CAAN7B,CAAAA,CAAAA,cAAAA","file":"/home/huydna/projects/sqlingo.js/packages/sqlingo/dist/chunk-2NBCADTA.cjs","sourcesContent":[null,"import type {\n Expression,\n} from '../expressions/expressions';\nimport {\n cache,\n} from '../port_internals';\nimport {\n DataTypeExprKind,\n} from '../expressions/types';\nimport {\n BitwiseAndExpr,\n BitwiseNotExpr,\n BitwiseOrExpr,\n BitwiseXorExpr,\n LengthExpr,\n LevenshteinExpr,\n StrPositionExpr,\n WidthBucketExpr,\n CeilExpr,\n FloorExpr,\n RoundExpr,\n SignExpr,\n ModExpr,\n RandExpr,\n Md5DigestExpr,\n} from '../expressions/expressions';\nimport type {\n TypeAnnotator,\n} from '../optimizer';\nimport {\n DialectTyping,\n} from './dialect';\nimport type {\n ExpressionMetadata,\n} from './dialect';\n\nexport class PrestoTyping {\n @cache\n static get EXPRESSION_METADATA (): ExpressionMetadata {\n // Clone the base metadata to apply dialect-specific overrides\n const map: ExpressionMetadata = new Map(DialectTyping.EXPRESSION_METADATA);\n\n const extend = (types: (typeof Expression)[], data: Record<string, unknown>) => {\n for (const type of types) map.set(type, data);\n };\n\n extend([\n BitwiseAndExpr,\n BitwiseNotExpr,\n BitwiseOrExpr,\n BitwiseXorExpr,\n LengthExpr,\n LevenshteinExpr,\n StrPositionExpr,\n WidthBucketExpr,\n ], {\n returns: DataTypeExprKind.BIGINT,\n });\n\n extend([\n CeilExpr,\n FloorExpr,\n RoundExpr,\n SignExpr,\n ], {\n annotator: (s: TypeAnnotator, e: Expression) => s.annotateByArgs(e, ['this']),\n });\n\n map.set(ModExpr, {\n annotator: (s: TypeAnnotator, e: ModExpr) => s.annotateByArgs(e, [\n 'this',\n 'expression',\n ]),\n });\n\n map.set(RandExpr, {\n annotator: (s: TypeAnnotator, e: RandExpr) =>\n e.args.this\n ? s.annotateByArgs(e, ['this'])\n : s.setType(e, DataTypeExprKind.DOUBLE),\n });\n\n map.set(Md5DigestExpr, {\n returns: DataTypeExprKind.VARBINARY,\n });\n\n return map;\n }\n}\n"]}