drizzle-orm 0.36.4-14e59f4 → 0.36.4-3c69a1f

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 (971) hide show
  1. package/_relations.cjs +328 -0
  2. package/_relations.cjs.map +1 -0
  3. package/_relations.d.cts +215 -0
  4. package/_relations.d.ts +215 -0
  5. package/_relations.js +316 -0
  6. package/_relations.js.map +1 -0
  7. package/alias.cjs.map +1 -1
  8. package/alias.d.cts +3 -3
  9. package/alias.d.ts +3 -3
  10. package/alias.js.map +1 -1
  11. package/aws-data-api/pg/driver.cjs +19 -5
  12. package/aws-data-api/pg/driver.cjs.map +1 -1
  13. package/aws-data-api/pg/driver.d.cts +9 -8
  14. package/aws-data-api/pg/driver.d.ts +9 -8
  15. package/aws-data-api/pg/driver.js +9 -8
  16. package/aws-data-api/pg/driver.js.map +1 -1
  17. package/aws-data-api/pg/migrator.cjs.map +1 -1
  18. package/aws-data-api/pg/migrator.d.cts +2 -1
  19. package/aws-data-api/pg/migrator.d.ts +2 -1
  20. package/aws-data-api/pg/migrator.js.map +1 -1
  21. package/aws-data-api/pg/session.cjs +67 -4
  22. package/aws-data-api/pg/session.cjs.map +1 -1
  23. package/aws-data-api/pg/session.d.cts +13 -8
  24. package/aws-data-api/pg/session.d.ts +13 -8
  25. package/aws-data-api/pg/session.js +67 -4
  26. package/aws-data-api/pg/session.js.map +1 -1
  27. package/better-sqlite3/driver.cjs +12 -5
  28. package/better-sqlite3/driver.cjs.map +1 -1
  29. package/better-sqlite3/driver.d.cts +7 -6
  30. package/better-sqlite3/driver.d.ts +7 -6
  31. package/better-sqlite3/driver.js +12 -8
  32. package/better-sqlite3/driver.js.map +1 -1
  33. package/better-sqlite3/migrator.cjs.map +1 -1
  34. package/better-sqlite3/migrator.d.cts +2 -1
  35. package/better-sqlite3/migrator.d.ts +2 -1
  36. package/better-sqlite3/migrator.js.map +1 -1
  37. package/better-sqlite3/session.cjs +49 -4
  38. package/better-sqlite3/session.cjs.map +1 -1
  39. package/better-sqlite3/session.d.cts +14 -8
  40. package/better-sqlite3/session.d.ts +14 -8
  41. package/better-sqlite3/session.js +49 -4
  42. package/better-sqlite3/session.js.map +1 -1
  43. package/bun-sqlite/driver.cjs +22 -5
  44. package/bun-sqlite/driver.cjs.map +1 -1
  45. package/bun-sqlite/driver.d.cts +7 -6
  46. package/bun-sqlite/driver.d.ts +7 -6
  47. package/bun-sqlite/driver.js +12 -8
  48. package/bun-sqlite/driver.js.map +1 -1
  49. package/bun-sqlite/migrator.cjs.map +1 -1
  50. package/bun-sqlite/migrator.d.cts +2 -1
  51. package/bun-sqlite/migrator.d.ts +2 -1
  52. package/bun-sqlite/migrator.js.map +1 -1
  53. package/bun-sqlite/session.cjs +49 -4
  54. package/bun-sqlite/session.cjs.map +1 -1
  55. package/bun-sqlite/session.d.cts +14 -8
  56. package/bun-sqlite/session.d.ts +14 -8
  57. package/bun-sqlite/session.js +49 -4
  58. package/bun-sqlite/session.js.map +1 -1
  59. package/column-builder.cjs.map +1 -1
  60. package/column-builder.d.cts +3 -4
  61. package/column-builder.d.ts +3 -4
  62. package/column-builder.js.map +1 -1
  63. package/d1/driver.cjs +22 -5
  64. package/d1/driver.cjs.map +1 -1
  65. package/d1/driver.d.cts +3 -2
  66. package/d1/driver.d.ts +3 -2
  67. package/d1/driver.js +12 -8
  68. package/d1/driver.js.map +1 -1
  69. package/d1/migrator.cjs.map +1 -1
  70. package/d1/migrator.d.cts +2 -1
  71. package/d1/migrator.d.ts +2 -1
  72. package/d1/migrator.js.map +1 -1
  73. package/d1/session.cjs +48 -6
  74. package/d1/session.cjs.map +1 -1
  75. package/d1/session.d.cts +15 -8
  76. package/d1/session.d.ts +15 -8
  77. package/d1/session.js +48 -6
  78. package/d1/session.js.map +1 -1
  79. package/expo-sqlite/driver.cjs +22 -5
  80. package/expo-sqlite/driver.cjs.map +1 -1
  81. package/expo-sqlite/driver.d.cts +3 -2
  82. package/expo-sqlite/driver.d.ts +3 -2
  83. package/expo-sqlite/driver.js +12 -8
  84. package/expo-sqlite/driver.js.map +1 -1
  85. package/expo-sqlite/migrator.cjs.map +1 -1
  86. package/expo-sqlite/migrator.d.cts +3 -2
  87. package/expo-sqlite/migrator.d.ts +3 -2
  88. package/expo-sqlite/migrator.js.map +1 -1
  89. package/expo-sqlite/query.cjs +13 -2
  90. package/expo-sqlite/query.cjs.map +1 -1
  91. package/expo-sqlite/query.d.cts +2 -1
  92. package/expo-sqlite/query.d.ts +2 -1
  93. package/expo-sqlite/query.js +3 -2
  94. package/expo-sqlite/query.js.map +1 -1
  95. package/expo-sqlite/session.cjs +47 -4
  96. package/expo-sqlite/session.cjs.map +1 -1
  97. package/expo-sqlite/session.d.cts +14 -8
  98. package/expo-sqlite/session.d.ts +14 -8
  99. package/expo-sqlite/session.js +47 -4
  100. package/expo-sqlite/session.js.map +1 -1
  101. package/libsql/driver-core.cjs +22 -5
  102. package/libsql/driver-core.cjs.map +1 -1
  103. package/libsql/driver-core.d.cts +2 -1
  104. package/libsql/driver-core.d.ts +2 -1
  105. package/libsql/driver-core.js +12 -8
  106. package/libsql/driver-core.js.map +1 -1
  107. package/libsql/driver.cjs.map +1 -1
  108. package/libsql/driver.d.cts +6 -5
  109. package/libsql/driver.d.ts +6 -5
  110. package/libsql/driver.js.map +1 -1
  111. package/libsql/http/index.cjs.map +1 -1
  112. package/libsql/http/index.d.cts +6 -5
  113. package/libsql/http/index.d.ts +6 -5
  114. package/libsql/http/index.js.map +1 -1
  115. package/libsql/migrator.cjs.map +1 -1
  116. package/libsql/migrator.d.cts +2 -1
  117. package/libsql/migrator.d.ts +2 -1
  118. package/libsql/migrator.js.map +1 -1
  119. package/libsql/node/index.cjs.map +1 -1
  120. package/libsql/node/index.d.cts +6 -5
  121. package/libsql/node/index.d.ts +6 -5
  122. package/libsql/node/index.js.map +1 -1
  123. package/libsql/session.cjs +60 -4
  124. package/libsql/session.cjs.map +1 -1
  125. package/libsql/session.d.cts +15 -9
  126. package/libsql/session.d.ts +15 -9
  127. package/libsql/session.js +60 -4
  128. package/libsql/session.js.map +1 -1
  129. package/libsql/sqlite3/index.cjs.map +1 -1
  130. package/libsql/sqlite3/index.d.cts +6 -5
  131. package/libsql/sqlite3/index.d.ts +6 -5
  132. package/libsql/sqlite3/index.js.map +1 -1
  133. package/libsql/wasm/index.cjs.map +1 -1
  134. package/libsql/wasm/index.d.cts +6 -5
  135. package/libsql/wasm/index.d.ts +6 -5
  136. package/libsql/wasm/index.js.map +1 -1
  137. package/libsql/web/index.cjs.map +1 -1
  138. package/libsql/web/index.d.cts +6 -5
  139. package/libsql/web/index.d.ts +6 -5
  140. package/libsql/web/index.js.map +1 -1
  141. package/libsql/ws/index.cjs.map +1 -1
  142. package/libsql/ws/index.d.cts +6 -5
  143. package/libsql/ws/index.d.ts +6 -5
  144. package/libsql/ws/index.js.map +1 -1
  145. package/mysql-core/db.cjs +29 -8
  146. package/mysql-core/db.cjs.map +1 -1
  147. package/mysql-core/db.d.cts +15 -8
  148. package/mysql-core/db.d.ts +15 -8
  149. package/mysql-core/db.js +28 -7
  150. package/mysql-core/db.js.map +1 -1
  151. package/mysql-core/dialect.cjs +170 -15
  152. package/mysql-core/dialect.cjs.map +1 -1
  153. package/mysql-core/dialect.d.cts +29 -13
  154. package/mysql-core/dialect.d.ts +29 -13
  155. package/mysql-core/dialect.js +167 -21
  156. package/mysql-core/dialect.js.map +1 -1
  157. package/{singlestore-core/query-builders/query.cjs → mysql-core/query-builders/_query.cjs} +41 -18
  158. package/mysql-core/query-builders/_query.cjs.map +1 -0
  159. package/mysql-core/query-builders/_query.d.cts +44 -0
  160. package/mysql-core/query-builders/_query.d.ts +44 -0
  161. package/{singlestore-core/query-builders/query.js → mysql-core/query-builders/_query.js} +29 -18
  162. package/mysql-core/query-builders/_query.js.map +1 -0
  163. package/mysql-core/query-builders/count.cjs.map +1 -1
  164. package/mysql-core/query-builders/count.d.cts +1 -1
  165. package/mysql-core/query-builders/count.d.ts +1 -1
  166. package/mysql-core/query-builders/count.js.map +1 -1
  167. package/mysql-core/query-builders/query.cjs +18 -31
  168. package/mysql-core/query-builders/query.cjs.map +1 -1
  169. package/mysql-core/query-builders/query.d.cts +8 -10
  170. package/mysql-core/query-builders/query.d.ts +8 -10
  171. package/mysql-core/query-builders/query.js +18 -31
  172. package/mysql-core/query-builders/query.js.map +1 -1
  173. package/mysql-core/session.cjs +3 -2
  174. package/mysql-core/session.cjs.map +1 -1
  175. package/mysql-core/session.d.cts +10 -7
  176. package/mysql-core/session.d.ts +10 -7
  177. package/mysql-core/session.js +3 -2
  178. package/mysql-core/session.js.map +1 -1
  179. package/mysql-proxy/driver.cjs +22 -5
  180. package/mysql-proxy/driver.cjs.map +1 -1
  181. package/mysql-proxy/driver.d.cts +3 -2
  182. package/mysql-proxy/driver.d.ts +3 -2
  183. package/mysql-proxy/driver.js +12 -8
  184. package/mysql-proxy/driver.js.map +1 -1
  185. package/mysql-proxy/migrator.cjs.map +1 -1
  186. package/mysql-proxy/migrator.d.cts +2 -1
  187. package/mysql-proxy/migrator.d.ts +2 -1
  188. package/mysql-proxy/migrator.js.map +1 -1
  189. package/mysql-proxy/session.cjs +47 -2
  190. package/mysql-proxy/session.cjs.map +1 -1
  191. package/mysql-proxy/session.d.cts +13 -8
  192. package/mysql-proxy/session.d.ts +13 -8
  193. package/mysql-proxy/session.js +47 -2
  194. package/mysql-proxy/session.js.map +1 -1
  195. package/mysql2/driver.cjs +24 -7
  196. package/mysql2/driver.cjs.map +1 -1
  197. package/mysql2/driver.d.cts +10 -9
  198. package/mysql2/driver.d.ts +10 -9
  199. package/mysql2/driver.js +14 -10
  200. package/mysql2/driver.js.map +1 -1
  201. package/mysql2/migrator.cjs.map +1 -1
  202. package/mysql2/migrator.d.cts +2 -1
  203. package/mysql2/migrator.d.ts +2 -1
  204. package/mysql2/migrator.js.map +1 -1
  205. package/mysql2/session.cjs +51 -2
  206. package/mysql2/session.cjs.map +1 -1
  207. package/mysql2/session.d.cts +13 -8
  208. package/mysql2/session.d.ts +13 -8
  209. package/mysql2/session.js +51 -2
  210. package/mysql2/session.js.map +1 -1
  211. package/neon-http/driver.cjs +22 -8
  212. package/neon-http/driver.cjs.map +1 -1
  213. package/neon-http/driver.d.cts +11 -10
  214. package/neon-http/driver.d.ts +11 -10
  215. package/neon-http/driver.js +12 -8
  216. package/neon-http/driver.js.map +1 -1
  217. package/neon-http/migrator.cjs.map +1 -1
  218. package/neon-http/migrator.d.cts +2 -1
  219. package/neon-http/migrator.d.ts +2 -1
  220. package/neon-http/migrator.js.map +1 -1
  221. package/neon-http/session.cjs +32 -2
  222. package/neon-http/session.cjs.map +1 -1
  223. package/neon-http/session.d.cts +13 -8
  224. package/neon-http/session.d.ts +13 -8
  225. package/neon-http/session.js +32 -2
  226. package/neon-http/session.js.map +1 -1
  227. package/neon-serverless/driver.cjs +18 -7
  228. package/neon-serverless/driver.cjs.map +1 -1
  229. package/neon-serverless/driver.d.cts +9 -8
  230. package/neon-serverless/driver.d.ts +9 -8
  231. package/neon-serverless/driver.js +8 -10
  232. package/neon-serverless/driver.js.map +1 -1
  233. package/neon-serverless/migrator.cjs.map +1 -1
  234. package/neon-serverless/migrator.d.cts +2 -1
  235. package/neon-serverless/migrator.d.ts +2 -1
  236. package/neon-serverless/migrator.js.map +1 -1
  237. package/neon-serverless/session.cjs +40 -5
  238. package/neon-serverless/session.cjs.map +1 -1
  239. package/neon-serverless/session.d.cts +13 -8
  240. package/neon-serverless/session.d.ts +13 -8
  241. package/neon-serverless/session.js +40 -5
  242. package/neon-serverless/session.js.map +1 -1
  243. package/node-postgres/driver.cjs +13 -7
  244. package/node-postgres/driver.cjs.map +1 -1
  245. package/node-postgres/driver.d.cts +9 -8
  246. package/node-postgres/driver.d.ts +9 -8
  247. package/node-postgres/driver.js +13 -10
  248. package/node-postgres/driver.js.map +1 -1
  249. package/node-postgres/migrator.cjs.map +1 -1
  250. package/node-postgres/migrator.d.cts +2 -1
  251. package/node-postgres/migrator.d.ts +2 -1
  252. package/node-postgres/migrator.js.map +1 -1
  253. package/node-postgres/session.cjs +45 -4
  254. package/node-postgres/session.cjs.map +1 -1
  255. package/node-postgres/session.d.cts +13 -8
  256. package/node-postgres/session.d.ts +13 -8
  257. package/node-postgres/session.js +45 -4
  258. package/node-postgres/session.js.map +1 -1
  259. package/op-sqlite/driver.cjs +22 -5
  260. package/op-sqlite/driver.cjs.map +1 -1
  261. package/op-sqlite/driver.d.cts +3 -2
  262. package/op-sqlite/driver.d.ts +3 -2
  263. package/op-sqlite/driver.js +12 -8
  264. package/op-sqlite/driver.js.map +1 -1
  265. package/op-sqlite/migrator.cjs.map +1 -1
  266. package/op-sqlite/migrator.d.cts +3 -2
  267. package/op-sqlite/migrator.d.ts +3 -2
  268. package/op-sqlite/migrator.js.map +1 -1
  269. package/op-sqlite/session.cjs +47 -4
  270. package/op-sqlite/session.cjs.map +1 -1
  271. package/op-sqlite/session.d.cts +14 -8
  272. package/op-sqlite/session.d.ts +14 -8
  273. package/op-sqlite/session.js +47 -4
  274. package/op-sqlite/session.js.map +1 -1
  275. package/package.json +65 -798
  276. package/pg-core/db.cjs +31 -7
  277. package/pg-core/db.cjs.map +1 -1
  278. package/pg-core/db.d.cts +18 -11
  279. package/pg-core/db.d.ts +18 -11
  280. package/pg-core/db.js +30 -6
  281. package/pg-core/db.js.map +1 -1
  282. package/pg-core/dialect.cjs +146 -488
  283. package/pg-core/dialect.cjs.map +1 -1
  284. package/pg-core/dialect.d.cts +21 -7
  285. package/pg-core/dialect.d.ts +21 -7
  286. package/pg-core/dialect.js +143 -494
  287. package/pg-core/dialect.js.map +1 -1
  288. package/pg-core/query-builders/_query.cjs +155 -0
  289. package/pg-core/query-builders/_query.cjs.map +1 -0
  290. package/pg-core/query-builders/_query.d.cts +47 -0
  291. package/pg-core/query-builders/_query.d.ts +47 -0
  292. package/pg-core/query-builders/_query.js +120 -0
  293. package/pg-core/query-builders/_query.js.map +1 -0
  294. package/pg-core/query-builders/count.cjs +0 -1
  295. package/pg-core/query-builders/count.cjs.map +1 -1
  296. package/pg-core/query-builders/count.d.cts +2 -3
  297. package/pg-core/query-builders/count.d.ts +2 -3
  298. package/pg-core/query-builders/count.js +0 -1
  299. package/pg-core/query-builders/count.js.map +1 -1
  300. package/pg-core/query-builders/delete.cjs.map +1 -1
  301. package/pg-core/query-builders/delete.js.map +1 -1
  302. package/pg-core/query-builders/insert.cjs +9 -1
  303. package/pg-core/query-builders/insert.cjs.map +1 -1
  304. package/pg-core/query-builders/insert.js +9 -1
  305. package/pg-core/query-builders/insert.js.map +1 -1
  306. package/pg-core/query-builders/query.cjs +15 -18
  307. package/pg-core/query-builders/query.cjs.map +1 -1
  308. package/pg-core/query-builders/query.d.cts +6 -6
  309. package/pg-core/query-builders/query.d.ts +6 -6
  310. package/pg-core/query-builders/query.js +15 -18
  311. package/pg-core/query-builders/query.js.map +1 -1
  312. package/pg-core/query-builders/refresh-materialized-view.cjs.map +1 -1
  313. package/pg-core/query-builders/refresh-materialized-view.js.map +1 -1
  314. package/pg-core/query-builders/select.cjs +10 -2
  315. package/pg-core/query-builders/select.cjs.map +1 -1
  316. package/pg-core/query-builders/select.js +11 -8
  317. package/pg-core/query-builders/select.js.map +1 -1
  318. package/pg-core/query-builders/update.cjs +7 -1
  319. package/pg-core/query-builders/update.cjs.map +1 -1
  320. package/pg-core/query-builders/update.d.cts +2 -2
  321. package/pg-core/query-builders/update.d.ts +2 -2
  322. package/pg-core/query-builders/update.js +8 -6
  323. package/pg-core/query-builders/update.js.map +1 -1
  324. package/pg-core/session.cjs +3 -2
  325. package/pg-core/session.cjs.map +1 -1
  326. package/pg-core/session.d.cts +10 -8
  327. package/pg-core/session.d.ts +10 -8
  328. package/pg-core/session.js +3 -2
  329. package/pg-core/session.js.map +1 -1
  330. package/pg-proxy/driver.cjs +21 -5
  331. package/pg-proxy/driver.cjs.map +1 -1
  332. package/pg-proxy/driver.d.cts +3 -2
  333. package/pg-proxy/driver.d.ts +3 -2
  334. package/pg-proxy/driver.js +11 -8
  335. package/pg-proxy/driver.js.map +1 -1
  336. package/pg-proxy/migrator.cjs.map +1 -1
  337. package/pg-proxy/migrator.d.cts +2 -1
  338. package/pg-proxy/migrator.d.ts +2 -1
  339. package/pg-proxy/migrator.js.map +1 -1
  340. package/pg-proxy/session.cjs +37 -2
  341. package/pg-proxy/session.cjs.map +1 -1
  342. package/pg-proxy/session.d.cts +13 -8
  343. package/pg-proxy/session.d.ts +13 -8
  344. package/pg-proxy/session.js +37 -2
  345. package/pg-proxy/session.js.map +1 -1
  346. package/pglite/driver.cjs +23 -7
  347. package/pglite/driver.cjs.map +1 -1
  348. package/pglite/driver.d.cts +9 -8
  349. package/pglite/driver.d.ts +9 -8
  350. package/pglite/driver.js +13 -10
  351. package/pglite/driver.js.map +1 -1
  352. package/pglite/migrator.cjs.map +1 -1
  353. package/pglite/migrator.d.cts +2 -1
  354. package/pglite/migrator.d.ts +2 -1
  355. package/pglite/migrator.js.map +1 -1
  356. package/pglite/session.cjs +34 -3
  357. package/pglite/session.cjs.map +1 -1
  358. package/pglite/session.d.cts +13 -8
  359. package/pglite/session.d.ts +13 -8
  360. package/pglite/session.js +34 -3
  361. package/pglite/session.js.map +1 -1
  362. package/planetscale-serverless/driver.cjs +22 -5
  363. package/planetscale-serverless/driver.cjs.map +1 -1
  364. package/planetscale-serverless/driver.d.cts +7 -6
  365. package/planetscale-serverless/driver.d.ts +7 -6
  366. package/planetscale-serverless/driver.js +12 -8
  367. package/planetscale-serverless/driver.js.map +1 -1
  368. package/planetscale-serverless/migrator.cjs.map +1 -1
  369. package/planetscale-serverless/migrator.d.cts +2 -1
  370. package/planetscale-serverless/migrator.d.ts +2 -1
  371. package/planetscale-serverless/migrator.js.map +1 -1
  372. package/planetscale-serverless/session.cjs +68 -5
  373. package/planetscale-serverless/session.cjs.map +1 -1
  374. package/planetscale-serverless/session.d.cts +14 -9
  375. package/planetscale-serverless/session.d.ts +14 -9
  376. package/planetscale-serverless/session.js +68 -5
  377. package/planetscale-serverless/session.js.map +1 -1
  378. package/postgres-js/driver.cjs +12 -6
  379. package/postgres-js/driver.cjs.map +1 -1
  380. package/postgres-js/driver.d.cts +7 -6
  381. package/postgres-js/driver.d.ts +7 -6
  382. package/postgres-js/driver.js +12 -9
  383. package/postgres-js/driver.js.map +1 -1
  384. package/postgres-js/migrator.cjs.map +1 -1
  385. package/postgres-js/migrator.d.cts +2 -1
  386. package/postgres-js/migrator.d.ts +2 -1
  387. package/postgres-js/migrator.js.map +1 -1
  388. package/postgres-js/session.cjs +51 -6
  389. package/postgres-js/session.cjs.map +1 -1
  390. package/postgres-js/session.d.cts +15 -9
  391. package/postgres-js/session.d.ts +15 -9
  392. package/postgres-js/session.js +51 -6
  393. package/postgres-js/session.js.map +1 -1
  394. package/prisma/mysql/driver.cjs +1 -1
  395. package/prisma/mysql/driver.cjs.map +1 -1
  396. package/prisma/mysql/driver.js +1 -1
  397. package/prisma/mysql/driver.js.map +1 -1
  398. package/prisma/mysql/session.cjs +3 -0
  399. package/prisma/mysql/session.cjs.map +1 -1
  400. package/prisma/mysql/session.d.cts +3 -1
  401. package/prisma/mysql/session.d.ts +3 -1
  402. package/prisma/mysql/session.js +3 -0
  403. package/prisma/mysql/session.js.map +1 -1
  404. package/prisma/pg/driver.cjs +1 -1
  405. package/prisma/pg/driver.cjs.map +1 -1
  406. package/prisma/pg/driver.js +1 -1
  407. package/prisma/pg/driver.js.map +1 -1
  408. package/prisma/pg/session.cjs +3 -0
  409. package/prisma/pg/session.cjs.map +1 -1
  410. package/prisma/pg/session.d.cts +3 -1
  411. package/prisma/pg/session.d.ts +3 -1
  412. package/prisma/pg/session.js +3 -0
  413. package/prisma/pg/session.js.map +1 -1
  414. package/prisma/sqlite/driver.cjs +1 -1
  415. package/prisma/sqlite/driver.cjs.map +1 -1
  416. package/prisma/sqlite/driver.js +1 -1
  417. package/prisma/sqlite/driver.js.map +1 -1
  418. package/prisma/sqlite/session.cjs +3 -0
  419. package/prisma/sqlite/session.cjs.map +1 -1
  420. package/prisma/sqlite/session.d.cts +4 -2
  421. package/prisma/sqlite/session.d.ts +4 -2
  422. package/prisma/sqlite/session.js +3 -0
  423. package/prisma/sqlite/session.js.map +1 -1
  424. package/relations.cjs +468 -245
  425. package/relations.cjs.map +1 -1
  426. package/relations.d.cts +264 -125
  427. package/relations.d.ts +264 -125
  428. package/relations.js +455 -238
  429. package/relations.js.map +1 -1
  430. package/sql/sql.cjs.map +1 -1
  431. package/sql/sql.d.cts +4 -4
  432. package/sql/sql.d.ts +4 -4
  433. package/sql/sql.js.map +1 -1
  434. package/sql-js/driver.cjs +16 -5
  435. package/sql-js/driver.cjs.map +1 -1
  436. package/sql-js/driver.d.cts +3 -2
  437. package/sql-js/driver.d.ts +3 -2
  438. package/sql-js/driver.js +6 -8
  439. package/sql-js/driver.js.map +1 -1
  440. package/sql-js/migrator.cjs.map +1 -1
  441. package/sql-js/migrator.d.cts +2 -1
  442. package/sql-js/migrator.d.ts +2 -1
  443. package/sql-js/migrator.js.map +1 -1
  444. package/sql-js/session.cjs +58 -4
  445. package/sql-js/session.cjs.map +1 -1
  446. package/sql-js/session.d.cts +14 -8
  447. package/sql-js/session.d.ts +14 -8
  448. package/sql-js/session.js +58 -4
  449. package/sql-js/session.js.map +1 -1
  450. package/sqlite-core/columns/blob.cjs +2 -16
  451. package/sqlite-core/columns/blob.cjs.map +1 -1
  452. package/sqlite-core/columns/blob.d.cts +2 -2
  453. package/sqlite-core/columns/blob.d.ts +2 -2
  454. package/sqlite-core/columns/blob.js +2 -16
  455. package/sqlite-core/columns/blob.js.map +1 -1
  456. package/sqlite-core/db.cjs +35 -14
  457. package/sqlite-core/db.cjs.map +1 -1
  458. package/sqlite-core/db.d.cts +15 -8
  459. package/sqlite-core/db.d.ts +15 -8
  460. package/sqlite-core/db.js +34 -13
  461. package/sqlite-core/db.js.map +1 -1
  462. package/sqlite-core/dialect.cjs +164 -7
  463. package/sqlite-core/dialect.cjs.map +1 -1
  464. package/sqlite-core/dialect.d.cts +25 -9
  465. package/sqlite-core/dialect.d.ts +25 -9
  466. package/sqlite-core/dialect.js +161 -13
  467. package/sqlite-core/dialect.js.map +1 -1
  468. package/sqlite-core/query-builders/_query.cjs +187 -0
  469. package/sqlite-core/query-builders/_query.cjs.map +1 -0
  470. package/sqlite-core/query-builders/_query.d.cts +55 -0
  471. package/sqlite-core/query-builders/_query.d.ts +55 -0
  472. package/sqlite-core/query-builders/_query.js +151 -0
  473. package/sqlite-core/query-builders/_query.js.map +1 -0
  474. package/sqlite-core/query-builders/count.cjs.map +1 -1
  475. package/sqlite-core/query-builders/count.d.cts +1 -1
  476. package/sqlite-core/query-builders/count.d.ts +1 -1
  477. package/sqlite-core/query-builders/count.js.map +1 -1
  478. package/sqlite-core/query-builders/delete.cjs.map +1 -1
  479. package/sqlite-core/query-builders/delete.d.cts +1 -1
  480. package/sqlite-core/query-builders/delete.d.ts +1 -1
  481. package/sqlite-core/query-builders/delete.js.map +1 -1
  482. package/sqlite-core/query-builders/insert.cjs.map +1 -1
  483. package/sqlite-core/query-builders/insert.d.cts +3 -3
  484. package/sqlite-core/query-builders/insert.d.ts +3 -3
  485. package/sqlite-core/query-builders/insert.js.map +1 -1
  486. package/sqlite-core/query-builders/query.cjs +30 -48
  487. package/sqlite-core/query-builders/query.cjs.map +1 -1
  488. package/sqlite-core/query-builders/query.d.cts +14 -16
  489. package/sqlite-core/query-builders/query.d.ts +14 -16
  490. package/sqlite-core/query-builders/query.js +30 -48
  491. package/sqlite-core/query-builders/query.js.map +1 -1
  492. package/sqlite-core/query-builders/select.cjs.map +1 -1
  493. package/sqlite-core/query-builders/select.d.cts +3 -3
  494. package/sqlite-core/query-builders/select.d.ts +3 -3
  495. package/sqlite-core/query-builders/select.js.map +1 -1
  496. package/sqlite-core/query-builders/update.cjs.map +1 -1
  497. package/sqlite-core/query-builders/update.d.cts +3 -3
  498. package/sqlite-core/query-builders/update.d.ts +3 -3
  499. package/sqlite-core/query-builders/update.js.map +1 -1
  500. package/sqlite-core/session.cjs +6 -2
  501. package/sqlite-core/session.cjs.map +1 -1
  502. package/sqlite-core/session.d.cts +14 -6
  503. package/sqlite-core/session.d.ts +14 -6
  504. package/sqlite-core/session.js +6 -2
  505. package/sqlite-core/session.js.map +1 -1
  506. package/sqlite-proxy/driver.cjs +22 -5
  507. package/sqlite-proxy/driver.cjs.map +1 -1
  508. package/sqlite-proxy/driver.d.cts +4 -3
  509. package/sqlite-proxy/driver.d.ts +4 -3
  510. package/sqlite-proxy/driver.js +12 -5
  511. package/sqlite-proxy/driver.js.map +1 -1
  512. package/sqlite-proxy/migrator.cjs.map +1 -1
  513. package/sqlite-proxy/migrator.d.cts +2 -1
  514. package/sqlite-proxy/migrator.d.ts +2 -1
  515. package/sqlite-proxy/migrator.js.map +1 -1
  516. package/sqlite-proxy/session.cjs +47 -4
  517. package/sqlite-proxy/session.cjs.map +1 -1
  518. package/sqlite-proxy/session.d.cts +14 -8
  519. package/sqlite-proxy/session.d.ts +14 -8
  520. package/sqlite-proxy/session.js +47 -4
  521. package/sqlite-proxy/session.js.map +1 -1
  522. package/table.cjs.map +1 -1
  523. package/table.d.cts +1 -1
  524. package/table.d.ts +1 -1
  525. package/table.js.map +1 -1
  526. package/tidb-serverless/driver.cjs +22 -5
  527. package/tidb-serverless/driver.cjs.map +1 -1
  528. package/tidb-serverless/driver.d.cts +7 -6
  529. package/tidb-serverless/driver.d.ts +7 -6
  530. package/tidb-serverless/driver.js +12 -8
  531. package/tidb-serverless/driver.js.map +1 -1
  532. package/tidb-serverless/migrator.cjs.map +1 -1
  533. package/tidb-serverless/migrator.d.cts +2 -1
  534. package/tidb-serverless/migrator.d.ts +2 -1
  535. package/tidb-serverless/migrator.js.map +1 -1
  536. package/tidb-serverless/session.cjs +62 -5
  537. package/tidb-serverless/session.cjs.map +1 -1
  538. package/tidb-serverless/session.d.cts +14 -9
  539. package/tidb-serverless/session.d.ts +14 -9
  540. package/tidb-serverless/session.js +62 -5
  541. package/tidb-serverless/session.js.map +1 -1
  542. package/utils.cjs +2 -2
  543. package/utils.cjs.map +1 -1
  544. package/utils.d.cts +3 -2
  545. package/utils.d.ts +3 -2
  546. package/utils.js +2 -2
  547. package/utils.js.map +1 -1
  548. package/vercel-postgres/driver.cjs +23 -7
  549. package/vercel-postgres/driver.cjs.map +1 -1
  550. package/vercel-postgres/driver.d.cts +9 -8
  551. package/vercel-postgres/driver.d.ts +9 -8
  552. package/vercel-postgres/driver.js +13 -10
  553. package/vercel-postgres/driver.js.map +1 -1
  554. package/vercel-postgres/migrator.cjs.map +1 -1
  555. package/vercel-postgres/migrator.d.cts +2 -1
  556. package/vercel-postgres/migrator.d.ts +2 -1
  557. package/vercel-postgres/migrator.js.map +1 -1
  558. package/vercel-postgres/session.cjs +34 -4
  559. package/vercel-postgres/session.cjs.map +1 -1
  560. package/vercel-postgres/session.d.cts +13 -8
  561. package/vercel-postgres/session.d.ts +13 -8
  562. package/vercel-postgres/session.js +34 -4
  563. package/vercel-postgres/session.js.map +1 -1
  564. package/version.cjs +1 -1
  565. package/version.d.cts +1 -1
  566. package/version.d.ts +1 -1
  567. package/version.js +1 -1
  568. package/xata-http/driver.cjs +17 -5
  569. package/xata-http/driver.cjs.map +1 -1
  570. package/xata-http/driver.d.cts +5 -4
  571. package/xata-http/driver.d.ts +5 -4
  572. package/xata-http/driver.js +7 -5
  573. package/xata-http/driver.js.map +1 -1
  574. package/xata-http/migrator.cjs.map +1 -1
  575. package/xata-http/migrator.d.cts +2 -1
  576. package/xata-http/migrator.d.ts +2 -1
  577. package/xata-http/migrator.js.map +1 -1
  578. package/xata-http/session.cjs +30 -2
  579. package/xata-http/session.cjs.map +1 -1
  580. package/xata-http/session.d.cts +13 -8
  581. package/xata-http/session.d.ts +13 -8
  582. package/xata-http/session.js +30 -2
  583. package/xata-http/session.js.map +1 -1
  584. package/durable-sqlite/driver.cjs +0 -64
  585. package/durable-sqlite/driver.cjs.map +0 -1
  586. package/durable-sqlite/driver.d.cts +0 -9
  587. package/durable-sqlite/driver.d.ts +0 -9
  588. package/durable-sqlite/driver.js +0 -42
  589. package/durable-sqlite/driver.js.map +0 -1
  590. package/durable-sqlite/index.cjs +0 -25
  591. package/durable-sqlite/index.cjs.map +0 -1
  592. package/durable-sqlite/index.d.cts +0 -2
  593. package/durable-sqlite/index.d.ts +0 -2
  594. package/durable-sqlite/index.js +0 -3
  595. package/durable-sqlite/index.js.map +0 -1
  596. package/durable-sqlite/migrator.cjs +0 -85
  597. package/durable-sqlite/migrator.cjs.map +0 -1
  598. package/durable-sqlite/migrator.d.cts +0 -14
  599. package/durable-sqlite/migrator.d.ts +0 -14
  600. package/durable-sqlite/migrator.js +0 -61
  601. package/durable-sqlite/migrator.js.map +0 -1
  602. package/durable-sqlite/session.cjs +0 -131
  603. package/durable-sqlite/session.cjs.map +0 -1
  604. package/durable-sqlite/session.d.cts +0 -46
  605. package/durable-sqlite/session.d.ts +0 -46
  606. package/durable-sqlite/session.js +0 -107
  607. package/durable-sqlite/session.js.map +0 -1
  608. package/singlestore/driver.cjs +0 -113
  609. package/singlestore/driver.cjs.map +0 -1
  610. package/singlestore/driver.d.cts +0 -52
  611. package/singlestore/driver.d.ts +0 -52
  612. package/singlestore/driver.js +0 -89
  613. package/singlestore/driver.js.map +0 -1
  614. package/singlestore/index.cjs +0 -25
  615. package/singlestore/index.cjs.map +0 -1
  616. package/singlestore/index.d.cts +0 -2
  617. package/singlestore/index.d.ts +0 -2
  618. package/singlestore/index.js +0 -3
  619. package/singlestore/index.js.map +0 -1
  620. package/singlestore/migrator.cjs +0 -33
  621. package/singlestore/migrator.cjs.map +0 -1
  622. package/singlestore/migrator.d.cts +0 -3
  623. package/singlestore/migrator.d.ts +0 -3
  624. package/singlestore/migrator.js +0 -9
  625. package/singlestore/migrator.js.map +0 -1
  626. package/singlestore/session.cjs +0 -258
  627. package/singlestore/session.cjs.map +0 -1
  628. package/singlestore/session.d.cts +0 -52
  629. package/singlestore/session.d.ts +0 -52
  630. package/singlestore/session.js +0 -236
  631. package/singlestore/session.js.map +0 -1
  632. package/singlestore-core/alias.cjs +0 -32
  633. package/singlestore-core/alias.cjs.map +0 -1
  634. package/singlestore-core/alias.d.cts +0 -4
  635. package/singlestore-core/alias.d.ts +0 -4
  636. package/singlestore-core/alias.js +0 -8
  637. package/singlestore-core/alias.js.map +0 -1
  638. package/singlestore-core/columns/all.cjs +0 -80
  639. package/singlestore-core/columns/all.cjs.map +0 -1
  640. package/singlestore-core/columns/all.d.cts +0 -51
  641. package/singlestore-core/columns/all.d.ts +0 -51
  642. package/singlestore-core/columns/all.js +0 -56
  643. package/singlestore-core/columns/all.js.map +0 -1
  644. package/singlestore-core/columns/bigint.cjs +0 -96
  645. package/singlestore-core/columns/bigint.cjs.map +0 -1
  646. package/singlestore-core/columns/bigint.d.cts +0 -54
  647. package/singlestore-core/columns/bigint.d.ts +0 -54
  648. package/singlestore-core/columns/bigint.js +0 -68
  649. package/singlestore-core/columns/bigint.js.map +0 -1
  650. package/singlestore-core/columns/binary.cjs +0 -60
  651. package/singlestore-core/columns/binary.cjs.map +0 -1
  652. package/singlestore-core/columns/binary.d.cts +0 -28
  653. package/singlestore-core/columns/binary.d.ts +0 -28
  654. package/singlestore-core/columns/binary.js +0 -34
  655. package/singlestore-core/columns/binary.js.map +0 -1
  656. package/singlestore-core/columns/boolean.cjs +0 -62
  657. package/singlestore-core/columns/boolean.cjs.map +0 -1
  658. package/singlestore-core/columns/boolean.d.cts +0 -24
  659. package/singlestore-core/columns/boolean.d.ts +0 -24
  660. package/singlestore-core/columns/boolean.js +0 -36
  661. package/singlestore-core/columns/boolean.js.map +0 -1
  662. package/singlestore-core/columns/char.cjs +0 -62
  663. package/singlestore-core/columns/char.cjs.map +0 -1
  664. package/singlestore-core/columns/char.d.cts +0 -31
  665. package/singlestore-core/columns/char.d.ts +0 -31
  666. package/singlestore-core/columns/char.js +0 -36
  667. package/singlestore-core/columns/char.js.map +0 -1
  668. package/singlestore-core/columns/common.cjs +0 -82
  669. package/singlestore-core/columns/common.cjs.map +0 -1
  670. package/singlestore-core/columns/common.d.cts +0 -42
  671. package/singlestore-core/columns/common.d.ts +0 -42
  672. package/singlestore-core/columns/common.js +0 -55
  673. package/singlestore-core/columns/common.js.map +0 -1
  674. package/singlestore-core/columns/custom.cjs +0 -77
  675. package/singlestore-core/columns/custom.cjs.map +0 -1
  676. package/singlestore-core/columns/custom.d.cts +0 -156
  677. package/singlestore-core/columns/custom.d.ts +0 -156
  678. package/singlestore-core/columns/custom.js +0 -51
  679. package/singlestore-core/columns/custom.js.map +0 -1
  680. package/singlestore-core/columns/date.cjs +0 -93
  681. package/singlestore-core/columns/date.cjs.map +0 -1
  682. package/singlestore-core/columns/date.common.cjs +0 -48
  683. package/singlestore-core/columns/date.common.cjs.map +0 -1
  684. package/singlestore-core/columns/date.common.d.cts +0 -16
  685. package/singlestore-core/columns/date.common.d.ts +0 -16
  686. package/singlestore-core/columns/date.common.js +0 -23
  687. package/singlestore-core/columns/date.common.js.map +0 -1
  688. package/singlestore-core/columns/date.d.cts +0 -53
  689. package/singlestore-core/columns/date.d.ts +0 -53
  690. package/singlestore-core/columns/date.js +0 -65
  691. package/singlestore-core/columns/date.js.map +0 -1
  692. package/singlestore-core/columns/datetime.cjs +0 -106
  693. package/singlestore-core/columns/datetime.cjs.map +0 -1
  694. package/singlestore-core/columns/datetime.d.cts +0 -54
  695. package/singlestore-core/columns/datetime.d.ts +0 -54
  696. package/singlestore-core/columns/datetime.js +0 -78
  697. package/singlestore-core/columns/datetime.js.map +0 -1
  698. package/singlestore-core/columns/decimal.cjs +0 -76
  699. package/singlestore-core/columns/decimal.cjs.map +0 -1
  700. package/singlestore-core/columns/decimal.d.cts +0 -32
  701. package/singlestore-core/columns/decimal.d.ts +0 -32
  702. package/singlestore-core/columns/decimal.js +0 -50
  703. package/singlestore-core/columns/decimal.js.map +0 -1
  704. package/singlestore-core/columns/double.cjs +0 -72
  705. package/singlestore-core/columns/double.cjs.map +0 -1
  706. package/singlestore-core/columns/double.d.cts +0 -32
  707. package/singlestore-core/columns/double.d.ts +0 -32
  708. package/singlestore-core/columns/double.js +0 -46
  709. package/singlestore-core/columns/double.js.map +0 -1
  710. package/singlestore-core/columns/enum.cjs +0 -67
  711. package/singlestore-core/columns/enum.cjs.map +0 -1
  712. package/singlestore-core/columns/enum.d.cts +0 -31
  713. package/singlestore-core/columns/enum.d.ts +0 -31
  714. package/singlestore-core/columns/enum.js +0 -41
  715. package/singlestore-core/columns/enum.js.map +0 -1
  716. package/singlestore-core/columns/float.cjs +0 -72
  717. package/singlestore-core/columns/float.cjs.map +0 -1
  718. package/singlestore-core/columns/float.d.cts +0 -32
  719. package/singlestore-core/columns/float.d.ts +0 -32
  720. package/singlestore-core/columns/float.js +0 -46
  721. package/singlestore-core/columns/float.js.map +0 -1
  722. package/singlestore-core/columns/index.cjs +0 -71
  723. package/singlestore-core/columns/index.cjs.map +0 -1
  724. package/singlestore-core/columns/index.d.cts +0 -25
  725. package/singlestore-core/columns/index.d.ts +0 -25
  726. package/singlestore-core/columns/index.js +0 -26
  727. package/singlestore-core/columns/index.js.map +0 -1
  728. package/singlestore-core/columns/int.cjs +0 -65
  729. package/singlestore-core/columns/int.cjs.map +0 -1
  730. package/singlestore-core/columns/int.d.cts +0 -28
  731. package/singlestore-core/columns/int.d.ts +0 -28
  732. package/singlestore-core/columns/int.js +0 -39
  733. package/singlestore-core/columns/int.js.map +0 -1
  734. package/singlestore-core/columns/json.cjs +0 -59
  735. package/singlestore-core/columns/json.cjs.map +0 -1
  736. package/singlestore-core/columns/json.d.cts +0 -24
  737. package/singlestore-core/columns/json.d.ts +0 -24
  738. package/singlestore-core/columns/json.js +0 -33
  739. package/singlestore-core/columns/json.js.map +0 -1
  740. package/singlestore-core/columns/mediumint.cjs +0 -65
  741. package/singlestore-core/columns/mediumint.cjs.map +0 -1
  742. package/singlestore-core/columns/mediumint.d.cts +0 -26
  743. package/singlestore-core/columns/mediumint.d.ts +0 -26
  744. package/singlestore-core/columns/mediumint.js +0 -39
  745. package/singlestore-core/columns/mediumint.js.map +0 -1
  746. package/singlestore-core/columns/real.cjs +0 -68
  747. package/singlestore-core/columns/real.cjs.map +0 -1
  748. package/singlestore-core/columns/real.d.cts +0 -30
  749. package/singlestore-core/columns/real.d.ts +0 -30
  750. package/singlestore-core/columns/real.js +0 -42
  751. package/singlestore-core/columns/real.js.map +0 -1
  752. package/singlestore-core/columns/serial.cjs +0 -64
  753. package/singlestore-core/columns/serial.cjs.map +0 -1
  754. package/singlestore-core/columns/serial.d.cts +0 -24
  755. package/singlestore-core/columns/serial.d.ts +0 -24
  756. package/singlestore-core/columns/serial.js +0 -38
  757. package/singlestore-core/columns/serial.js.map +0 -1
  758. package/singlestore-core/columns/smallint.cjs +0 -65
  759. package/singlestore-core/columns/smallint.cjs.map +0 -1
  760. package/singlestore-core/columns/smallint.d.cts +0 -26
  761. package/singlestore-core/columns/smallint.d.ts +0 -26
  762. package/singlestore-core/columns/smallint.js +0 -39
  763. package/singlestore-core/columns/smallint.js.map +0 -1
  764. package/singlestore-core/columns/text.cjs +0 -80
  765. package/singlestore-core/columns/text.cjs.map +0 -1
  766. package/singlestore-core/columns/text.d.cts +0 -46
  767. package/singlestore-core/columns/text.d.ts +0 -46
  768. package/singlestore-core/columns/text.js +0 -51
  769. package/singlestore-core/columns/text.js.map +0 -1
  770. package/singlestore-core/columns/time.cjs +0 -56
  771. package/singlestore-core/columns/time.cjs.map +0 -1
  772. package/singlestore-core/columns/time.d.cts +0 -23
  773. package/singlestore-core/columns/time.d.ts +0 -23
  774. package/singlestore-core/columns/time.js +0 -30
  775. package/singlestore-core/columns/time.js.map +0 -1
  776. package/singlestore-core/columns/timestamp.cjs +0 -97
  777. package/singlestore-core/columns/timestamp.cjs.map +0 -1
  778. package/singlestore-core/columns/timestamp.d.cts +0 -49
  779. package/singlestore-core/columns/timestamp.d.ts +0 -49
  780. package/singlestore-core/columns/timestamp.js +0 -69
  781. package/singlestore-core/columns/timestamp.js.map +0 -1
  782. package/singlestore-core/columns/tinyint.cjs +0 -65
  783. package/singlestore-core/columns/tinyint.cjs.map +0 -1
  784. package/singlestore-core/columns/tinyint.d.cts +0 -26
  785. package/singlestore-core/columns/tinyint.d.ts +0 -26
  786. package/singlestore-core/columns/tinyint.js +0 -39
  787. package/singlestore-core/columns/tinyint.js.map +0 -1
  788. package/singlestore-core/columns/varbinary.cjs +0 -61
  789. package/singlestore-core/columns/varbinary.cjs.map +0 -1
  790. package/singlestore-core/columns/varbinary.d.cts +0 -26
  791. package/singlestore-core/columns/varbinary.d.ts +0 -26
  792. package/singlestore-core/columns/varbinary.js +0 -35
  793. package/singlestore-core/columns/varbinary.js.map +0 -1
  794. package/singlestore-core/columns/varchar.cjs +0 -63
  795. package/singlestore-core/columns/varchar.cjs.map +0 -1
  796. package/singlestore-core/columns/varchar.d.cts +0 -29
  797. package/singlestore-core/columns/varchar.d.ts +0 -29
  798. package/singlestore-core/columns/varchar.js +0 -37
  799. package/singlestore-core/columns/varchar.js.map +0 -1
  800. package/singlestore-core/columns/year.cjs +0 -56
  801. package/singlestore-core/columns/year.cjs.map +0 -1
  802. package/singlestore-core/columns/year.d.cts +0 -23
  803. package/singlestore-core/columns/year.d.ts +0 -23
  804. package/singlestore-core/columns/year.js +0 -30
  805. package/singlestore-core/columns/year.js.map +0 -1
  806. package/singlestore-core/db.cjs +0 -261
  807. package/singlestore-core/db.cjs.map +0 -1
  808. package/singlestore-core/db.d.cts +0 -231
  809. package/singlestore-core/db.d.ts +0 -231
  810. package/singlestore-core/db.js +0 -242
  811. package/singlestore-core/db.js.map +0 -1
  812. package/singlestore-core/dialect.cjs +0 -607
  813. package/singlestore-core/dialect.cjs.map +0 -1
  814. package/singlestore-core/dialect.d.cts +0 -64
  815. package/singlestore-core/dialect.d.ts +0 -64
  816. package/singlestore-core/dialect.js +0 -589
  817. package/singlestore-core/dialect.js.map +0 -1
  818. package/singlestore-core/expressions.cjs +0 -49
  819. package/singlestore-core/expressions.cjs.map +0 -1
  820. package/singlestore-core/expressions.d.cts +0 -8
  821. package/singlestore-core/expressions.d.ts +0 -8
  822. package/singlestore-core/expressions.js +0 -22
  823. package/singlestore-core/expressions.js.map +0 -1
  824. package/singlestore-core/index.cjs +0 -47
  825. package/singlestore-core/index.cjs.map +0 -1
  826. package/singlestore-core/index.d.cts +0 -13
  827. package/singlestore-core/index.d.ts +0 -13
  828. package/singlestore-core/index.js +0 -14
  829. package/singlestore-core/index.js.map +0 -1
  830. package/singlestore-core/indexes.cjs +0 -88
  831. package/singlestore-core/indexes.cjs.map +0 -1
  832. package/singlestore-core/indexes.d.cts +0 -62
  833. package/singlestore-core/indexes.d.ts +0 -62
  834. package/singlestore-core/indexes.js +0 -60
  835. package/singlestore-core/indexes.js.map +0 -1
  836. package/singlestore-core/primary-keys.cjs +0 -68
  837. package/singlestore-core/primary-keys.cjs.map +0 -1
  838. package/singlestore-core/primary-keys.d.cts +0 -30
  839. package/singlestore-core/primary-keys.d.ts +0 -30
  840. package/singlestore-core/primary-keys.js +0 -42
  841. package/singlestore-core/primary-keys.js.map +0 -1
  842. package/singlestore-core/query-builders/count.cjs +0 -73
  843. package/singlestore-core/query-builders/count.cjs.map +0 -1
  844. package/singlestore-core/query-builders/count.d.cts +0 -25
  845. package/singlestore-core/query-builders/count.d.ts +0 -25
  846. package/singlestore-core/query-builders/count.js +0 -49
  847. package/singlestore-core/query-builders/count.js.map +0 -1
  848. package/singlestore-core/query-builders/delete.cjs +0 -123
  849. package/singlestore-core/query-builders/delete.cjs.map +0 -1
  850. package/singlestore-core/query-builders/delete.d.cts +0 -83
  851. package/singlestore-core/query-builders/delete.d.ts +0 -83
  852. package/singlestore-core/query-builders/delete.js +0 -99
  853. package/singlestore-core/query-builders/delete.js.map +0 -1
  854. package/singlestore-core/query-builders/index.cjs +0 -33
  855. package/singlestore-core/query-builders/index.cjs.map +0 -1
  856. package/singlestore-core/query-builders/index.d.cts +0 -6
  857. package/singlestore-core/query-builders/index.d.ts +0 -6
  858. package/singlestore-core/query-builders/index.js +0 -7
  859. package/singlestore-core/query-builders/index.js.map +0 -1
  860. package/singlestore-core/query-builders/insert.cjs +0 -146
  861. package/singlestore-core/query-builders/insert.cjs.map +0 -1
  862. package/singlestore-core/query-builders/insert.d.cts +0 -106
  863. package/singlestore-core/query-builders/insert.d.ts +0 -106
  864. package/singlestore-core/query-builders/insert.js +0 -121
  865. package/singlestore-core/query-builders/insert.js.map +0 -1
  866. package/singlestore-core/query-builders/query-builder.cjs +0 -99
  867. package/singlestore-core/query-builders/query-builder.cjs.map +0 -1
  868. package/singlestore-core/query-builders/query-builder.d.cts +0 -33
  869. package/singlestore-core/query-builders/query-builder.d.ts +0 -33
  870. package/singlestore-core/query-builders/query-builder.js +0 -75
  871. package/singlestore-core/query-builders/query-builder.js.map +0 -1
  872. package/singlestore-core/query-builders/query.cjs.map +0 -1
  873. package/singlestore-core/query-builders/query.d.cts +0 -42
  874. package/singlestore-core/query-builders/query.d.ts +0 -42
  875. package/singlestore-core/query-builders/query.js.map +0 -1
  876. package/singlestore-core/query-builders/select.cjs +0 -687
  877. package/singlestore-core/query-builders/select.cjs.map +0 -1
  878. package/singlestore-core/query-builders/select.d.cts +0 -585
  879. package/singlestore-core/query-builders/select.d.ts +0 -585
  880. package/singlestore-core/query-builders/select.js +0 -662
  881. package/singlestore-core/query-builders/select.js.map +0 -1
  882. package/singlestore-core/query-builders/select.types.cjs +0 -17
  883. package/singlestore-core/query-builders/select.types.cjs.map +0 -1
  884. package/singlestore-core/query-builders/select.types.d.cts +0 -137
  885. package/singlestore-core/query-builders/select.types.d.ts +0 -137
  886. package/singlestore-core/query-builders/select.types.js +0 -1
  887. package/singlestore-core/query-builders/select.types.js.map +0 -1
  888. package/singlestore-core/query-builders/update.cjs +0 -147
  889. package/singlestore-core/query-builders/update.cjs.map +0 -1
  890. package/singlestore-core/query-builders/update.d.cts +0 -102
  891. package/singlestore-core/query-builders/update.d.ts +0 -102
  892. package/singlestore-core/query-builders/update.js +0 -122
  893. package/singlestore-core/query-builders/update.js.map +0 -1
  894. package/singlestore-core/schema.cjs +0 -56
  895. package/singlestore-core/schema.cjs.map +0 -1
  896. package/singlestore-core/schema.d.cts +0 -22
  897. package/singlestore-core/schema.d.ts +0 -22
  898. package/singlestore-core/schema.js +0 -29
  899. package/singlestore-core/schema.js.map +0 -1
  900. package/singlestore-core/session.cjs +0 -87
  901. package/singlestore-core/session.cjs.map +0 -1
  902. package/singlestore-core/session.d.cts +0 -66
  903. package/singlestore-core/session.d.ts +0 -66
  904. package/singlestore-core/session.js +0 -61
  905. package/singlestore-core/session.js.map +0 -1
  906. package/singlestore-core/subquery.cjs +0 -17
  907. package/singlestore-core/subquery.cjs.map +0 -1
  908. package/singlestore-core/subquery.d.cts +0 -5
  909. package/singlestore-core/subquery.d.ts +0 -5
  910. package/singlestore-core/subquery.js +0 -1
  911. package/singlestore-core/subquery.js.map +0 -1
  912. package/singlestore-core/table.cjs +0 -73
  913. package/singlestore-core/table.cjs.map +0 -1
  914. package/singlestore-core/table.d.cts +0 -40
  915. package/singlestore-core/table.d.ts +0 -40
  916. package/singlestore-core/table.js +0 -46
  917. package/singlestore-core/table.js.map +0 -1
  918. package/singlestore-core/unique-constraint.cjs +0 -82
  919. package/singlestore-core/unique-constraint.cjs.map +0 -1
  920. package/singlestore-core/unique-constraint.d.cts +0 -24
  921. package/singlestore-core/unique-constraint.d.ts +0 -24
  922. package/singlestore-core/unique-constraint.js +0 -54
  923. package/singlestore-core/unique-constraint.js.map +0 -1
  924. package/singlestore-core/utils.cjs +0 -65
  925. package/singlestore-core/utils.cjs.map +0 -1
  926. package/singlestore-core/utils.d.cts +0 -13
  927. package/singlestore-core/utils.d.ts +0 -13
  928. package/singlestore-core/utils.js +0 -41
  929. package/singlestore-core/utils.js.map +0 -1
  930. package/singlestore-core/view-base.cjs +0 -33
  931. package/singlestore-core/view-base.cjs.map +0 -1
  932. package/singlestore-core/view-base.d.cts +0 -9
  933. package/singlestore-core/view-base.d.ts +0 -9
  934. package/singlestore-core/view-base.js +0 -9
  935. package/singlestore-core/view-base.js.map +0 -1
  936. package/singlestore-core/view-common.cjs +0 -29
  937. package/singlestore-core/view-common.cjs.map +0 -1
  938. package/singlestore-core/view-common.d.cts +0 -1
  939. package/singlestore-core/view-common.d.ts +0 -1
  940. package/singlestore-core/view-common.js +0 -5
  941. package/singlestore-core/view-common.js.map +0 -1
  942. package/singlestore-core/view.cjs +0 -146
  943. package/singlestore-core/view.cjs.map +0 -1
  944. package/singlestore-core/view.d.cts +0 -65
  945. package/singlestore-core/view.d.ts +0 -65
  946. package/singlestore-core/view.js +0 -119
  947. package/singlestore-core/view.js.map +0 -1
  948. package/singlestore-proxy/driver.cjs +0 -62
  949. package/singlestore-proxy/driver.cjs.map +0 -1
  950. package/singlestore-proxy/driver.d.cts +0 -13
  951. package/singlestore-proxy/driver.d.ts +0 -13
  952. package/singlestore-proxy/driver.js +0 -42
  953. package/singlestore-proxy/driver.js.map +0 -1
  954. package/singlestore-proxy/index.cjs +0 -25
  955. package/singlestore-proxy/index.cjs.map +0 -1
  956. package/singlestore-proxy/index.d.cts +0 -2
  957. package/singlestore-proxy/index.d.ts +0 -2
  958. package/singlestore-proxy/index.js +0 -3
  959. package/singlestore-proxy/index.js.map +0 -1
  960. package/singlestore-proxy/migrator.cjs +0 -60
  961. package/singlestore-proxy/migrator.cjs.map +0 -1
  962. package/singlestore-proxy/migrator.d.cts +0 -4
  963. package/singlestore-proxy/migrator.d.ts +0 -4
  964. package/singlestore-proxy/migrator.js +0 -36
  965. package/singlestore-proxy/migrator.js.map +0 -1
  966. package/singlestore-proxy/session.cjs +0 -127
  967. package/singlestore-proxy/session.cjs.map +0 -1
  968. package/singlestore-proxy/session.d.cts +0 -50
  969. package/singlestore-proxy/session.d.ts +0 -50
  970. package/singlestore-proxy/session.js +0 -101
  971. package/singlestore-proxy/session.js.map +0 -1
package/mysql-core/db.js CHANGED
@@ -2,6 +2,7 @@ import { entityKind } from "../entity.js";
2
2
  import { SelectionProxyHandler } from "../selection-proxy.js";
3
3
  import { sql } from "../sql/sql.js";
4
4
  import { WithSubquery } from "../subquery.js";
5
+ import { _RelationalQueryBuilder } from "./query-builders/_query.js";
5
6
  import { MySqlCountBuilder } from "./query-builders/count.js";
6
7
  import {
7
8
  MySqlDeleteBase,
@@ -12,23 +13,26 @@ import {
12
13
  } from "./query-builders/index.js";
13
14
  import { RelationalQueryBuilder } from "./query-builders/query.js";
14
15
  class MySqlDatabase {
15
- constructor(dialect, session, schema, mode) {
16
+ constructor(dialect, session, relations, schema, mode) {
16
17
  this.dialect = dialect;
17
18
  this.session = session;
18
19
  this.mode = mode;
20
+ const rel = relations ?? {};
19
21
  this._ = schema ? {
20
22
  schema: schema.schema,
21
23
  fullSchema: schema.fullSchema,
22
- tableNamesMap: schema.tableNamesMap
24
+ tableNamesMap: schema.tableNamesMap,
25
+ relations: rel
23
26
  } : {
24
27
  schema: void 0,
25
28
  fullSchema: {},
26
- tableNamesMap: {}
29
+ tableNamesMap: {},
30
+ relations: rel
27
31
  };
28
- this.query = {};
32
+ this._query = {};
29
33
  if (this._.schema) {
30
34
  for (const [tableName, columns] of Object.entries(this._.schema)) {
31
- this.query[tableName] = new RelationalQueryBuilder(
35
+ this._query[tableName] = new _RelationalQueryBuilder(
32
36
  schema.fullSchema,
33
37
  this._.schema,
34
38
  this._.tableNamesMap,
@@ -40,8 +44,25 @@ class MySqlDatabase {
40
44
  );
41
45
  }
42
46
  }
47
+ this.query = {};
48
+ if (relations) {
49
+ for (const [tableName, relation] of Object.entries(relations.tablesConfig)) {
50
+ this.query[tableName] = new RelationalQueryBuilder(
51
+ relations.tables,
52
+ relations.tablesConfig,
53
+ relations.tableNamesMap,
54
+ relation.table,
55
+ relation,
56
+ dialect,
57
+ session
58
+ );
59
+ }
60
+ }
43
61
  }
44
62
  static [entityKind] = "MySqlDatabase";
63
+ /** @deprecated */
64
+ _query;
65
+ // TO-DO: Figure out how to pass DrizzleTypeError without breaking withReplicas
45
66
  query;
46
67
  /**
47
68
  * Creates a subquery that defines a temporary named result set as a CTE.
@@ -244,8 +265,8 @@ const withReplicas = (primary, replicas, getReplica = () => replicas[Math.floor(
244
265
  select,
245
266
  selectDistinct,
246
267
  with: $with,
247
- get query() {
248
- return getReplica(replicas).query;
268
+ get _query() {
269
+ return getReplica(replicas)._query;
249
270
  }
250
271
  };
251
272
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mysql-core/db.ts"],"sourcesContent":["import type { ResultSetHeader } from 'mysql2/promise';\nimport { entityKind } from '~/entity.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type { ExtractTablesWithRelations, RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { type ColumnsSelection, type SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport { WithSubquery } from '~/subquery.ts';\nimport type { DrizzleTypeError } from '~/utils.ts';\nimport type { MySqlDialect } from './dialect.ts';\nimport { MySqlCountBuilder } from './query-builders/count.ts';\nimport {\n\tMySqlDeleteBase,\n\tMySqlInsertBuilder,\n\tMySqlSelectBuilder,\n\tMySqlUpdateBuilder,\n\tQueryBuilder,\n} from './query-builders/index.ts';\nimport { RelationalQueryBuilder } from './query-builders/query.ts';\nimport type { SelectedFields } from './query-builders/select.types.ts';\nimport type {\n\tMode,\n\tMySqlQueryResultHKT,\n\tMySqlQueryResultKind,\n\tMySqlSession,\n\tMySqlTransaction,\n\tMySqlTransactionConfig,\n\tPreparedQueryHKTBase,\n} from './session.ts';\nimport type { WithSubqueryWithSelection } from './subquery.ts';\nimport type { MySqlTable } from './table.ts';\nimport type { MySqlViewBase } from './view-base.ts';\n\nexport class MySqlDatabase<\n\tTQueryResult extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = {},\n\tTSchema extends TablesRelationalConfig = ExtractTablesWithRelations<TFullSchema>,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlDatabase';\n\n\tdeclare readonly _: {\n\t\treadonly schema: TSchema | undefined;\n\t\treadonly fullSchema: TFullSchema;\n\t\treadonly tableNamesMap: Record<string, string>;\n\t};\n\n\tquery: TFullSchema extends Record<string, never>\n\t\t? DrizzleTypeError<'Seems like the schema generic is missing - did you forget to add it to your DB type?'>\n\t\t: {\n\t\t\t[K in keyof TSchema]: RelationalQueryBuilder<TPreparedQueryHKT, TSchema, TSchema[K]>;\n\t\t};\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly dialect: MySqlDialect,\n\t\t/** @internal */\n\t\treadonly session: MySqlSession<any, any, any, any>,\n\t\tschema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprotected readonly mode: Mode,\n\t) {\n\t\tthis._ = schema\n\t\t\t? {\n\t\t\t\tschema: schema.schema,\n\t\t\t\tfullSchema: schema.fullSchema as TFullSchema,\n\t\t\t\ttableNamesMap: schema.tableNamesMap,\n\t\t\t}\n\t\t\t: {\n\t\t\t\tschema: undefined,\n\t\t\t\tfullSchema: {} as TFullSchema,\n\t\t\t\ttableNamesMap: {},\n\t\t\t};\n\t\tthis.query = {} as typeof this['query'];\n\t\tif (this._.schema) {\n\t\t\tfor (const [tableName, columns] of Object.entries(this._.schema)) {\n\t\t\t\t(this.query as MySqlDatabase<TQueryResult, TPreparedQueryHKT, Record<string, any>>['query'])[tableName] =\n\t\t\t\t\tnew RelationalQueryBuilder(\n\t\t\t\t\t\tschema!.fullSchema,\n\t\t\t\t\t\tthis._.schema,\n\t\t\t\t\t\tthis._.tableNamesMap,\n\t\t\t\t\t\tschema!.fullSchema[tableName] as MySqlTable,\n\t\t\t\t\t\tcolumns,\n\t\t\t\t\t\tdialect,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tthis.mode,\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates a subquery that defines a temporary named result set as a CTE.\n\t *\n\t * It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}\n\t *\n\t * @param alias The alias for the subquery.\n\t *\n\t * Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Create a subquery with alias 'sq' and use it in the select query\n\t * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));\n\t *\n\t * const result = await db.with(sq).select().from(sq);\n\t * ```\n\t *\n\t * To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:\n\t *\n\t * ```ts\n\t * // Select an arbitrary SQL value as a field in a CTE and reference it in the main query\n\t * const sq = db.$with('sq').as(db.select({\n\t * name: sql<string>`upper(${users.name})`.as('name'),\n\t * })\n\t * .from(users));\n\t *\n\t * const result = await db.with(sq).select({ name: sq.name }).from(sq);\n\t * ```\n\t */\n\t$with<TAlias extends string>(alias: TAlias) {\n\t\tconst self = this;\n\t\treturn {\n\t\t\tas<TSelection extends ColumnsSelection>(\n\t\t\t\tqb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>),\n\t\t\t): WithSubqueryWithSelection<TSelection, TAlias> {\n\t\t\t\tif (typeof qb === 'function') {\n\t\t\t\t\tqb = qb(new QueryBuilder(self.dialect));\n\t\t\t\t}\n\n\t\t\t\treturn new Proxy(\n\t\t\t\t\tnew WithSubquery(qb.getSQL(), qb.getSelectedFields() as SelectedFields, alias, true),\n\t\t\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t\t\t) as WithSubqueryWithSelection<TSelection, TAlias>;\n\t\t\t},\n\t\t};\n\t}\n\n\t$count(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t) {\n\t\treturn new MySqlCountBuilder({ source, filters, session: this.session });\n\t}\n\n\t/**\n\t * Incorporates a previously defined CTE (using `$with`) into the main query.\n\t *\n\t * This method allows the main query to reference a temporary named result set.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}\n\t *\n\t * @param queries The CTEs to incorporate into the main query.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Define a subquery 'sq' as a CTE using $with\n\t * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));\n\t *\n\t * // Incorporate the CTE 'sq' into the main query and select from it\n\t * const result = await db.with(sq).select().from(sq);\n\t * ```\n\t */\n\twith(...queries: WithSubquery[]) {\n\t\tconst self = this;\n\n\t\t/**\n\t\t * Creates a select query.\n\t\t *\n\t\t * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.\n\t\t *\n\t\t * Use `.from()` method to specify which table to select from.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/select}\n\t\t *\n\t\t * @param fields The selection object.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Select all columns and all rows from the 'cars' table\n\t\t * const allCars: Car[] = await db.select().from(cars);\n\t\t *\n\t\t * // Select specific columns and all rows from the 'cars' table\n\t\t * const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({\n\t\t * id: cars.id,\n\t\t * brand: cars.brand\n\t\t * })\n\t\t * .from(cars);\n\t\t * ```\n\t\t *\n\t\t * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:\n\t\t *\n\t\t * ```ts\n\t\t * // Select specific columns along with expression and all rows from the 'cars' table\n\t\t * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({\n\t\t * id: cars.id,\n\t\t * lowerBrand: sql<string>`lower(${cars.brand})`,\n\t\t * })\n\t\t * .from(cars);\n\t\t * ```\n\t\t */\n\t\tfunction select(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\t\tfunction select<TSelection extends SelectedFields>(\n\t\t\tfields: TSelection,\n\t\t): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\t\tfunction select(fields?: SelectedFields): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\t\treturn new MySqlSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: self.session,\n\t\t\t\tdialect: self.dialect,\n\t\t\t\twithList: queries,\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Adds `distinct` expression to the select query.\n\t\t *\n\t\t * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.\n\t\t *\n\t\t * Use `.from()` method to specify which table to select from.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/select#distinct}\n\t\t *\n\t\t * @param fields The selection object.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * // Select all unique rows from the 'cars' table\n\t\t * await db.selectDistinct()\n\t\t * .from(cars)\n\t\t * .orderBy(cars.id, cars.brand, cars.color);\n\t\t *\n\t\t * // Select all unique brands from the 'cars' table\n\t\t * await db.selectDistinct({ brand: cars.brand })\n\t\t * .from(cars)\n\t\t * .orderBy(cars.brand);\n\t\t * ```\n\t\t */\n\t\tfunction selectDistinct(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\t\tfunction selectDistinct<TSelection extends SelectedFields>(\n\t\t\tfields: TSelection,\n\t\t): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\t\tfunction selectDistinct(\n\t\t\tfields?: SelectedFields,\n\t\t): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\t\treturn new MySqlSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: self.session,\n\t\t\t\tdialect: self.dialect,\n\t\t\t\twithList: queries,\n\t\t\t\tdistinct: true,\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Creates an update query.\n\t\t *\n\t\t * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.\n\t\t *\n\t\t * Use `.set()` method to specify which values to update.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t\t *\n\t\t * @param table The table to update.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Update all rows in the 'cars' table\n\t\t * await db.update(cars).set({ color: 'red' });\n\t\t *\n\t\t * // Update rows with filters and conditions\n\t\t * await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));\n\t\t * ```\n\t\t */\n\t\tfunction update<TTable extends MySqlTable>(\n\t\t\ttable: TTable,\n\t\t): MySqlUpdateBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\t\treturn new MySqlUpdateBuilder(table, self.session, self.dialect, queries);\n\t\t}\n\n\t\t/**\n\t\t * Creates a delete query.\n\t\t *\n\t\t * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/delete}\n\t\t *\n\t\t * @param table The table to delete from.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Delete all rows in the 'cars' table\n\t\t * await db.delete(cars);\n\t\t *\n\t\t * // Delete rows with filters and conditions\n\t\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t\t * ```\n\t\t */\n\t\tfunction delete_<TTable extends MySqlTable>(\n\t\t\ttable: TTable,\n\t\t): MySqlDeleteBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\t\treturn new MySqlDeleteBase(table, self.session, self.dialect, queries);\n\t\t}\n\n\t\treturn { select, selectDistinct, update, delete: delete_ };\n\t}\n\n\t/**\n\t * Creates a select query.\n\t *\n\t * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.\n\t *\n\t * Use `.from()` method to specify which table to select from.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select}\n\t *\n\t * @param fields The selection object.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all columns and all rows from the 'cars' table\n\t * const allCars: Car[] = await db.select().from(cars);\n\t *\n\t * // Select specific columns and all rows from the 'cars' table\n\t * const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({\n\t * id: cars.id,\n\t * brand: cars.brand\n\t * })\n\t * .from(cars);\n\t * ```\n\t *\n\t * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:\n\t *\n\t * ```ts\n\t * // Select specific columns along with expression and all rows from the 'cars' table\n\t * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({\n\t * id: cars.id,\n\t * lowerBrand: sql<string>`lower(${cars.brand})`,\n\t * })\n\t * .from(cars);\n\t * ```\n\t */\n\tselect(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\tselect<TSelection extends SelectedFields>(fields: TSelection): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\tselect(fields?: SelectedFields): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\treturn new MySqlSelectBuilder({ fields: fields ?? undefined, session: this.session, dialect: this.dialect });\n\t}\n\n\t/**\n\t * Adds `distinct` expression to the select query.\n\t *\n\t * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.\n\t *\n\t * Use `.from()` method to specify which table to select from.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#distinct}\n\t *\n\t * @param fields The selection object.\n\t *\n\t * @example\n\t * ```ts\n\t * // Select all unique rows from the 'cars' table\n\t * await db.selectDistinct()\n\t * .from(cars)\n\t * .orderBy(cars.id, cars.brand, cars.color);\n\t *\n\t * // Select all unique brands from the 'cars' table\n\t * await db.selectDistinct({ brand: cars.brand })\n\t * .from(cars)\n\t * .orderBy(cars.brand);\n\t * ```\n\t */\n\tselectDistinct(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\tselectDistinct<TSelection extends SelectedFields>(\n\t\tfields: TSelection,\n\t): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\tselectDistinct(fields?: SelectedFields): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\treturn new MySqlSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: this.session,\n\t\t\tdialect: this.dialect,\n\t\t\tdistinct: true,\n\t\t});\n\t}\n\n\t/**\n\t * Creates an update query.\n\t *\n\t * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.\n\t *\n\t * Use `.set()` method to specify which values to update.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param table The table to update.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Update all rows in the 'cars' table\n\t * await db.update(cars).set({ color: 'red' });\n\t *\n\t * // Update rows with filters and conditions\n\t * await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));\n\t * ```\n\t */\n\tupdate<TTable extends MySqlTable>(table: TTable): MySqlUpdateBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new MySqlUpdateBuilder(table, this.session, this.dialect);\n\t}\n\n\t/**\n\t * Creates an insert query.\n\t *\n\t * Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert}\n\t *\n\t * @param table The table to insert into.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Insert one row\n\t * await db.insert(cars).values({ brand: 'BMW' });\n\t *\n\t * // Insert multiple rows\n\t * await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);\n\t * ```\n\t */\n\tinsert<TTable extends MySqlTable>(table: TTable): MySqlInsertBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new MySqlInsertBuilder(table, this.session, this.dialect);\n\t}\n\n\t/**\n\t * Creates a delete query.\n\t *\n\t * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/delete}\n\t *\n\t * @param table The table to delete from.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Delete all rows in the 'cars' table\n\t * await db.delete(cars);\n\t *\n\t * // Delete rows with filters and conditions\n\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t * ```\n\t */\n\tdelete<TTable extends MySqlTable>(table: TTable): MySqlDeleteBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new MySqlDeleteBase(table, this.session, this.dialect);\n\t}\n\n\texecute<T extends { [column: string]: any } = ResultSetHeader>(\n\t\tquery: SQLWrapper | string,\n\t): Promise<MySqlQueryResultKind<TQueryResult, T>> {\n\t\treturn this.session.execute(typeof query === 'string' ? sql.raw(query) : query.getSQL());\n\t}\n\n\ttransaction<T>(\n\t\ttransaction: (\n\t\t\ttx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>,\n\t\t\tconfig?: MySqlTransactionConfig,\n\t\t) => Promise<T>,\n\t\tconfig?: MySqlTransactionConfig,\n\t): Promise<T> {\n\t\treturn this.session.transaction(transaction, config);\n\t}\n}\n\nexport type MySQLWithReplicas<Q> = Q & { $primary: Q };\n\nexport const withReplicas = <\n\tHKT extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n\tQ extends MySqlDatabase<\n\t\tHKT,\n\t\tTPreparedQueryHKT,\n\t\tTFullSchema,\n\t\tTSchema extends Record<string, unknown> ? ExtractTablesWithRelations<TFullSchema> : TSchema\n\t>,\n>(\n\tprimary: Q,\n\treplicas: [Q, ...Q[]],\n\tgetReplica: (replicas: Q[]) => Q = () => replicas[Math.floor(Math.random() * replicas.length)]!,\n): MySQLWithReplicas<Q> => {\n\tconst select: Q['select'] = (...args: []) => getReplica(replicas).select(...args);\n\tconst selectDistinct: Q['selectDistinct'] = (...args: []) => getReplica(replicas).selectDistinct(...args);\n\tconst $with: Q['with'] = (...args: []) => getReplica(replicas).with(...args);\n\n\tconst update: Q['update'] = (...args: [any]) => primary.update(...args);\n\tconst insert: Q['insert'] = (...args: [any]) => primary.insert(...args);\n\tconst $delete: Q['delete'] = (...args: [any]) => primary.delete(...args);\n\tconst execute: Q['execute'] = (...args: [any]) => primary.execute(...args);\n\tconst transaction: Q['transaction'] = (...args: [any, any]) => primary.transaction(...args);\n\n\treturn {\n\t\t...primary,\n\t\tupdate,\n\t\tinsert,\n\t\tdelete: $delete,\n\t\texecute,\n\t\ttransaction,\n\t\t$primary: primary,\n\t\tselect,\n\t\tselectDistinct,\n\t\twith: $with,\n\t\tget query() {\n\t\t\treturn getReplica(replicas).query;\n\t\t},\n\t};\n};\n"],"mappings":"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","names":[]}
1
+ {"version":3,"sources":["../../src/mysql-core/db.ts"],"sourcesContent":["import type { ResultSetHeader } from 'mysql2/promise';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type { AnyRelations, EmptyRelations, ExtractTablesWithRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { type ColumnsSelection, type SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport { WithSubquery } from '~/subquery.ts';\nimport type { DrizzleTypeError } from '~/utils.ts';\nimport type { MySqlDialect } from './dialect.ts';\nimport { _RelationalQueryBuilder } from './query-builders/_query.ts';\nimport { MySqlCountBuilder } from './query-builders/count.ts';\nimport {\n\tMySqlDeleteBase,\n\tMySqlInsertBuilder,\n\tMySqlSelectBuilder,\n\tMySqlUpdateBuilder,\n\tQueryBuilder,\n} from './query-builders/index.ts';\nimport { RelationalQueryBuilder } from './query-builders/query.ts';\nimport type { SelectedFields } from './query-builders/select.types.ts';\nimport type {\n\tMode,\n\tMySqlQueryResultHKT,\n\tMySqlQueryResultKind,\n\tMySqlSession,\n\tMySqlTransaction,\n\tMySqlTransactionConfig,\n\tPreparedQueryHKTBase,\n} from './session.ts';\nimport type { WithSubqueryWithSelection } from './subquery.ts';\nimport type { MySqlTable } from './table.ts';\nimport type { MySqlViewBase } from './view-base.ts';\n\nexport class MySqlDatabase<\n\tTQueryResult extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTRelations extends AnyRelations = EmptyRelations,\n\tTTablesConfig extends TablesRelationalConfig = ExtractTablesWithRelations<TRelations>,\n\tTSchema extends V1.TablesRelationalConfig = V1.ExtractTablesWithRelations<TFullSchema>,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlDatabase';\n\n\tdeclare readonly _: {\n\t\treadonly schema: TSchema | undefined;\n\t\treadonly fullSchema: TFullSchema;\n\t\treadonly relations: TRelations;\n\t\treadonly tableNamesMap: Record<string, string>;\n\t};\n\n\t/** @deprecated */\n\t_query: TFullSchema extends Record<string, never>\n\t\t? DrizzleTypeError<'Seems like the schema generic is missing - did you forget to add it to your DB type?'>\n\t\t: {\n\t\t\t[K in keyof TSchema]: _RelationalQueryBuilder<TPreparedQueryHKT, TSchema, TSchema[K]>;\n\t\t};\n\n\t// TO-DO: Figure out how to pass DrizzleTypeError without breaking withReplicas\n\tquery: {\n\t\t[K in keyof TRelations['tables']]: RelationalQueryBuilder<\n\t\t\tTPreparedQueryHKT,\n\t\t\tTTablesConfig,\n\t\t\tTTablesConfig[K]\n\t\t>;\n\t};\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly dialect: MySqlDialect,\n\t\t/** @internal */\n\t\treadonly session: MySqlSession<any, any, any, any, any, any>,\n\t\trelations: AnyRelations | undefined,\n\t\tschema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprotected readonly mode: Mode,\n\t) {\n\t\tconst rel = relations ?? {} as EmptyRelations;\n\n\t\tthis._ = schema\n\t\t\t? {\n\t\t\t\tschema: schema.schema,\n\t\t\t\tfullSchema: schema.fullSchema as TFullSchema,\n\t\t\t\ttableNamesMap: schema.tableNamesMap,\n\t\t\t\trelations: rel as TRelations,\n\t\t\t}\n\t\t\t: {\n\t\t\t\tschema: undefined,\n\t\t\t\tfullSchema: {} as TFullSchema,\n\t\t\t\ttableNamesMap: {},\n\t\t\t\trelations: rel as TRelations,\n\t\t\t};\n\t\tthis._query = {} as typeof this['_query'];\n\t\tif (this._.schema) {\n\t\t\tfor (const [tableName, columns] of Object.entries(this._.schema)) {\n\t\t\t\t(this._query as MySqlDatabase<TQueryResult, TPreparedQueryHKT, Record<string, any>>['_query'])[tableName] =\n\t\t\t\t\tnew _RelationalQueryBuilder(\n\t\t\t\t\t\tschema!.fullSchema,\n\t\t\t\t\t\tthis._.schema,\n\t\t\t\t\t\tthis._.tableNamesMap,\n\t\t\t\t\t\tschema!.fullSchema[tableName] as MySqlTable,\n\t\t\t\t\t\tcolumns,\n\t\t\t\t\t\tdialect,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tthis.mode,\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthis.query = {} as typeof this['query'];\n\t\tif (relations) {\n\t\t\tfor (const [tableName, relation] of Object.entries(relations.tablesConfig)) {\n\t\t\t\t(this.query as MySqlDatabase<\n\t\t\t\t\tTQueryResult,\n\t\t\t\t\tTPreparedQueryHKT,\n\t\t\t\t\tTSchema,\n\t\t\t\t\tAnyRelations,\n\t\t\t\t\tTablesRelationalConfig,\n\t\t\t\t\tV1.TablesRelationalConfig\n\t\t\t\t>['query'])[\n\t\t\t\t\ttableName\n\t\t\t\t] = new RelationalQueryBuilder(\n\t\t\t\t\trelations.tables,\n\t\t\t\t\trelations.tablesConfig,\n\t\t\t\t\trelations.tableNamesMap,\n\t\t\t\t\trelation.table as MySqlTable,\n\t\t\t\t\trelation,\n\t\t\t\t\tdialect,\n\t\t\t\t\tsession,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates a subquery that defines a temporary named result set as a CTE.\n\t *\n\t * It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}\n\t *\n\t * @param alias The alias for the subquery.\n\t *\n\t * Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Create a subquery with alias 'sq' and use it in the select query\n\t * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));\n\t *\n\t * const result = await db.with(sq).select().from(sq);\n\t * ```\n\t *\n\t * To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:\n\t *\n\t * ```ts\n\t * // Select an arbitrary SQL value as a field in a CTE and reference it in the main query\n\t * const sq = db.$with('sq').as(db.select({\n\t * name: sql<string>`upper(${users.name})`.as('name'),\n\t * })\n\t * .from(users));\n\t *\n\t * const result = await db.with(sq).select({ name: sq.name }).from(sq);\n\t * ```\n\t */\n\t$with<TAlias extends string>(alias: TAlias) {\n\t\tconst self = this;\n\t\treturn {\n\t\t\tas<TSelection extends ColumnsSelection>(\n\t\t\t\tqb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>),\n\t\t\t): WithSubqueryWithSelection<TSelection, TAlias> {\n\t\t\t\tif (typeof qb === 'function') {\n\t\t\t\t\tqb = qb(new QueryBuilder(self.dialect));\n\t\t\t\t}\n\n\t\t\t\treturn new Proxy(\n\t\t\t\t\tnew WithSubquery(qb.getSQL(), qb.getSelectedFields() as SelectedFields, alias, true),\n\t\t\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t\t\t) as WithSubqueryWithSelection<TSelection, TAlias>;\n\t\t\t},\n\t\t};\n\t}\n\n\t$count(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t) {\n\t\treturn new MySqlCountBuilder({ source, filters, session: this.session });\n\t}\n\n\t/**\n\t * Incorporates a previously defined CTE (using `$with`) into the main query.\n\t *\n\t * This method allows the main query to reference a temporary named result set.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}\n\t *\n\t * @param queries The CTEs to incorporate into the main query.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Define a subquery 'sq' as a CTE using $with\n\t * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));\n\t *\n\t * // Incorporate the CTE 'sq' into the main query and select from it\n\t * const result = await db.with(sq).select().from(sq);\n\t * ```\n\t */\n\twith(...queries: WithSubquery[]) {\n\t\tconst self = this;\n\n\t\t/**\n\t\t * Creates a select query.\n\t\t *\n\t\t * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.\n\t\t *\n\t\t * Use `.from()` method to specify which table to select from.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/select}\n\t\t *\n\t\t * @param fields The selection object.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Select all columns and all rows from the 'cars' table\n\t\t * const allCars: Car[] = await db.select().from(cars);\n\t\t *\n\t\t * // Select specific columns and all rows from the 'cars' table\n\t\t * const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({\n\t\t * id: cars.id,\n\t\t * brand: cars.brand\n\t\t * })\n\t\t * .from(cars);\n\t\t * ```\n\t\t *\n\t\t * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:\n\t\t *\n\t\t * ```ts\n\t\t * // Select specific columns along with expression and all rows from the 'cars' table\n\t\t * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({\n\t\t * id: cars.id,\n\t\t * lowerBrand: sql<string>`lower(${cars.brand})`,\n\t\t * })\n\t\t * .from(cars);\n\t\t * ```\n\t\t */\n\t\tfunction select(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\t\tfunction select<TSelection extends SelectedFields>(\n\t\t\tfields: TSelection,\n\t\t): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\t\tfunction select(fields?: SelectedFields): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\t\treturn new MySqlSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: self.session,\n\t\t\t\tdialect: self.dialect,\n\t\t\t\twithList: queries,\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Adds `distinct` expression to the select query.\n\t\t *\n\t\t * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.\n\t\t *\n\t\t * Use `.from()` method to specify which table to select from.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/select#distinct}\n\t\t *\n\t\t * @param fields The selection object.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * // Select all unique rows from the 'cars' table\n\t\t * await db.selectDistinct()\n\t\t * .from(cars)\n\t\t * .orderBy(cars.id, cars.brand, cars.color);\n\t\t *\n\t\t * // Select all unique brands from the 'cars' table\n\t\t * await db.selectDistinct({ brand: cars.brand })\n\t\t * .from(cars)\n\t\t * .orderBy(cars.brand);\n\t\t * ```\n\t\t */\n\t\tfunction selectDistinct(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\t\tfunction selectDistinct<TSelection extends SelectedFields>(\n\t\t\tfields: TSelection,\n\t\t): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\t\tfunction selectDistinct(\n\t\t\tfields?: SelectedFields,\n\t\t): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\t\treturn new MySqlSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: self.session,\n\t\t\t\tdialect: self.dialect,\n\t\t\t\twithList: queries,\n\t\t\t\tdistinct: true,\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Creates an update query.\n\t\t *\n\t\t * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.\n\t\t *\n\t\t * Use `.set()` method to specify which values to update.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t\t *\n\t\t * @param table The table to update.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Update all rows in the 'cars' table\n\t\t * await db.update(cars).set({ color: 'red' });\n\t\t *\n\t\t * // Update rows with filters and conditions\n\t\t * await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));\n\t\t * ```\n\t\t */\n\t\tfunction update<TTable extends MySqlTable>(\n\t\t\ttable: TTable,\n\t\t): MySqlUpdateBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\t\treturn new MySqlUpdateBuilder(table, self.session, self.dialect, queries);\n\t\t}\n\n\t\t/**\n\t\t * Creates a delete query.\n\t\t *\n\t\t * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/delete}\n\t\t *\n\t\t * @param table The table to delete from.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Delete all rows in the 'cars' table\n\t\t * await db.delete(cars);\n\t\t *\n\t\t * // Delete rows with filters and conditions\n\t\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t\t * ```\n\t\t */\n\t\tfunction delete_<TTable extends MySqlTable>(\n\t\t\ttable: TTable,\n\t\t): MySqlDeleteBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\t\treturn new MySqlDeleteBase(table, self.session, self.dialect, queries);\n\t\t}\n\n\t\treturn { select, selectDistinct, update, delete: delete_ };\n\t}\n\n\t/**\n\t * Creates a select query.\n\t *\n\t * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.\n\t *\n\t * Use `.from()` method to specify which table to select from.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select}\n\t *\n\t * @param fields The selection object.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all columns and all rows from the 'cars' table\n\t * const allCars: Car[] = await db.select().from(cars);\n\t *\n\t * // Select specific columns and all rows from the 'cars' table\n\t * const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({\n\t * id: cars.id,\n\t * brand: cars.brand\n\t * })\n\t * .from(cars);\n\t * ```\n\t *\n\t * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:\n\t *\n\t * ```ts\n\t * // Select specific columns along with expression and all rows from the 'cars' table\n\t * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({\n\t * id: cars.id,\n\t * lowerBrand: sql<string>`lower(${cars.brand})`,\n\t * })\n\t * .from(cars);\n\t * ```\n\t */\n\tselect(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\tselect<TSelection extends SelectedFields>(fields: TSelection): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\tselect(fields?: SelectedFields): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\treturn new MySqlSelectBuilder({ fields: fields ?? undefined, session: this.session, dialect: this.dialect });\n\t}\n\n\t/**\n\t * Adds `distinct` expression to the select query.\n\t *\n\t * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.\n\t *\n\t * Use `.from()` method to specify which table to select from.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#distinct}\n\t *\n\t * @param fields The selection object.\n\t *\n\t * @example\n\t * ```ts\n\t * // Select all unique rows from the 'cars' table\n\t * await db.selectDistinct()\n\t * .from(cars)\n\t * .orderBy(cars.id, cars.brand, cars.color);\n\t *\n\t * // Select all unique brands from the 'cars' table\n\t * await db.selectDistinct({ brand: cars.brand })\n\t * .from(cars)\n\t * .orderBy(cars.brand);\n\t * ```\n\t */\n\tselectDistinct(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;\n\tselectDistinct<TSelection extends SelectedFields>(\n\t\tfields: TSelection,\n\t): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;\n\tselectDistinct(fields?: SelectedFields): MySqlSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\treturn new MySqlSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: this.session,\n\t\t\tdialect: this.dialect,\n\t\t\tdistinct: true,\n\t\t});\n\t}\n\n\t/**\n\t * Creates an update query.\n\t *\n\t * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.\n\t *\n\t * Use `.set()` method to specify which values to update.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param table The table to update.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Update all rows in the 'cars' table\n\t * await db.update(cars).set({ color: 'red' });\n\t *\n\t * // Update rows with filters and conditions\n\t * await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));\n\t * ```\n\t */\n\tupdate<TTable extends MySqlTable>(table: TTable): MySqlUpdateBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new MySqlUpdateBuilder(table, this.session, this.dialect);\n\t}\n\n\t/**\n\t * Creates an insert query.\n\t *\n\t * Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert}\n\t *\n\t * @param table The table to insert into.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Insert one row\n\t * await db.insert(cars).values({ brand: 'BMW' });\n\t *\n\t * // Insert multiple rows\n\t * await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);\n\t * ```\n\t */\n\tinsert<TTable extends MySqlTable>(table: TTable): MySqlInsertBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new MySqlInsertBuilder(table, this.session, this.dialect);\n\t}\n\n\t/**\n\t * Creates a delete query.\n\t *\n\t * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/delete}\n\t *\n\t * @param table The table to delete from.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Delete all rows in the 'cars' table\n\t * await db.delete(cars);\n\t *\n\t * // Delete rows with filters and conditions\n\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t * ```\n\t */\n\tdelete<TTable extends MySqlTable>(table: TTable): MySqlDeleteBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new MySqlDeleteBase(table, this.session, this.dialect);\n\t}\n\n\texecute<T extends { [column: string]: any } = ResultSetHeader>(\n\t\tquery: SQLWrapper | string,\n\t): Promise<MySqlQueryResultKind<TQueryResult, T>> {\n\t\treturn this.session.execute(typeof query === 'string' ? sql.raw(query) : query.getSQL());\n\t}\n\n\ttransaction<T>(\n\t\ttransaction: (\n\t\t\ttx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TRelations, TTablesConfig, TSchema>,\n\t\t\tconfig?: MySqlTransactionConfig,\n\t\t) => Promise<T>,\n\t\tconfig?: MySqlTransactionConfig,\n\t): Promise<T> {\n\t\treturn this.session.transaction(transaction, config);\n\t}\n}\n\nexport type MySQLWithReplicas<Q> = Q & { $primary: Q };\n\nexport const withReplicas = <\n\tHKT extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n\tQ extends MySqlDatabase<\n\t\tHKT,\n\t\tTPreparedQueryHKT,\n\t\tTFullSchema,\n\t\tTRelations,\n\t\tTTablesConfig,\n\t\tTSchema extends Record<string, unknown> ? V1.ExtractTablesWithRelations<TFullSchema> : TSchema\n\t>,\n>(\n\tprimary: Q,\n\treplicas: [Q, ...Q[]],\n\tgetReplica: (replicas: Q[]) => Q = () => replicas[Math.floor(Math.random() * replicas.length)]!,\n): MySQLWithReplicas<Q> => {\n\tconst select: Q['select'] = (...args: []) => getReplica(replicas).select(...args);\n\tconst selectDistinct: Q['selectDistinct'] = (...args: []) => getReplica(replicas).selectDistinct(...args);\n\tconst $with: Q['with'] = (...args: []) => getReplica(replicas).with(...args);\n\n\tconst update: Q['update'] = (...args: [any]) => primary.update(...args);\n\tconst insert: Q['insert'] = (...args: [any]) => primary.insert(...args);\n\tconst $delete: Q['delete'] = (...args: [any]) => primary.delete(...args);\n\tconst execute: Q['execute'] = (...args: [any]) => primary.execute(...args);\n\tconst transaction: Q['transaction'] = (...args: [any, any]) => primary.transaction(...args);\n\n\treturn {\n\t\t...primary,\n\t\tupdate,\n\t\tinsert,\n\t\tdelete: $delete,\n\t\texecute,\n\t\ttransaction,\n\t\t$primary: primary,\n\t\tselect,\n\t\tselectDistinct,\n\t\twith: $with,\n\t\tget _query() {\n\t\t\treturn getReplica(replicas)._query;\n\t\t},\n\t};\n};\n"],"mappings":"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","names":[]}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,12 +17,21 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var dialect_exports = {};
20
30
  __export(dialect_exports, {
21
31
  MySqlDialect: () => MySqlDialect
22
32
  });
23
33
  module.exports = __toCommonJS(dialect_exports);
34
+ var V1 = __toESM(require("../_relations.cjs"), 1);
24
35
  var import_alias = require("../alias.cjs");
25
36
  var import_casing = require("../casing.cjs");
26
37
  var import_column = require("../column.cjs");
@@ -386,7 +397,8 @@ class MySqlDialect {
386
397
  invokeSource
387
398
  });
388
399
  }
389
- buildRelationalQuery({
400
+ /** @deprecated */
401
+ _buildRelationalQuery({
390
402
  fullSchema,
391
403
  schema,
392
404
  tableNamesMap,
@@ -415,7 +427,7 @@ class MySqlDialect {
415
427
  Object.entries(tableConfig.columns).map(([key, value]) => [key, (0, import_alias.aliasedTableColumn)(value, tableAlias)])
416
428
  );
417
429
  if (config.where) {
418
- const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, (0, import_relations.getOperators)()) : config.where;
430
+ const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, V1.getOperators()) : config.where;
419
431
  where = whereSql && (0, import_alias.mapColumnsInSQLToAlias)(whereSql, tableAlias);
420
432
  }
421
433
  const fieldsSelection = [];
@@ -467,7 +479,7 @@ class MySqlDialect {
467
479
  selection: []
468
480
  });
469
481
  }
470
- let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, (0, import_relations.getOrderByOperators)()) : config.orderBy ?? [];
482
+ let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, V1.getOrderByOperators()) : config.orderBy ?? [];
471
483
  if (!Array.isArray(orderByOrig)) {
472
484
  orderByOrig = [orderByOrig];
473
485
  }
@@ -484,7 +496,7 @@ class MySqlDialect {
484
496
  queryConfig: selectedRelationConfigValue,
485
497
  relation
486
498
  } of selectedRelations) {
487
- const normalizedRelation = (0, import_relations.normalizeRelation)(schema, tableNamesMap, relation);
499
+ const normalizedRelation = V1.normalizeRelation(schema, tableNamesMap, relation);
488
500
  const relationTableName = (0, import_table.getTableUniqueName)(relation.referencedTable);
489
501
  const relationTableTsName = tableNamesMap[relationTableName];
490
502
  const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
@@ -496,13 +508,13 @@ class MySqlDialect {
496
508
  )
497
509
  )
498
510
  );
499
- const builtRelation = this.buildRelationalQuery({
511
+ const builtRelation = this._buildRelationalQuery({
500
512
  fullSchema,
501
513
  schema,
502
514
  tableNamesMap,
503
515
  table: fullSchema[relationTableTsName],
504
516
  tableConfig: schema[relationTableTsName],
505
- queryConfig: (0, import_entity.is)(relation, import_relations.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
517
+ queryConfig: (0, import_entity.is)(relation, V1.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
506
518
  tableAlias: relationTableAlias,
507
519
  joinOn: joinOn2,
508
520
  nestedQueryRelation: relation
@@ -537,7 +549,7 @@ class MySqlDialect {
537
549
  ),
538
550
  import_sql.sql`, `
539
551
  )})`;
540
- if ((0, import_entity.is)(nestedQueryRelation, import_relations.Many)) {
552
+ if ((0, import_entity.is)(nestedQueryRelation, V1.Many)) {
541
553
  field = import_sql.sql`coalesce(json_arrayagg(${field}), json_array())`;
542
554
  }
543
555
  const nestedSelection = [{
@@ -611,7 +623,8 @@ class MySqlDialect {
611
623
  selection
612
624
  };
613
625
  }
614
- buildRelationalQueryWithoutLateralSubqueries({
626
+ /** @deprecated */
627
+ _buildRelationalQueryWithoutLateralSubqueries({
615
628
  fullSchema,
616
629
  schema,
617
630
  tableNamesMap,
@@ -639,7 +652,7 @@ class MySqlDialect {
639
652
  Object.entries(tableConfig.columns).map(([key, value]) => [key, (0, import_alias.aliasedTableColumn)(value, tableAlias)])
640
653
  );
641
654
  if (config.where) {
642
- const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, (0, import_relations.getOperators)()) : config.where;
655
+ const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, V1.getOperators()) : config.where;
643
656
  where = whereSql && (0, import_alias.mapColumnsInSQLToAlias)(whereSql, tableAlias);
644
657
  }
645
658
  const fieldsSelection = [];
@@ -691,7 +704,7 @@ class MySqlDialect {
691
704
  selection: []
692
705
  });
693
706
  }
694
- let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, (0, import_relations.getOrderByOperators)()) : config.orderBy ?? [];
707
+ let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, V1.getOrderByOperators()) : config.orderBy ?? [];
695
708
  if (!Array.isArray(orderByOrig)) {
696
709
  orderByOrig = [orderByOrig];
697
710
  }
@@ -708,7 +721,7 @@ class MySqlDialect {
708
721
  queryConfig: selectedRelationConfigValue,
709
722
  relation
710
723
  } of selectedRelations) {
711
- const normalizedRelation = (0, import_relations.normalizeRelation)(schema, tableNamesMap, relation);
724
+ const normalizedRelation = V1.normalizeRelation(schema, tableNamesMap, relation);
712
725
  const relationTableName = (0, import_table.getTableUniqueName)(relation.referencedTable);
713
726
  const relationTableTsName = tableNamesMap[relationTableName];
714
727
  const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
@@ -720,19 +733,19 @@ class MySqlDialect {
720
733
  )
721
734
  )
722
735
  );
723
- const builtRelation = this.buildRelationalQueryWithoutLateralSubqueries({
736
+ const builtRelation = this._buildRelationalQueryWithoutLateralSubqueries({
724
737
  fullSchema,
725
738
  schema,
726
739
  tableNamesMap,
727
740
  table: fullSchema[relationTableTsName],
728
741
  tableConfig: schema[relationTableTsName],
729
- queryConfig: (0, import_entity.is)(relation, import_relations.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
742
+ queryConfig: (0, import_entity.is)(relation, V1.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
730
743
  tableAlias: relationTableAlias,
731
744
  joinOn: joinOn2,
732
745
  nestedQueryRelation: relation
733
746
  });
734
747
  let fieldSql = import_sql.sql`(${builtRelation.sql})`;
735
- if ((0, import_entity.is)(relation, import_relations.Many)) {
748
+ if ((0, import_entity.is)(relation, V1.Many)) {
736
749
  fieldSql = import_sql.sql`coalesce(${fieldSql}, json_array())`;
737
750
  }
738
751
  const field = fieldSql.as(selectedRelationTsKey);
@@ -760,7 +773,7 @@ class MySqlDialect {
760
773
  ),
761
774
  import_sql.sql`, `
762
775
  )})`;
763
- if ((0, import_entity.is)(nestedQueryRelation, import_relations.Many)) {
776
+ if ((0, import_entity.is)(nestedQueryRelation, V1.Many)) {
764
777
  field = import_sql.sql`json_arrayagg(${field})`;
765
778
  }
766
779
  const nestedSelection = [{
@@ -832,6 +845,148 @@ class MySqlDialect {
832
845
  selection
833
846
  };
834
847
  }
848
+ unwrapAllColumns = (table, selection) => {
849
+ return import_sql.sql.join(
850
+ Object.entries(table[import_table.Columns]).map(([k, v]) => {
851
+ selection.push({
852
+ key: k,
853
+ field: v
854
+ });
855
+ return import_sql.sql`${v} as ${import_sql.sql.identifier(k)}`;
856
+ }),
857
+ import_sql.sql`, `
858
+ );
859
+ };
860
+ getSelectedTableColumns = (table, columns) => {
861
+ const selectedColumns = [];
862
+ if (!columns) {
863
+ for (const [k, v] of Object.entries(table[import_table.Columns])) {
864
+ selectedColumns.push({
865
+ column: v,
866
+ tsName: k
867
+ });
868
+ }
869
+ return selectedColumns;
870
+ }
871
+ const entries = Object.entries(columns);
872
+ let colSelectionMode;
873
+ for (const [k, v] of entries) {
874
+ if (colSelectionMode === void 0)
875
+ colSelectionMode = v;
876
+ else if (v !== void 0 && colSelectionMode !== v) {
877
+ throw new Error("Columns cannot be both true and false at the same time");
878
+ }
879
+ if (v) {
880
+ selectedColumns.push({
881
+ column: table[import_table.Columns][k],
882
+ tsName: k
883
+ });
884
+ }
885
+ }
886
+ if (colSelectionMode === false) {
887
+ for (const [k, v] of Object.entries(table[import_table.Columns])) {
888
+ if (columns[k] === false)
889
+ continue;
890
+ selectedColumns.push({
891
+ column: v,
892
+ tsName: k
893
+ });
894
+ }
895
+ }
896
+ return selectedColumns;
897
+ };
898
+ buildColumns = (table, selection, params) => params?.columns ? (() => {
899
+ const columnIdentifiers = [];
900
+ const selectedColumns = this.getSelectedTableColumns(table, params?.columns);
901
+ for (const column of selectedColumns) {
902
+ columnIdentifiers.push(
903
+ import_sql.sql`${table[column.tsName]} as ${import_sql.sql.identifier(column.tsName)}`
904
+ );
905
+ }
906
+ return columnIdentifiers.length ? import_sql.sql.join(columnIdentifiers, import_sql.sql`, `) : this.unwrapAllColumns(table, selection);
907
+ })() : (() => {
908
+ const columnIdentifiers = [this.unwrapAllColumns(table, selection)];
909
+ return import_sql.sql.join(columnIdentifiers, import_sql.sql`, `);
910
+ })();
911
+ buildRelationalQuery({
912
+ tables,
913
+ schema,
914
+ tableNamesMap,
915
+ table,
916
+ tableConfig,
917
+ queryConfig: config,
918
+ relationWhere,
919
+ mode
920
+ }) {
921
+ const selection = [];
922
+ const isSingle = mode === "first";
923
+ const params = config === true ? void 0 : config;
924
+ const limit = isSingle ? 1 : params?.limit;
925
+ const offset = params?.offset;
926
+ const columns = this.buildColumns(table, selection, params);
927
+ const where = params?.where && relationWhere ? (0, import_expressions.and)((0, import_relations.relationFilterToSQL)(table, params.where), relationWhere) : params?.where ? (0, import_relations.relationFilterToSQL)(table, params.where) : relationWhere;
928
+ const order = params?.orderBy ? (0, import_relations.relationsOrderToSQL)(table, params.orderBy) : void 0;
929
+ const extras = params?.extras ? (0, import_relations.relationExtrasToSQL)(table, params.extras) : void 0;
930
+ if (extras)
931
+ selection.push(...extras.selection);
932
+ const selectionArr = [columns];
933
+ const joins = params ? (() => {
934
+ const { with: joins2 } = params;
935
+ if (!joins2)
936
+ return;
937
+ const withEntries = Object.entries(joins2).filter(([_, v]) => v);
938
+ if (!withEntries.length)
939
+ return;
940
+ return import_sql.sql.join(
941
+ withEntries.map(([k, join]) => {
942
+ selectionArr.push(import_sql.sql`${import_sql.sql.identifier(k)}.${import_sql.sql.identifier("r")} as ${import_sql.sql.identifier(k)}`);
943
+ if ((0, import_entity.is)(tableConfig.relations[k], import_relations.AggregatedField)) {
944
+ const relation2 = tableConfig.relations[k];
945
+ relation2.onTable(table);
946
+ const query2 = relation2.getSQL();
947
+ selection.push({
948
+ key: k,
949
+ field: relation2
950
+ });
951
+ return import_sql.sql`, lateral(${query2}) as ${import_sql.sql.identifier(k)}`;
952
+ }
953
+ const relation = tableConfig.relations[k];
954
+ const isSingle2 = (0, import_entity.is)(relation, import_relations.One);
955
+ const targetTable = relation.targetTable;
956
+ const relationFilter = (0, import_relations.relationToSQL)(relation);
957
+ const innerQuery = this.buildRelationalQuery({
958
+ table: targetTable,
959
+ mode: isSingle2 ? "first" : "many",
960
+ schema,
961
+ queryConfig: join,
962
+ tableConfig: schema[tableNamesMap[(0, import_table.getTableUniqueName)(targetTable)]],
963
+ tableNamesMap,
964
+ tables,
965
+ relationWhere: relationFilter
966
+ });
967
+ selection.push({
968
+ field: targetTable,
969
+ key: k,
970
+ selection: innerQuery.selection,
971
+ isArray: !isSingle2
972
+ });
973
+ const jsonColumns = import_sql.sql.join(
974
+ innerQuery.selection.map((s) => import_sql.sql`${import_sql.sql.raw(this.escapeString(s.key))}, ${import_sql.sql.identifier(s.key)}`),
975
+ import_sql.sql`, `
976
+ );
977
+ return import_sql.sql`, lateral(select ${isSingle2 ? import_sql.sql`json_object(${jsonColumns}) as ${import_sql.sql.identifier("r")}` : import_sql.sql`coalesce(json_arrayagg(json_object(${jsonColumns})), json_array()) as ${import_sql.sql.identifier("r")}`} from (${innerQuery.sql}) as ${import_sql.sql.identifier("t")}) as ${import_sql.sql.identifier(k)}`;
978
+ })
979
+ );
980
+ })() : void 0;
981
+ if (extras?.sql)
982
+ selectionArr.push(extras.sql);
983
+ const selectionSet = import_sql.sql.join(selectionArr, import_sql.sql`, `);
984
+ const query = import_sql.sql`select ${selectionSet} from ${table}${import_sql.sql`${joins}`.if(joins)}${import_sql.sql` where ${where}`.if(where)}${import_sql.sql` order by ${order}`.if(order)}${import_sql.sql` limit ${limit}`.if(limit !== void 0)}${import_sql.sql` offset ${offset}`.if(offset !== void 0)}`;
985
+ return {
986
+ sql: query,
987
+ selection
988
+ };
989
+ }
835
990
  }
836
991
  // Annotate the CommonJS export names for ESM import in node:
837
992
  0 && (module.exports = {