drizzle-orm 0.39.2-8628c8a → 0.39.2-c7c31ad

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 (1001) 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-sql/driver.cjs +16 -5
  44. package/bun-sql/driver.cjs.map +1 -1
  45. package/bun-sql/driver.d.cts +7 -6
  46. package/bun-sql/driver.d.ts +7 -6
  47. package/bun-sql/driver.js +6 -8
  48. package/bun-sql/driver.js.map +1 -1
  49. package/bun-sql/migrator.cjs.map +1 -1
  50. package/bun-sql/migrator.d.cts +2 -1
  51. package/bun-sql/migrator.d.ts +2 -1
  52. package/bun-sql/migrator.js.map +1 -1
  53. package/bun-sql/session.cjs +50 -6
  54. package/bun-sql/session.cjs.map +1 -1
  55. package/bun-sql/session.d.cts +14 -9
  56. package/bun-sql/session.d.ts +14 -9
  57. package/bun-sql/session.js +50 -6
  58. package/bun-sql/session.js.map +1 -1
  59. package/bun-sqlite/driver.cjs +22 -5
  60. package/bun-sqlite/driver.cjs.map +1 -1
  61. package/bun-sqlite/driver.d.cts +7 -6
  62. package/bun-sqlite/driver.d.ts +7 -6
  63. package/bun-sqlite/driver.js +12 -8
  64. package/bun-sqlite/driver.js.map +1 -1
  65. package/bun-sqlite/migrator.cjs.map +1 -1
  66. package/bun-sqlite/migrator.d.cts +2 -1
  67. package/bun-sqlite/migrator.d.ts +2 -1
  68. package/bun-sqlite/migrator.js.map +1 -1
  69. package/bun-sqlite/session.cjs +49 -4
  70. package/bun-sqlite/session.cjs.map +1 -1
  71. package/bun-sqlite/session.d.cts +14 -8
  72. package/bun-sqlite/session.d.ts +14 -8
  73. package/bun-sqlite/session.js +49 -4
  74. package/bun-sqlite/session.js.map +1 -1
  75. package/column-builder.cjs.map +1 -1
  76. package/column-builder.d.cts +5 -6
  77. package/column-builder.d.ts +5 -6
  78. package/column-builder.js.map +1 -1
  79. package/d1/driver.cjs +22 -5
  80. package/d1/driver.cjs.map +1 -1
  81. package/d1/driver.d.cts +3 -2
  82. package/d1/driver.d.ts +3 -2
  83. package/d1/driver.js +12 -8
  84. package/d1/driver.js.map +1 -1
  85. package/d1/migrator.cjs.map +1 -1
  86. package/d1/migrator.d.cts +2 -1
  87. package/d1/migrator.d.ts +2 -1
  88. package/d1/migrator.js.map +1 -1
  89. package/d1/session.cjs +50 -8
  90. package/d1/session.cjs.map +1 -1
  91. package/d1/session.d.cts +15 -8
  92. package/d1/session.d.ts +15 -8
  93. package/d1/session.js +50 -8
  94. package/d1/session.js.map +1 -1
  95. package/durable-sqlite/driver.cjs +16 -5
  96. package/durable-sqlite/driver.cjs.map +1 -1
  97. package/durable-sqlite/driver.d.cts +3 -2
  98. package/durable-sqlite/driver.d.ts +3 -2
  99. package/durable-sqlite/driver.js +6 -8
  100. package/durable-sqlite/driver.js.map +1 -1
  101. package/durable-sqlite/migrator.cjs.map +1 -1
  102. package/durable-sqlite/migrator.d.cts +2 -1
  103. package/durable-sqlite/migrator.d.ts +2 -1
  104. package/durable-sqlite/migrator.js.map +1 -1
  105. package/durable-sqlite/session.cjs +46 -4
  106. package/durable-sqlite/session.cjs.map +1 -1
  107. package/durable-sqlite/session.d.cts +14 -8
  108. package/durable-sqlite/session.d.ts +14 -8
  109. package/durable-sqlite/session.js +46 -4
  110. package/durable-sqlite/session.js.map +1 -1
  111. package/expo-sqlite/driver.cjs +22 -5
  112. package/expo-sqlite/driver.cjs.map +1 -1
  113. package/expo-sqlite/driver.d.cts +3 -2
  114. package/expo-sqlite/driver.d.ts +3 -2
  115. package/expo-sqlite/driver.js +12 -8
  116. package/expo-sqlite/driver.js.map +1 -1
  117. package/expo-sqlite/migrator.cjs.map +1 -1
  118. package/expo-sqlite/migrator.d.cts +3 -2
  119. package/expo-sqlite/migrator.d.ts +3 -2
  120. package/expo-sqlite/migrator.js.map +1 -1
  121. package/expo-sqlite/query.cjs +13 -2
  122. package/expo-sqlite/query.cjs.map +1 -1
  123. package/expo-sqlite/query.d.cts +2 -1
  124. package/expo-sqlite/query.d.ts +2 -1
  125. package/expo-sqlite/query.js +3 -2
  126. package/expo-sqlite/query.js.map +1 -1
  127. package/expo-sqlite/session.cjs +47 -4
  128. package/expo-sqlite/session.cjs.map +1 -1
  129. package/expo-sqlite/session.d.cts +14 -8
  130. package/expo-sqlite/session.d.ts +14 -8
  131. package/expo-sqlite/session.js +47 -4
  132. package/expo-sqlite/session.js.map +1 -1
  133. package/libsql/driver-core.cjs +22 -5
  134. package/libsql/driver-core.cjs.map +1 -1
  135. package/libsql/driver-core.d.cts +2 -1
  136. package/libsql/driver-core.d.ts +2 -1
  137. package/libsql/driver-core.js +12 -8
  138. package/libsql/driver-core.js.map +1 -1
  139. package/libsql/driver.cjs.map +1 -1
  140. package/libsql/driver.d.cts +6 -5
  141. package/libsql/driver.d.ts +6 -5
  142. package/libsql/driver.js.map +1 -1
  143. package/libsql/http/index.cjs.map +1 -1
  144. package/libsql/http/index.d.cts +6 -5
  145. package/libsql/http/index.d.ts +6 -5
  146. package/libsql/http/index.js.map +1 -1
  147. package/libsql/migrator.cjs.map +1 -1
  148. package/libsql/migrator.d.cts +2 -1
  149. package/libsql/migrator.d.ts +2 -1
  150. package/libsql/migrator.js.map +1 -1
  151. package/libsql/node/index.cjs.map +1 -1
  152. package/libsql/node/index.d.cts +6 -5
  153. package/libsql/node/index.d.ts +6 -5
  154. package/libsql/node/index.js.map +1 -1
  155. package/libsql/session.cjs +56 -4
  156. package/libsql/session.cjs.map +1 -1
  157. package/libsql/session.d.cts +15 -9
  158. package/libsql/session.d.ts +15 -9
  159. package/libsql/session.js +56 -4
  160. package/libsql/session.js.map +1 -1
  161. package/libsql/sqlite3/index.cjs.map +1 -1
  162. package/libsql/sqlite3/index.d.cts +6 -5
  163. package/libsql/sqlite3/index.d.ts +6 -5
  164. package/libsql/sqlite3/index.js.map +1 -1
  165. package/libsql/wasm/index.cjs.map +1 -1
  166. package/libsql/wasm/index.d.cts +6 -5
  167. package/libsql/wasm/index.d.ts +6 -5
  168. package/libsql/wasm/index.js.map +1 -1
  169. package/libsql/web/index.cjs.map +1 -1
  170. package/libsql/web/index.d.cts +6 -5
  171. package/libsql/web/index.d.ts +6 -5
  172. package/libsql/web/index.js.map +1 -1
  173. package/libsql/ws/index.cjs.map +1 -1
  174. package/libsql/ws/index.d.cts +6 -5
  175. package/libsql/ws/index.d.ts +6 -5
  176. package/libsql/ws/index.js.map +1 -1
  177. package/mysql-core/db.cjs +30 -6
  178. package/mysql-core/db.cjs.map +1 -1
  179. package/mysql-core/db.d.cts +15 -8
  180. package/mysql-core/db.d.ts +15 -8
  181. package/mysql-core/db.js +29 -5
  182. package/mysql-core/db.js.map +1 -1
  183. package/mysql-core/dialect.cjs +187 -15
  184. package/mysql-core/dialect.cjs.map +1 -1
  185. package/mysql-core/dialect.d.cts +36 -13
  186. package/mysql-core/dialect.d.ts +36 -13
  187. package/mysql-core/dialect.js +185 -22
  188. package/mysql-core/dialect.js.map +1 -1
  189. package/mysql-core/query-builders/_query.cjs +149 -0
  190. package/mysql-core/query-builders/_query.cjs.map +1 -0
  191. package/mysql-core/query-builders/_query.d.cts +44 -0
  192. package/mysql-core/query-builders/_query.d.ts +44 -0
  193. package/mysql-core/query-builders/_query.js +114 -0
  194. package/mysql-core/query-builders/_query.js.map +1 -0
  195. package/mysql-core/query-builders/count.cjs.map +1 -1
  196. package/mysql-core/query-builders/count.d.cts +1 -1
  197. package/mysql-core/query-builders/count.d.ts +1 -1
  198. package/mysql-core/query-builders/count.js.map +1 -1
  199. package/mysql-core/query-builders/query.cjs +18 -31
  200. package/mysql-core/query-builders/query.cjs.map +1 -1
  201. package/mysql-core/query-builders/query.d.cts +8 -10
  202. package/mysql-core/query-builders/query.d.ts +8 -10
  203. package/mysql-core/query-builders/query.js +18 -31
  204. package/mysql-core/query-builders/query.js.map +1 -1
  205. package/mysql-core/session.cjs +3 -2
  206. package/mysql-core/session.cjs.map +1 -1
  207. package/mysql-core/session.d.cts +10 -7
  208. package/mysql-core/session.d.ts +10 -7
  209. package/mysql-core/session.js +3 -2
  210. package/mysql-core/session.js.map +1 -1
  211. package/mysql-proxy/driver.cjs +22 -5
  212. package/mysql-proxy/driver.cjs.map +1 -1
  213. package/mysql-proxy/driver.d.cts +3 -2
  214. package/mysql-proxy/driver.d.ts +3 -2
  215. package/mysql-proxy/driver.js +12 -8
  216. package/mysql-proxy/driver.js.map +1 -1
  217. package/mysql-proxy/migrator.cjs.map +1 -1
  218. package/mysql-proxy/migrator.d.cts +2 -1
  219. package/mysql-proxy/migrator.d.ts +2 -1
  220. package/mysql-proxy/migrator.js.map +1 -1
  221. package/mysql-proxy/session.cjs +27 -2
  222. package/mysql-proxy/session.cjs.map +1 -1
  223. package/mysql-proxy/session.d.cts +13 -8
  224. package/mysql-proxy/session.d.ts +13 -8
  225. package/mysql-proxy/session.js +27 -2
  226. package/mysql-proxy/session.js.map +1 -1
  227. package/mysql2/driver.cjs +24 -7
  228. package/mysql2/driver.cjs.map +1 -1
  229. package/mysql2/driver.d.cts +10 -9
  230. package/mysql2/driver.d.ts +10 -9
  231. package/mysql2/driver.js +14 -10
  232. package/mysql2/driver.js.map +1 -1
  233. package/mysql2/migrator.cjs.map +1 -1
  234. package/mysql2/migrator.d.cts +2 -1
  235. package/mysql2/migrator.d.ts +2 -1
  236. package/mysql2/migrator.js.map +1 -1
  237. package/mysql2/session.cjs +30 -2
  238. package/mysql2/session.cjs.map +1 -1
  239. package/mysql2/session.d.cts +13 -8
  240. package/mysql2/session.d.ts +13 -8
  241. package/mysql2/session.js +30 -2
  242. package/mysql2/session.js.map +1 -1
  243. package/neon-http/driver.cjs +21 -7
  244. package/neon-http/driver.cjs.map +1 -1
  245. package/neon-http/driver.d.cts +10 -9
  246. package/neon-http/driver.d.ts +10 -9
  247. package/neon-http/driver.js +11 -7
  248. package/neon-http/driver.js.map +1 -1
  249. package/neon-http/migrator.cjs.map +1 -1
  250. package/neon-http/migrator.d.cts +2 -1
  251. package/neon-http/migrator.d.ts +2 -1
  252. package/neon-http/migrator.js.map +1 -1
  253. package/neon-http/session.cjs +32 -2
  254. package/neon-http/session.cjs.map +1 -1
  255. package/neon-http/session.d.cts +13 -8
  256. package/neon-http/session.d.ts +13 -8
  257. package/neon-http/session.js +32 -2
  258. package/neon-http/session.js.map +1 -1
  259. package/neon-serverless/driver.cjs +18 -7
  260. package/neon-serverless/driver.cjs.map +1 -1
  261. package/neon-serverless/driver.d.cts +9 -8
  262. package/neon-serverless/driver.d.ts +9 -8
  263. package/neon-serverless/driver.js +8 -10
  264. package/neon-serverless/driver.js.map +1 -1
  265. package/neon-serverless/migrator.cjs.map +1 -1
  266. package/neon-serverless/migrator.d.cts +2 -1
  267. package/neon-serverless/migrator.d.ts +2 -1
  268. package/neon-serverless/migrator.js.map +1 -1
  269. package/neon-serverless/session.cjs +40 -5
  270. package/neon-serverless/session.cjs.map +1 -1
  271. package/neon-serverless/session.d.cts +13 -8
  272. package/neon-serverless/session.d.ts +13 -8
  273. package/neon-serverless/session.js +40 -5
  274. package/neon-serverless/session.js.map +1 -1
  275. package/node-postgres/driver.cjs +13 -7
  276. package/node-postgres/driver.cjs.map +1 -1
  277. package/node-postgres/driver.d.cts +9 -8
  278. package/node-postgres/driver.d.ts +9 -8
  279. package/node-postgres/driver.js +13 -10
  280. package/node-postgres/driver.js.map +1 -1
  281. package/node-postgres/migrator.cjs.map +1 -1
  282. package/node-postgres/migrator.d.cts +2 -1
  283. package/node-postgres/migrator.d.ts +2 -1
  284. package/node-postgres/migrator.js.map +1 -1
  285. package/node-postgres/session.cjs +45 -4
  286. package/node-postgres/session.cjs.map +1 -1
  287. package/node-postgres/session.d.cts +13 -8
  288. package/node-postgres/session.d.ts +13 -8
  289. package/node-postgres/session.js +45 -4
  290. package/node-postgres/session.js.map +1 -1
  291. package/op-sqlite/driver.cjs +22 -5
  292. package/op-sqlite/driver.cjs.map +1 -1
  293. package/op-sqlite/driver.d.cts +3 -2
  294. package/op-sqlite/driver.d.ts +3 -2
  295. package/op-sqlite/driver.js +12 -8
  296. package/op-sqlite/driver.js.map +1 -1
  297. package/op-sqlite/migrator.cjs.map +1 -1
  298. package/op-sqlite/migrator.d.cts +3 -2
  299. package/op-sqlite/migrator.d.ts +3 -2
  300. package/op-sqlite/migrator.js.map +1 -1
  301. package/op-sqlite/session.cjs +47 -4
  302. package/op-sqlite/session.cjs.map +1 -1
  303. package/op-sqlite/session.d.cts +14 -8
  304. package/op-sqlite/session.d.ts +14 -8
  305. package/op-sqlite/session.js +47 -4
  306. package/op-sqlite/session.js.map +1 -1
  307. package/package.json +367 -1052
  308. package/pg-core/db.cjs +32 -5
  309. package/pg-core/db.cjs.map +1 -1
  310. package/pg-core/db.d.cts +16 -9
  311. package/pg-core/db.d.ts +16 -9
  312. package/pg-core/db.js +31 -4
  313. package/pg-core/db.js.map +1 -1
  314. package/pg-core/dialect.cjs +162 -488
  315. package/pg-core/dialect.cjs.map +1 -1
  316. package/pg-core/dialect.d.cts +27 -8
  317. package/pg-core/dialect.d.ts +27 -8
  318. package/pg-core/dialect.js +160 -495
  319. package/pg-core/dialect.js.map +1 -1
  320. package/{gel-core/query-builders/query.cjs → pg-core/query-builders/_query.cjs} +31 -15
  321. package/pg-core/query-builders/_query.cjs.map +1 -0
  322. package/pg-core/query-builders/_query.d.cts +47 -0
  323. package/pg-core/query-builders/_query.d.ts +47 -0
  324. package/{gel-core/query-builders/query.js → pg-core/query-builders/_query.js} +19 -15
  325. package/pg-core/query-builders/_query.js.map +1 -0
  326. package/pg-core/query-builders/count.cjs.map +1 -1
  327. package/pg-core/query-builders/count.d.cts +1 -1
  328. package/pg-core/query-builders/count.d.ts +1 -1
  329. package/pg-core/query-builders/count.js.map +1 -1
  330. package/pg-core/query-builders/query.cjs +15 -18
  331. package/pg-core/query-builders/query.cjs.map +1 -1
  332. package/pg-core/query-builders/query.d.cts +6 -6
  333. package/pg-core/query-builders/query.d.ts +6 -6
  334. package/pg-core/query-builders/query.js +15 -18
  335. package/pg-core/query-builders/query.js.map +1 -1
  336. package/pg-core/session.cjs +3 -2
  337. package/pg-core/session.cjs.map +1 -1
  338. package/pg-core/session.d.cts +9 -6
  339. package/pg-core/session.d.ts +9 -6
  340. package/pg-core/session.js +3 -2
  341. package/pg-core/session.js.map +1 -1
  342. package/pg-core/table.cjs +0 -2
  343. package/pg-core/table.cjs.map +1 -1
  344. package/pg-core/table.js +0 -2
  345. package/pg-core/table.js.map +1 -1
  346. package/pg-proxy/driver.cjs +21 -5
  347. package/pg-proxy/driver.cjs.map +1 -1
  348. package/pg-proxy/driver.d.cts +3 -2
  349. package/pg-proxy/driver.d.ts +3 -2
  350. package/pg-proxy/driver.js +11 -8
  351. package/pg-proxy/driver.js.map +1 -1
  352. package/pg-proxy/migrator.cjs.map +1 -1
  353. package/pg-proxy/migrator.d.cts +2 -1
  354. package/pg-proxy/migrator.d.ts +2 -1
  355. package/pg-proxy/migrator.js.map +1 -1
  356. package/pg-proxy/session.cjs +37 -2
  357. package/pg-proxy/session.cjs.map +1 -1
  358. package/pg-proxy/session.d.cts +13 -8
  359. package/pg-proxy/session.d.ts +13 -8
  360. package/pg-proxy/session.js +37 -2
  361. package/pg-proxy/session.js.map +1 -1
  362. package/pglite/driver.cjs +23 -7
  363. package/pglite/driver.cjs.map +1 -1
  364. package/pglite/driver.d.cts +9 -8
  365. package/pglite/driver.d.ts +9 -8
  366. package/pglite/driver.js +13 -10
  367. package/pglite/driver.js.map +1 -1
  368. package/pglite/migrator.cjs.map +1 -1
  369. package/pglite/migrator.d.cts +2 -1
  370. package/pglite/migrator.d.ts +2 -1
  371. package/pglite/migrator.js.map +1 -1
  372. package/pglite/session.cjs +34 -3
  373. package/pglite/session.cjs.map +1 -1
  374. package/pglite/session.d.cts +13 -8
  375. package/pglite/session.d.ts +13 -8
  376. package/pglite/session.js +34 -3
  377. package/pglite/session.js.map +1 -1
  378. package/planetscale-serverless/driver.cjs +22 -5
  379. package/planetscale-serverless/driver.cjs.map +1 -1
  380. package/planetscale-serverless/driver.d.cts +7 -6
  381. package/planetscale-serverless/driver.d.ts +7 -6
  382. package/planetscale-serverless/driver.js +12 -8
  383. package/planetscale-serverless/driver.js.map +1 -1
  384. package/planetscale-serverless/migrator.cjs.map +1 -1
  385. package/planetscale-serverless/migrator.d.cts +2 -1
  386. package/planetscale-serverless/migrator.d.ts +2 -1
  387. package/planetscale-serverless/migrator.js.map +1 -1
  388. package/planetscale-serverless/session.cjs +45 -5
  389. package/planetscale-serverless/session.cjs.map +1 -1
  390. package/planetscale-serverless/session.d.cts +14 -9
  391. package/planetscale-serverless/session.d.ts +14 -9
  392. package/planetscale-serverless/session.js +45 -5
  393. package/planetscale-serverless/session.js.map +1 -1
  394. package/postgres-js/driver.cjs +6 -5
  395. package/postgres-js/driver.cjs.map +1 -1
  396. package/postgres-js/driver.d.cts +7 -6
  397. package/postgres-js/driver.d.ts +7 -6
  398. package/postgres-js/driver.js +6 -8
  399. package/postgres-js/driver.js.map +1 -1
  400. package/postgres-js/migrator.cjs.map +1 -1
  401. package/postgres-js/migrator.d.cts +2 -1
  402. package/postgres-js/migrator.d.ts +2 -1
  403. package/postgres-js/migrator.js.map +1 -1
  404. package/postgres-js/session.cjs +51 -6
  405. package/postgres-js/session.cjs.map +1 -1
  406. package/postgres-js/session.d.cts +15 -9
  407. package/postgres-js/session.d.ts +15 -9
  408. package/postgres-js/session.js +51 -6
  409. package/postgres-js/session.js.map +1 -1
  410. package/prisma/mysql/driver.cjs +1 -1
  411. package/prisma/mysql/driver.cjs.map +1 -1
  412. package/prisma/mysql/driver.js +1 -1
  413. package/prisma/mysql/driver.js.map +1 -1
  414. package/prisma/mysql/session.cjs +3 -0
  415. package/prisma/mysql/session.cjs.map +1 -1
  416. package/prisma/mysql/session.d.cts +3 -1
  417. package/prisma/mysql/session.d.ts +3 -1
  418. package/prisma/mysql/session.js +3 -0
  419. package/prisma/mysql/session.js.map +1 -1
  420. package/prisma/pg/driver.cjs +1 -1
  421. package/prisma/pg/driver.cjs.map +1 -1
  422. package/prisma/pg/driver.js +1 -1
  423. package/prisma/pg/driver.js.map +1 -1
  424. package/prisma/pg/session.cjs +3 -0
  425. package/prisma/pg/session.cjs.map +1 -1
  426. package/prisma/pg/session.d.cts +3 -1
  427. package/prisma/pg/session.d.ts +3 -1
  428. package/prisma/pg/session.js +3 -0
  429. package/prisma/pg/session.js.map +1 -1
  430. package/prisma/sqlite/driver.cjs +1 -1
  431. package/prisma/sqlite/driver.cjs.map +1 -1
  432. package/prisma/sqlite/driver.js +1 -1
  433. package/prisma/sqlite/driver.js.map +1 -1
  434. package/prisma/sqlite/session.cjs +3 -0
  435. package/prisma/sqlite/session.cjs.map +1 -1
  436. package/prisma/sqlite/session.d.cts +4 -2
  437. package/prisma/sqlite/session.d.ts +4 -2
  438. package/prisma/sqlite/session.js +3 -0
  439. package/prisma/sqlite/session.js.map +1 -1
  440. package/relations.cjs +626 -245
  441. package/relations.cjs.map +1 -1
  442. package/relations.d.cts +305 -140
  443. package/relations.d.ts +305 -140
  444. package/relations.js +619 -240
  445. package/relations.js.map +1 -1
  446. package/singlestore/driver.cjs +1 -1
  447. package/singlestore/driver.cjs.map +1 -1
  448. package/singlestore/driver.d.cts +1 -1
  449. package/singlestore/driver.d.ts +1 -1
  450. package/singlestore/driver.js +3 -3
  451. package/singlestore/driver.js.map +1 -1
  452. package/singlestore/session.cjs.map +1 -1
  453. package/singlestore/session.d.cts +4 -4
  454. package/singlestore/session.d.ts +4 -4
  455. package/singlestore/session.js.map +1 -1
  456. package/singlestore-core/db.cjs.map +1 -1
  457. package/singlestore-core/db.d.cts +3 -3
  458. package/singlestore-core/db.d.ts +3 -3
  459. package/singlestore-core/db.js.map +1 -1
  460. package/singlestore-core/dialect.cjs +16 -6
  461. package/singlestore-core/dialect.cjs.map +1 -1
  462. package/singlestore-core/dialect.d.cts +6 -6
  463. package/singlestore-core/dialect.d.ts +6 -6
  464. package/singlestore-core/dialect.js +6 -12
  465. package/singlestore-core/dialect.js.map +1 -1
  466. package/singlestore-core/query-builders/query.cjs +12 -2
  467. package/singlestore-core/query-builders/query.cjs.map +1 -1
  468. package/singlestore-core/query-builders/query.d.cts +6 -6
  469. package/singlestore-core/query-builders/query.d.ts +6 -6
  470. package/singlestore-core/query-builders/query.js +2 -4
  471. package/singlestore-core/query-builders/query.js.map +1 -1
  472. package/singlestore-core/session.cjs.map +1 -1
  473. package/singlestore-core/session.d.cts +5 -5
  474. package/singlestore-core/session.d.ts +5 -5
  475. package/singlestore-core/session.js.map +1 -1
  476. package/singlestore-proxy/driver.cjs +1 -1
  477. package/singlestore-proxy/driver.cjs.map +1 -1
  478. package/singlestore-proxy/driver.js +3 -3
  479. package/singlestore-proxy/driver.js.map +1 -1
  480. package/singlestore-proxy/session.cjs.map +1 -1
  481. package/singlestore-proxy/session.d.cts +4 -4
  482. package/singlestore-proxy/session.d.ts +4 -4
  483. package/singlestore-proxy/session.js.map +1 -1
  484. package/sql/expressions/conditions.cjs.map +1 -1
  485. package/sql/expressions/conditions.d.cts +4 -4
  486. package/sql/expressions/conditions.d.ts +4 -4
  487. package/sql/expressions/conditions.js.map +1 -1
  488. package/sql/sql.cjs +21 -0
  489. package/sql/sql.cjs.map +1 -1
  490. package/sql/sql.d.cts +8 -8
  491. package/sql/sql.d.ts +8 -8
  492. package/sql/sql.js +22 -1
  493. package/sql/sql.js.map +1 -1
  494. package/sql-js/driver.cjs +16 -5
  495. package/sql-js/driver.cjs.map +1 -1
  496. package/sql-js/driver.d.cts +3 -2
  497. package/sql-js/driver.d.ts +3 -2
  498. package/sql-js/driver.js +6 -8
  499. package/sql-js/driver.js.map +1 -1
  500. package/sql-js/migrator.cjs.map +1 -1
  501. package/sql-js/migrator.d.cts +2 -1
  502. package/sql-js/migrator.d.ts +2 -1
  503. package/sql-js/migrator.js.map +1 -1
  504. package/sql-js/session.cjs +71 -36
  505. package/sql-js/session.cjs.map +1 -1
  506. package/sql-js/session.d.cts +16 -13
  507. package/sql-js/session.d.ts +16 -13
  508. package/sql-js/session.js +71 -36
  509. package/sql-js/session.js.map +1 -1
  510. package/sqlite-core/db.cjs +39 -12
  511. package/sqlite-core/db.cjs.map +1 -1
  512. package/sqlite-core/db.d.cts +16 -8
  513. package/sqlite-core/db.d.ts +16 -8
  514. package/sqlite-core/db.js +38 -11
  515. package/sqlite-core/db.js.map +1 -1
  516. package/sqlite-core/dialect.cjs +176 -7
  517. package/sqlite-core/dialect.cjs.map +1 -1
  518. package/sqlite-core/dialect.d.cts +31 -9
  519. package/sqlite-core/dialect.d.ts +31 -9
  520. package/sqlite-core/dialect.js +174 -14
  521. package/sqlite-core/dialect.js.map +1 -1
  522. package/sqlite-core/query-builders/_query.cjs +187 -0
  523. package/sqlite-core/query-builders/_query.cjs.map +1 -0
  524. package/sqlite-core/query-builders/_query.d.cts +55 -0
  525. package/sqlite-core/query-builders/_query.d.ts +55 -0
  526. package/sqlite-core/query-builders/_query.js +151 -0
  527. package/sqlite-core/query-builders/_query.js.map +1 -0
  528. package/sqlite-core/query-builders/count.cjs.map +1 -1
  529. package/sqlite-core/query-builders/count.d.cts +1 -1
  530. package/sqlite-core/query-builders/count.d.ts +1 -1
  531. package/sqlite-core/query-builders/count.js.map +1 -1
  532. package/sqlite-core/query-builders/delete.cjs.map +1 -1
  533. package/sqlite-core/query-builders/delete.d.cts +1 -1
  534. package/sqlite-core/query-builders/delete.d.ts +1 -1
  535. package/sqlite-core/query-builders/delete.js.map +1 -1
  536. package/sqlite-core/query-builders/insert.cjs.map +1 -1
  537. package/sqlite-core/query-builders/insert.d.cts +3 -3
  538. package/sqlite-core/query-builders/insert.d.ts +3 -3
  539. package/sqlite-core/query-builders/insert.js.map +1 -1
  540. package/sqlite-core/query-builders/query.cjs +56 -35
  541. package/sqlite-core/query-builders/query.cjs.map +1 -1
  542. package/sqlite-core/query-builders/query.d.cts +18 -17
  543. package/sqlite-core/query-builders/query.d.ts +18 -17
  544. package/sqlite-core/query-builders/query.js +56 -35
  545. package/sqlite-core/query-builders/query.js.map +1 -1
  546. package/sqlite-core/query-builders/select.cjs.map +1 -1
  547. package/sqlite-core/query-builders/select.d.cts +3 -3
  548. package/sqlite-core/query-builders/select.d.ts +3 -3
  549. package/sqlite-core/query-builders/select.js.map +1 -1
  550. package/sqlite-core/query-builders/update.cjs.map +1 -1
  551. package/sqlite-core/query-builders/update.d.cts +3 -3
  552. package/sqlite-core/query-builders/update.d.ts +3 -3
  553. package/sqlite-core/query-builders/update.js.map +1 -1
  554. package/sqlite-core/session.cjs +6 -2
  555. package/sqlite-core/session.cjs.map +1 -1
  556. package/sqlite-core/session.d.cts +15 -7
  557. package/sqlite-core/session.d.ts +15 -7
  558. package/sqlite-core/session.js +6 -2
  559. package/sqlite-core/session.js.map +1 -1
  560. package/sqlite-proxy/driver.cjs +23 -5
  561. package/sqlite-proxy/driver.cjs.map +1 -1
  562. package/sqlite-proxy/driver.d.cts +4 -3
  563. package/sqlite-proxy/driver.d.ts +4 -3
  564. package/sqlite-proxy/driver.js +13 -5
  565. package/sqlite-proxy/driver.js.map +1 -1
  566. package/sqlite-proxy/migrator.cjs.map +1 -1
  567. package/sqlite-proxy/migrator.d.cts +2 -1
  568. package/sqlite-proxy/migrator.d.ts +2 -1
  569. package/sqlite-proxy/migrator.js.map +1 -1
  570. package/sqlite-proxy/session.cjs +50 -6
  571. package/sqlite-proxy/session.cjs.map +1 -1
  572. package/sqlite-proxy/session.d.cts +14 -8
  573. package/sqlite-proxy/session.d.ts +14 -8
  574. package/sqlite-proxy/session.js +50 -6
  575. package/sqlite-proxy/session.js.map +1 -1
  576. package/table.cjs.map +1 -1
  577. package/table.d.cts +2 -2
  578. package/table.d.ts +2 -2
  579. package/table.js.map +1 -1
  580. package/tidb-serverless/driver.cjs +22 -5
  581. package/tidb-serverless/driver.cjs.map +1 -1
  582. package/tidb-serverless/driver.d.cts +7 -6
  583. package/tidb-serverless/driver.d.ts +7 -6
  584. package/tidb-serverless/driver.js +12 -8
  585. package/tidb-serverless/driver.js.map +1 -1
  586. package/tidb-serverless/migrator.cjs.map +1 -1
  587. package/tidb-serverless/migrator.d.cts +2 -1
  588. package/tidb-serverless/migrator.d.ts +2 -1
  589. package/tidb-serverless/migrator.js.map +1 -1
  590. package/tidb-serverless/session.cjs +62 -5
  591. package/tidb-serverless/session.cjs.map +1 -1
  592. package/tidb-serverless/session.d.cts +14 -9
  593. package/tidb-serverless/session.d.ts +14 -9
  594. package/tidb-serverless/session.js +62 -5
  595. package/tidb-serverless/session.js.map +1 -1
  596. package/utils.cjs +2 -2
  597. package/utils.cjs.map +1 -1
  598. package/utils.d.cts +3 -1
  599. package/utils.d.ts +3 -1
  600. package/utils.js +2 -2
  601. package/utils.js.map +1 -1
  602. package/vercel-postgres/driver.cjs +23 -7
  603. package/vercel-postgres/driver.cjs.map +1 -1
  604. package/vercel-postgres/driver.d.cts +9 -8
  605. package/vercel-postgres/driver.d.ts +9 -8
  606. package/vercel-postgres/driver.js +13 -10
  607. package/vercel-postgres/driver.js.map +1 -1
  608. package/vercel-postgres/migrator.cjs.map +1 -1
  609. package/vercel-postgres/migrator.d.cts +2 -1
  610. package/vercel-postgres/migrator.d.ts +2 -1
  611. package/vercel-postgres/migrator.js.map +1 -1
  612. package/vercel-postgres/session.cjs +34 -4
  613. package/vercel-postgres/session.cjs.map +1 -1
  614. package/vercel-postgres/session.d.cts +13 -8
  615. package/vercel-postgres/session.d.ts +13 -8
  616. package/vercel-postgres/session.js +34 -4
  617. package/vercel-postgres/session.js.map +1 -1
  618. package/version.cjs +1 -1
  619. package/version.d.cts +1 -1
  620. package/version.d.ts +1 -1
  621. package/version.js +1 -1
  622. package/xata-http/driver.cjs +17 -5
  623. package/xata-http/driver.cjs.map +1 -1
  624. package/xata-http/driver.d.cts +5 -4
  625. package/xata-http/driver.d.ts +5 -4
  626. package/xata-http/driver.js +7 -5
  627. package/xata-http/driver.js.map +1 -1
  628. package/xata-http/migrator.cjs.map +1 -1
  629. package/xata-http/migrator.d.cts +2 -1
  630. package/xata-http/migrator.d.ts +2 -1
  631. package/xata-http/migrator.js.map +1 -1
  632. package/xata-http/session.cjs +30 -2
  633. package/xata-http/session.cjs.map +1 -1
  634. package/xata-http/session.d.cts +13 -8
  635. package/xata-http/session.d.ts +13 -8
  636. package/xata-http/session.js +30 -2
  637. package/xata-http/session.js.map +1 -1
  638. package/gel/driver.cjs +0 -97
  639. package/gel/driver.cjs.map +0 -1
  640. package/gel/driver.d.cts +0 -38
  641. package/gel/driver.d.ts +0 -38
  642. package/gel/driver.js +0 -74
  643. package/gel/driver.js.map +0 -1
  644. package/gel/index.cjs +0 -25
  645. package/gel/index.cjs.map +0 -1
  646. package/gel/index.d.cts +0 -2
  647. package/gel/index.d.ts +0 -2
  648. package/gel/index.js +0 -3
  649. package/gel/index.js.map +0 -1
  650. package/gel/migrator.cjs +0 -5
  651. package/gel/migrator.cjs.map +0 -1
  652. package/gel/migrator.d.cts +0 -1
  653. package/gel/migrator.d.ts +0 -1
  654. package/gel/migrator.js +0 -4
  655. package/gel/migrator.js.map +0 -1
  656. package/gel/session.cjs +0 -139
  657. package/gel/session.cjs.map +0 -1
  658. package/gel/session.d.cts +0 -47
  659. package/gel/session.d.ts +0 -47
  660. package/gel/session.js +0 -113
  661. package/gel/session.js.map +0 -1
  662. package/gel-core/alias.cjs +0 -32
  663. package/gel-core/alias.cjs.map +0 -1
  664. package/gel-core/alias.d.cts +0 -4
  665. package/gel-core/alias.d.ts +0 -4
  666. package/gel-core/alias.js +0 -8
  667. package/gel-core/alias.js.map +0 -1
  668. package/gel-core/checks.cjs +0 -58
  669. package/gel-core/checks.cjs.map +0 -1
  670. package/gel-core/checks.d.cts +0 -18
  671. package/gel-core/checks.d.ts +0 -18
  672. package/gel-core/checks.js +0 -32
  673. package/gel-core/checks.js.map +0 -1
  674. package/gel-core/columns/all.cjs +0 -72
  675. package/gel-core/columns/all.cjs.map +0 -1
  676. package/gel-core/columns/all.d.cts +0 -43
  677. package/gel-core/columns/all.d.ts +0 -43
  678. package/gel-core/columns/all.js +0 -48
  679. package/gel-core/columns/all.js.map +0 -1
  680. package/gel-core/columns/bigint.cjs +0 -54
  681. package/gel-core/columns/bigint.cjs.map +0 -1
  682. package/gel-core/columns/bigint.d.cts +0 -23
  683. package/gel-core/columns/bigint.d.ts +0 -23
  684. package/gel-core/columns/bigint.js +0 -28
  685. package/gel-core/columns/bigint.js.map +0 -1
  686. package/gel-core/columns/bigintT.cjs +0 -60
  687. package/gel-core/columns/bigintT.cjs.map +0 -1
  688. package/gel-core/columns/bigintT.d.cts +0 -24
  689. package/gel-core/columns/bigintT.d.ts +0 -24
  690. package/gel-core/columns/bigintT.js +0 -34
  691. package/gel-core/columns/bigintT.js.map +0 -1
  692. package/gel-core/columns/boolean.cjs +0 -53
  693. package/gel-core/columns/boolean.cjs.map +0 -1
  694. package/gel-core/columns/boolean.d.cts +0 -22
  695. package/gel-core/columns/boolean.d.ts +0 -22
  696. package/gel-core/columns/boolean.js +0 -27
  697. package/gel-core/columns/boolean.js.map +0 -1
  698. package/gel-core/columns/bytes.cjs +0 -56
  699. package/gel-core/columns/bytes.cjs.map +0 -1
  700. package/gel-core/columns/bytes.d.cts +0 -22
  701. package/gel-core/columns/bytes.d.ts +0 -22
  702. package/gel-core/columns/bytes.js +0 -30
  703. package/gel-core/columns/bytes.js.map +0 -1
  704. package/gel-core/columns/common.cjs +0 -213
  705. package/gel-core/columns/common.cjs.map +0 -1
  706. package/gel-core/columns/common.d.cts +0 -147
  707. package/gel-core/columns/common.d.ts +0 -147
  708. package/gel-core/columns/common.js +0 -184
  709. package/gel-core/columns/common.js.map +0 -1
  710. package/gel-core/columns/custom.cjs +0 -77
  711. package/gel-core/columns/custom.cjs.map +0 -1
  712. package/gel-core/columns/custom.d.cts +0 -155
  713. package/gel-core/columns/custom.d.ts +0 -155
  714. package/gel-core/columns/custom.js +0 -51
  715. package/gel-core/columns/custom.js.map +0 -1
  716. package/gel-core/columns/date-duration.cjs +0 -56
  717. package/gel-core/columns/date-duration.cjs.map +0 -1
  718. package/gel-core/columns/date-duration.d.cts +0 -23
  719. package/gel-core/columns/date-duration.d.ts +0 -23
  720. package/gel-core/columns/date-duration.js +0 -30
  721. package/gel-core/columns/date-duration.js.map +0 -1
  722. package/gel-core/columns/date.common.cjs +0 -37
  723. package/gel-core/columns/date.common.cjs.map +0 -1
  724. package/gel-core/columns/date.common.d.cts +0 -7
  725. package/gel-core/columns/date.common.d.ts +0 -7
  726. package/gel-core/columns/date.common.js +0 -13
  727. package/gel-core/columns/date.common.js.map +0 -1
  728. package/gel-core/columns/decimal.cjs +0 -56
  729. package/gel-core/columns/decimal.cjs.map +0 -1
  730. package/gel-core/columns/decimal.d.cts +0 -26
  731. package/gel-core/columns/decimal.d.ts +0 -26
  732. package/gel-core/columns/decimal.js +0 -30
  733. package/gel-core/columns/decimal.js.map +0 -1
  734. package/gel-core/columns/double-precision.cjs +0 -62
  735. package/gel-core/columns/double-precision.cjs.map +0 -1
  736. package/gel-core/columns/double-precision.d.cts +0 -23
  737. package/gel-core/columns/double-precision.d.ts +0 -23
  738. package/gel-core/columns/double-precision.js +0 -36
  739. package/gel-core/columns/double-precision.js.map +0 -1
  740. package/gel-core/columns/duration.cjs +0 -53
  741. package/gel-core/columns/duration.cjs.map +0 -1
  742. package/gel-core/columns/duration.d.cts +0 -23
  743. package/gel-core/columns/duration.d.ts +0 -23
  744. package/gel-core/columns/duration.js +0 -27
  745. package/gel-core/columns/duration.js.map +0 -1
  746. package/gel-core/columns/index.cjs +0 -65
  747. package/gel-core/columns/index.cjs.map +0 -1
  748. package/gel-core/columns/index.d.cts +0 -22
  749. package/gel-core/columns/index.d.ts +0 -22
  750. package/gel-core/columns/index.js +0 -23
  751. package/gel-core/columns/index.js.map +0 -1
  752. package/gel-core/columns/int.common.cjs +0 -67
  753. package/gel-core/columns/int.common.cjs.map +0 -1
  754. package/gel-core/columns/int.common.d.cts +0 -15
  755. package/gel-core/columns/int.common.d.ts +0 -15
  756. package/gel-core/columns/int.common.js +0 -43
  757. package/gel-core/columns/int.common.js.map +0 -1
  758. package/gel-core/columns/integer.cjs +0 -54
  759. package/gel-core/columns/integer.cjs.map +0 -1
  760. package/gel-core/columns/integer.d.cts +0 -23
  761. package/gel-core/columns/integer.d.ts +0 -23
  762. package/gel-core/columns/integer.js +0 -28
  763. package/gel-core/columns/integer.js.map +0 -1
  764. package/gel-core/columns/json.cjs +0 -56
  765. package/gel-core/columns/json.cjs.map +0 -1
  766. package/gel-core/columns/json.d.cts +0 -26
  767. package/gel-core/columns/json.d.ts +0 -26
  768. package/gel-core/columns/json.js +0 -30
  769. package/gel-core/columns/json.js.map +0 -1
  770. package/gel-core/columns/localdate.cjs +0 -57
  771. package/gel-core/columns/localdate.cjs.map +0 -1
  772. package/gel-core/columns/localdate.d.cts +0 -24
  773. package/gel-core/columns/localdate.d.ts +0 -24
  774. package/gel-core/columns/localdate.js +0 -31
  775. package/gel-core/columns/localdate.js.map +0 -1
  776. package/gel-core/columns/localtime.cjs +0 -57
  777. package/gel-core/columns/localtime.cjs.map +0 -1
  778. package/gel-core/columns/localtime.d.cts +0 -24
  779. package/gel-core/columns/localtime.d.ts +0 -24
  780. package/gel-core/columns/localtime.js +0 -31
  781. package/gel-core/columns/localtime.js.map +0 -1
  782. package/gel-core/columns/real.cjs +0 -57
  783. package/gel-core/columns/real.cjs.map +0 -1
  784. package/gel-core/columns/real.d.cts +0 -28
  785. package/gel-core/columns/real.d.ts +0 -28
  786. package/gel-core/columns/real.js +0 -31
  787. package/gel-core/columns/real.js.map +0 -1
  788. package/gel-core/columns/relative-duration.cjs +0 -56
  789. package/gel-core/columns/relative-duration.cjs.map +0 -1
  790. package/gel-core/columns/relative-duration.d.cts +0 -23
  791. package/gel-core/columns/relative-duration.d.ts +0 -23
  792. package/gel-core/columns/relative-duration.js +0 -30
  793. package/gel-core/columns/relative-duration.js.map +0 -1
  794. package/gel-core/columns/smallint.cjs +0 -54
  795. package/gel-core/columns/smallint.cjs.map +0 -1
  796. package/gel-core/columns/smallint.d.cts +0 -23
  797. package/gel-core/columns/smallint.d.ts +0 -23
  798. package/gel-core/columns/smallint.js +0 -28
  799. package/gel-core/columns/smallint.js.map +0 -1
  800. package/gel-core/columns/text.cjs +0 -54
  801. package/gel-core/columns/text.cjs.map +0 -1
  802. package/gel-core/columns/text.d.cts +0 -26
  803. package/gel-core/columns/text.d.ts +0 -26
  804. package/gel-core/columns/text.js +0 -28
  805. package/gel-core/columns/text.js.map +0 -1
  806. package/gel-core/columns/timestamp.cjs +0 -60
  807. package/gel-core/columns/timestamp.cjs.map +0 -1
  808. package/gel-core/columns/timestamp.d.cts +0 -28
  809. package/gel-core/columns/timestamp.d.ts +0 -28
  810. package/gel-core/columns/timestamp.js +0 -34
  811. package/gel-core/columns/timestamp.js.map +0 -1
  812. package/gel-core/columns/timestamptz.cjs +0 -60
  813. package/gel-core/columns/timestamptz.cjs.map +0 -1
  814. package/gel-core/columns/timestamptz.d.cts +0 -27
  815. package/gel-core/columns/timestamptz.d.ts +0 -27
  816. package/gel-core/columns/timestamptz.js +0 -34
  817. package/gel-core/columns/timestamptz.js.map +0 -1
  818. package/gel-core/columns/uuid.cjs +0 -53
  819. package/gel-core/columns/uuid.cjs.map +0 -1
  820. package/gel-core/columns/uuid.d.cts +0 -22
  821. package/gel-core/columns/uuid.d.ts +0 -22
  822. package/gel-core/columns/uuid.js +0 -27
  823. package/gel-core/columns/uuid.js.map +0 -1
  824. package/gel-core/db.cjs +0 -338
  825. package/gel-core/db.cjs.map +0 -1
  826. package/gel-core/db.d.cts +0 -281
  827. package/gel-core/db.d.ts +0 -281
  828. package/gel-core/db.js +0 -319
  829. package/gel-core/db.js.map +0 -1
  830. package/gel-core/dialect.cjs +0 -1142
  831. package/gel-core/dialect.cjs.map +0 -1
  832. package/gel-core/dialect.d.cts +0 -62
  833. package/gel-core/dialect.d.ts +0 -62
  834. package/gel-core/dialect.js +0 -1128
  835. package/gel-core/dialect.js.map +0 -1
  836. package/gel-core/expressions.cjs +0 -49
  837. package/gel-core/expressions.cjs.map +0 -1
  838. package/gel-core/expressions.d.cts +0 -8
  839. package/gel-core/expressions.d.ts +0 -8
  840. package/gel-core/expressions.js +0 -22
  841. package/gel-core/expressions.js.map +0 -1
  842. package/gel-core/foreign-keys.cjs +0 -100
  843. package/gel-core/foreign-keys.cjs.map +0 -1
  844. package/gel-core/foreign-keys.d.cts +0 -48
  845. package/gel-core/foreign-keys.d.ts +0 -48
  846. package/gel-core/foreign-keys.js +0 -74
  847. package/gel-core/foreign-keys.js.map +0 -1
  848. package/gel-core/index.cjs +0 -61
  849. package/gel-core/index.cjs.map +0 -1
  850. package/gel-core/index.d.cts +0 -20
  851. package/gel-core/index.d.ts +0 -20
  852. package/gel-core/index.js +0 -21
  853. package/gel-core/index.js.map +0 -1
  854. package/gel-core/indexes.cjs +0 -149
  855. package/gel-core/indexes.cjs.map +0 -1
  856. package/gel-core/indexes.d.cts +0 -79
  857. package/gel-core/indexes.d.ts +0 -79
  858. package/gel-core/indexes.js +0 -121
  859. package/gel-core/indexes.js.map +0 -1
  860. package/gel-core/policies.cjs +0 -58
  861. package/gel-core/policies.cjs.map +0 -1
  862. package/gel-core/policies.d.cts +0 -24
  863. package/gel-core/policies.d.ts +0 -24
  864. package/gel-core/policies.js +0 -33
  865. package/gel-core/policies.js.map +0 -1
  866. package/gel-core/primary-keys.cjs +0 -68
  867. package/gel-core/primary-keys.cjs.map +0 -1
  868. package/gel-core/primary-keys.d.cts +0 -30
  869. package/gel-core/primary-keys.d.ts +0 -30
  870. package/gel-core/primary-keys.js +0 -42
  871. package/gel-core/primary-keys.js.map +0 -1
  872. package/gel-core/query-builders/count.cjs +0 -73
  873. package/gel-core/query-builders/count.cjs.map +0 -1
  874. package/gel-core/query-builders/count.d.cts +0 -25
  875. package/gel-core/query-builders/count.d.ts +0 -25
  876. package/gel-core/query-builders/count.js +0 -49
  877. package/gel-core/query-builders/count.js.map +0 -1
  878. package/gel-core/query-builders/delete.cjs +0 -105
  879. package/gel-core/query-builders/delete.cjs.map +0 -1
  880. package/gel-core/query-builders/delete.d.cts +0 -99
  881. package/gel-core/query-builders/delete.d.ts +0 -99
  882. package/gel-core/query-builders/delete.js +0 -81
  883. package/gel-core/query-builders/delete.js.map +0 -1
  884. package/gel-core/query-builders/index.cjs +0 -35
  885. package/gel-core/query-builders/index.cjs.map +0 -1
  886. package/gel-core/query-builders/index.d.cts +0 -7
  887. package/gel-core/query-builders/index.d.ts +0 -7
  888. package/gel-core/query-builders/index.js +0 -8
  889. package/gel-core/query-builders/index.js.map +0 -1
  890. package/gel-core/query-builders/insert.cjs +0 -218
  891. package/gel-core/query-builders/insert.cjs.map +0 -1
  892. package/gel-core/query-builders/insert.d.cts +0 -116
  893. package/gel-core/query-builders/insert.d.ts +0 -116
  894. package/gel-core/query-builders/insert.js +0 -193
  895. package/gel-core/query-builders/insert.js.map +0 -1
  896. package/gel-core/query-builders/query-builder.cjs +0 -114
  897. package/gel-core/query-builders/query-builder.cjs.map +0 -1
  898. package/gel-core/query-builders/query-builder.d.cts +0 -40
  899. package/gel-core/query-builders/query-builder.d.ts +0 -40
  900. package/gel-core/query-builders/query-builder.js +0 -90
  901. package/gel-core/query-builders/query-builder.js.map +0 -1
  902. package/gel-core/query-builders/query.cjs.map +0 -1
  903. package/gel-core/query-builders/query.d.cts +0 -46
  904. package/gel-core/query-builders/query.d.ts +0 -46
  905. package/gel-core/query-builders/query.js.map +0 -1
  906. package/gel-core/query-builders/raw.cjs +0 -57
  907. package/gel-core/query-builders/raw.cjs.map +0 -1
  908. package/gel-core/query-builders/raw.d.cts +0 -22
  909. package/gel-core/query-builders/raw.d.ts +0 -22
  910. package/gel-core/query-builders/raw.js +0 -33
  911. package/gel-core/query-builders/raw.js.map +0 -1
  912. package/gel-core/query-builders/refresh-materialized-view.cjs +0 -77
  913. package/gel-core/query-builders/refresh-materialized-view.cjs.map +0 -1
  914. package/gel-core/query-builders/refresh-materialized-view.d.cts +0 -27
  915. package/gel-core/query-builders/refresh-materialized-view.d.ts +0 -27
  916. package/gel-core/query-builders/refresh-materialized-view.js +0 -53
  917. package/gel-core/query-builders/refresh-materialized-view.js.map +0 -1
  918. package/gel-core/query-builders/select.cjs +0 -775
  919. package/gel-core/query-builders/select.cjs.map +0 -1
  920. package/gel-core/query-builders/select.d.cts +0 -721
  921. package/gel-core/query-builders/select.d.ts +0 -721
  922. package/gel-core/query-builders/select.js +0 -748
  923. package/gel-core/query-builders/select.js.map +0 -1
  924. package/gel-core/query-builders/select.types.cjs +0 -17
  925. package/gel-core/query-builders/select.types.cjs.map +0 -1
  926. package/gel-core/query-builders/select.types.d.cts +0 -138
  927. package/gel-core/query-builders/select.types.d.ts +0 -138
  928. package/gel-core/query-builders/select.types.js +0 -1
  929. package/gel-core/query-builders/select.types.js.map +0 -1
  930. package/gel-core/query-builders/update.cjs +0 -226
  931. package/gel-core/query-builders/update.cjs.map +0 -1
  932. package/gel-core/query-builders/update.d.cts +0 -166
  933. package/gel-core/query-builders/update.d.ts +0 -166
  934. package/gel-core/query-builders/update.js +0 -205
  935. package/gel-core/query-builders/update.js.map +0 -1
  936. package/gel-core/roles.cjs +0 -57
  937. package/gel-core/roles.cjs.map +0 -1
  938. package/gel-core/roles.d.cts +0 -13
  939. package/gel-core/roles.d.ts +0 -13
  940. package/gel-core/roles.js +0 -32
  941. package/gel-core/roles.js.map +0 -1
  942. package/gel-core/schema.cjs +0 -74
  943. package/gel-core/schema.cjs.map +0 -1
  944. package/gel-core/schema.d.cts +0 -15
  945. package/gel-core/schema.d.ts +0 -15
  946. package/gel-core/schema.js +0 -48
  947. package/gel-core/schema.js.map +0 -1
  948. package/gel-core/sequence.cjs +0 -52
  949. package/gel-core/sequence.cjs.map +0 -1
  950. package/gel-core/sequence.d.cts +0 -18
  951. package/gel-core/sequence.d.ts +0 -18
  952. package/gel-core/sequence.js +0 -25
  953. package/gel-core/sequence.js.map +0 -1
  954. package/gel-core/session.cjs +0 -94
  955. package/gel-core/session.cjs.map +0 -1
  956. package/gel-core/session.d.cts +0 -56
  957. package/gel-core/session.d.ts +0 -56
  958. package/gel-core/session.js +0 -68
  959. package/gel-core/session.js.map +0 -1
  960. package/gel-core/subquery.cjs +0 -17
  961. package/gel-core/subquery.cjs.map +0 -1
  962. package/gel-core/subquery.d.cts +0 -5
  963. package/gel-core/subquery.d.ts +0 -5
  964. package/gel-core/subquery.js +0 -1
  965. package/gel-core/subquery.js.map +0 -1
  966. package/gel-core/table.cjs +0 -100
  967. package/gel-core/table.cjs.map +0 -1
  968. package/gel-core/table.d.cts +0 -95
  969. package/gel-core/table.d.ts +0 -95
  970. package/gel-core/table.js +0 -71
  971. package/gel-core/table.js.map +0 -1
  972. package/gel-core/unique-constraint.cjs +0 -89
  973. package/gel-core/unique-constraint.cjs.map +0 -1
  974. package/gel-core/unique-constraint.d.cts +0 -25
  975. package/gel-core/unique-constraint.d.ts +0 -25
  976. package/gel-core/unique-constraint.js +0 -61
  977. package/gel-core/unique-constraint.js.map +0 -1
  978. package/gel-core/utils.cjs +0 -100
  979. package/gel-core/utils.cjs.map +0 -1
  980. package/gel-core/utils.d.cts +0 -51
  981. package/gel-core/utils.d.ts +0 -51
  982. package/gel-core/utils.js +0 -74
  983. package/gel-core/utils.js.map +0 -1
  984. package/gel-core/view-base.cjs +0 -33
  985. package/gel-core/view-base.cjs.map +0 -1
  986. package/gel-core/view-base.d.cts +0 -8
  987. package/gel-core/view-base.d.ts +0 -8
  988. package/gel-core/view-base.js +0 -9
  989. package/gel-core/view-base.js.map +0 -1
  990. package/gel-core/view-common.cjs +0 -29
  991. package/gel-core/view-common.cjs.map +0 -1
  992. package/gel-core/view-common.d.cts +0 -1
  993. package/gel-core/view-common.d.ts +0 -1
  994. package/gel-core/view-common.js +0 -5
  995. package/gel-core/view-common.js.map +0 -1
  996. package/gel-core/view.cjs +0 -302
  997. package/gel-core/view.cjs.map +0 -1
  998. package/gel-core/view.d.cts +0 -150
  999. package/gel-core/view.d.ts +0 -150
  1000. package/gel-core/view.js +0 -268
  1001. package/gel-core/view.js.map +0 -1
@@ -1,1142 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var dialect_exports = {};
20
- __export(dialect_exports, {
21
- GelDialect: () => GelDialect
22
- });
23
- module.exports = __toCommonJS(dialect_exports);
24
- var import_alias = require("../alias.cjs");
25
- var import_casing = require("../casing.cjs");
26
- var import_column = require("../column.cjs");
27
- var import_entity = require("../entity.cjs");
28
- var import_errors = require("../errors.cjs");
29
- var import_columns = require("./columns/index.cjs");
30
- var import_table = require("./table.cjs");
31
- var import_relations = require("../relations.cjs");
32
- var import_sql = require("../sql/index.cjs");
33
- var import_sql2 = require("../sql/sql.cjs");
34
- var import_subquery = require("../subquery.cjs");
35
- var import_table2 = require("../table.cjs");
36
- var import_utils = require("../utils.cjs");
37
- var import_view_common = require("../view-common.cjs");
38
- var import_timestamp = require("./columns/timestamp.cjs");
39
- var import_view_base = require("./view-base.cjs");
40
- class GelDialect {
41
- static [import_entity.entityKind] = "GelDialect";
42
- /** @internal */
43
- casing;
44
- constructor(config) {
45
- this.casing = new import_casing.CasingCache(config?.casing);
46
- }
47
- // TODO can not migrate gel with drizzle
48
- // async migrate(migrations: MigrationMeta[], session: GelSession, config: string | MigrationConfig): Promise<void> {
49
- // const migrationsTable = typeof config === 'string'
50
- // ? '__drizzle_migrations'
51
- // : config.migrationsTable ?? '__drizzle_migrations';
52
- // const migrationsSchema = typeof config === 'string' ? 'drizzle' : config.migrationsSchema ?? 'drizzle';
53
- // const migrationTableCreate = sql`
54
- // CREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)} (
55
- // id SERIAL PRIMARY KEY,
56
- // hash text NOT NULL,
57
- // created_at bigint
58
- // )
59
- // `;
60
- // await session.execute(sql`CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}`);
61
- // await session.execute(migrationTableCreate);
62
- // const dbMigrations = await session.all<{ id: number; hash: string; created_at: string }>(
63
- // sql`select id, hash, created_at from ${sql.identifier(migrationsSchema)}.${
64
- // sql.identifier(migrationsTable)
65
- // } order by created_at desc limit 1`,
66
- // );
67
- // const lastDbMigration = dbMigrations[0];
68
- // await session.transaction(async (tx) => {
69
- // for await (const migration of migrations) {
70
- // if (
71
- // !lastDbMigration
72
- // || Number(lastDbMigration.created_at) < migration.folderMillis
73
- // ) {
74
- // for (const stmt of migration.sql) {
75
- // await tx.execute(sql.raw(stmt));
76
- // }
77
- // await tx.execute(
78
- // sql`insert into ${sql.identifier(migrationsSchema)}.${
79
- // sql.identifier(migrationsTable)
80
- // } ("hash", "created_at") values(${migration.hash}, ${migration.folderMillis})`,
81
- // );
82
- // }
83
- // }
84
- // });
85
- // }
86
- escapeName(name) {
87
- return `"${name}"`;
88
- }
89
- escapeParam(num) {
90
- return `$${num + 1}`;
91
- }
92
- escapeString(str) {
93
- return `'${str.replace(/'/g, "''")}'`;
94
- }
95
- buildWithCTE(queries) {
96
- if (!queries?.length)
97
- return void 0;
98
- const withSqlChunks = [import_sql2.sql`with `];
99
- for (const [i, w] of queries.entries()) {
100
- withSqlChunks.push(import_sql2.sql`${import_sql2.sql.identifier(w._.alias)} as (${w._.sql})`);
101
- if (i < queries.length - 1) {
102
- withSqlChunks.push(import_sql2.sql`, `);
103
- }
104
- }
105
- withSqlChunks.push(import_sql2.sql` `);
106
- return import_sql2.sql.join(withSqlChunks);
107
- }
108
- buildDeleteQuery({ table, where, returning, withList }) {
109
- const withSql = this.buildWithCTE(withList);
110
- const returningSql = returning ? import_sql2.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
111
- const whereSql = where ? import_sql2.sql` where ${where}` : void 0;
112
- return import_sql2.sql`${withSql}delete from ${table}${whereSql}${returningSql}`;
113
- }
114
- buildUpdateSet(table, set) {
115
- const tableColumns = table[import_table2.Table.Symbol.Columns];
116
- const columnNames = Object.keys(tableColumns).filter(
117
- (colName) => set[colName] !== void 0 || tableColumns[colName]?.onUpdateFn !== void 0
118
- );
119
- const setSize = columnNames.length;
120
- return import_sql2.sql.join(columnNames.flatMap((colName, i) => {
121
- const col = tableColumns[colName];
122
- const value = set[colName] ?? import_sql2.sql.param(col.onUpdateFn(), col);
123
- const res = import_sql2.sql`${import_sql2.sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
124
- if (i < setSize - 1) {
125
- return [res, import_sql2.sql.raw(", ")];
126
- }
127
- return [res];
128
- }));
129
- }
130
- buildUpdateQuery({ table, set, where, returning, withList, from, joins }) {
131
- const withSql = this.buildWithCTE(withList);
132
- const tableName = table[import_table.GelTable.Symbol.Name];
133
- const tableSchema = table[import_table.GelTable.Symbol.Schema];
134
- const origTableName = table[import_table.GelTable.Symbol.OriginalName];
135
- const alias = tableName === origTableName ? void 0 : tableName;
136
- const tableSql = import_sql2.sql`${tableSchema ? import_sql2.sql`${import_sql2.sql.identifier(tableSchema)}.` : void 0}${import_sql2.sql.identifier(origTableName)}${alias && import_sql2.sql` ${import_sql2.sql.identifier(alias)}`}`;
137
- const setSql = this.buildUpdateSet(table, set);
138
- const fromSql = from && import_sql2.sql.join([import_sql2.sql.raw(" from "), this.buildFromTable(from)]);
139
- const joinsSql = this.buildJoins(joins);
140
- const returningSql = returning ? import_sql2.sql` returning ${this.buildSelection(returning, { isSingleTable: !from })}` : void 0;
141
- const whereSql = where ? import_sql2.sql` where ${where}` : void 0;
142
- return import_sql2.sql`${withSql}update ${tableSql} set ${setSql}${fromSql}${joinsSql}${whereSql}${returningSql}`;
143
- }
144
- /**
145
- * Builds selection SQL with provided fields/expressions
146
- *
147
- * Examples:
148
- *
149
- * `select <selection> from`
150
- *
151
- * `insert ... returning <selection>`
152
- *
153
- * If `isSingleTable` is true, then columns won't be prefixed with table name
154
- */
155
- buildSelection(fields, { isSingleTable = false } = {}) {
156
- const columnsLen = fields.length;
157
- const chunks = fields.flatMap(({ field }, i) => {
158
- const chunk = [];
159
- if ((0, import_entity.is)(field, import_sql2.SQL.Aliased) && field.isSelectionField) {
160
- chunk.push(import_sql2.sql.identifier(field.fieldAlias));
161
- } else if ((0, import_entity.is)(field, import_sql2.SQL.Aliased) || (0, import_entity.is)(field, import_sql2.SQL)) {
162
- const query = (0, import_entity.is)(field, import_sql2.SQL.Aliased) ? field.sql : field;
163
- if (isSingleTable) {
164
- chunk.push(
165
- new import_sql2.SQL(
166
- query.queryChunks.map((c) => {
167
- if ((0, import_entity.is)(c, import_columns.GelColumn)) {
168
- return import_sql2.sql.identifier(this.casing.getColumnCasing(c));
169
- }
170
- return c;
171
- })
172
- )
173
- );
174
- } else {
175
- chunk.push(query);
176
- }
177
- if ((0, import_entity.is)(field, import_sql2.SQL.Aliased)) {
178
- chunk.push(import_sql2.sql` as ${import_sql2.sql.identifier(field.fieldAlias)}`);
179
- }
180
- } else if ((0, import_entity.is)(field, import_column.Column)) {
181
- if (isSingleTable) {
182
- chunk.push(import_sql2.sql.identifier(this.casing.getColumnCasing(field)));
183
- } else {
184
- chunk.push(field);
185
- }
186
- }
187
- if (i < columnsLen - 1) {
188
- chunk.push(import_sql2.sql`, `);
189
- }
190
- return chunk;
191
- });
192
- return import_sql2.sql.join(chunks);
193
- }
194
- buildJoins(joins) {
195
- if (!joins || joins.length === 0) {
196
- return void 0;
197
- }
198
- const joinsArray = [];
199
- for (const [index, joinMeta] of joins.entries()) {
200
- if (index === 0) {
201
- joinsArray.push(import_sql2.sql` `);
202
- }
203
- const table = joinMeta.table;
204
- const lateralSql = joinMeta.lateral ? import_sql2.sql` lateral` : void 0;
205
- if ((0, import_entity.is)(table, import_table.GelTable)) {
206
- const tableName = table[import_table.GelTable.Symbol.Name];
207
- const tableSchema = table[import_table.GelTable.Symbol.Schema];
208
- const origTableName = table[import_table.GelTable.Symbol.OriginalName];
209
- const alias = tableName === origTableName ? void 0 : joinMeta.alias;
210
- joinsArray.push(
211
- import_sql2.sql`${import_sql2.sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? import_sql2.sql`${import_sql2.sql.identifier(tableSchema)}.` : void 0}${import_sql2.sql.identifier(origTableName)}${alias && import_sql2.sql` ${import_sql2.sql.identifier(alias)}`} on ${joinMeta.on}`
212
- );
213
- } else if ((0, import_entity.is)(table, import_sql.View)) {
214
- const viewName = table[import_view_common.ViewBaseConfig].name;
215
- const viewSchema = table[import_view_common.ViewBaseConfig].schema;
216
- const origViewName = table[import_view_common.ViewBaseConfig].originalName;
217
- const alias = viewName === origViewName ? void 0 : joinMeta.alias;
218
- joinsArray.push(
219
- import_sql2.sql`${import_sql2.sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? import_sql2.sql`${import_sql2.sql.identifier(viewSchema)}.` : void 0}${import_sql2.sql.identifier(origViewName)}${alias && import_sql2.sql` ${import_sql2.sql.identifier(alias)}`} on ${joinMeta.on}`
220
- );
221
- } else {
222
- joinsArray.push(
223
- import_sql2.sql`${import_sql2.sql.raw(joinMeta.joinType)} join${lateralSql} ${table} on ${joinMeta.on}`
224
- );
225
- }
226
- if (index < joins.length - 1) {
227
- joinsArray.push(import_sql2.sql` `);
228
- }
229
- }
230
- return import_sql2.sql.join(joinsArray);
231
- }
232
- buildFromTable(table) {
233
- if ((0, import_entity.is)(table, import_table2.Table) && table[import_table2.Table.Symbol.OriginalName] !== table[import_table2.Table.Symbol.Name]) {
234
- let fullName = import_sql2.sql`${import_sql2.sql.identifier(table[import_table2.Table.Symbol.OriginalName])}`;
235
- if (table[import_table2.Table.Symbol.Schema]) {
236
- fullName = import_sql2.sql`${import_sql2.sql.identifier(table[import_table2.Table.Symbol.Schema])}.${fullName}`;
237
- }
238
- return import_sql2.sql`${fullName} ${import_sql2.sql.identifier(table[import_table2.Table.Symbol.Name])}`;
239
- }
240
- return table;
241
- }
242
- buildSelectQuery({
243
- withList,
244
- fields,
245
- fieldsFlat,
246
- where,
247
- having,
248
- table,
249
- joins,
250
- orderBy,
251
- groupBy,
252
- limit,
253
- offset,
254
- lockingClause,
255
- distinct,
256
- setOperators
257
- }) {
258
- const fieldsList = fieldsFlat ?? (0, import_utils.orderSelectedFields)(fields);
259
- for (const f of fieldsList) {
260
- if ((0, import_entity.is)(f.field, import_column.Column) && (0, import_table2.getTableName)(f.field.table) !== ((0, import_entity.is)(table, import_subquery.Subquery) ? table._.alias : (0, import_entity.is)(table, import_view_base.GelViewBase) ? table[import_view_common.ViewBaseConfig].name : (0, import_entity.is)(table, import_sql2.SQL) ? void 0 : (0, import_table2.getTableName)(table)) && !((table2) => joins?.some(
261
- ({ alias }) => alias === (table2[import_table2.Table.Symbol.IsAlias] ? (0, import_table2.getTableName)(table2) : table2[import_table2.Table.Symbol.BaseName])
262
- ))(f.field.table)) {
263
- const tableName = (0, import_table2.getTableName)(f.field.table);
264
- throw new Error(
265
- `Your "${f.path.join("->")}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`
266
- );
267
- }
268
- }
269
- const isSingleTable = !joins || joins.length === 0;
270
- const withSql = this.buildWithCTE(withList);
271
- let distinctSql;
272
- if (distinct) {
273
- distinctSql = distinct === true ? import_sql2.sql` distinct` : import_sql2.sql` distinct on (${import_sql2.sql.join(distinct.on, import_sql2.sql`, `)})`;
274
- }
275
- const selection = this.buildSelection(fieldsList, { isSingleTable });
276
- const tableSql = this.buildFromTable(table);
277
- const joinsSql = this.buildJoins(joins);
278
- const whereSql = where ? import_sql2.sql` where ${where}` : void 0;
279
- const havingSql = having ? import_sql2.sql` having ${having}` : void 0;
280
- let orderBySql;
281
- if (orderBy && orderBy.length > 0) {
282
- orderBySql = import_sql2.sql` order by ${import_sql2.sql.join(orderBy, import_sql2.sql`, `)}`;
283
- }
284
- let groupBySql;
285
- if (groupBy && groupBy.length > 0) {
286
- groupBySql = import_sql2.sql` group by ${import_sql2.sql.join(groupBy, import_sql2.sql`, `)}`;
287
- }
288
- const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? import_sql2.sql` limit ${limit}` : void 0;
289
- const offsetSql = offset ? import_sql2.sql` offset ${offset}` : void 0;
290
- const lockingClauseSql = import_sql2.sql.empty();
291
- if (lockingClause) {
292
- const clauseSql = import_sql2.sql` for ${import_sql2.sql.raw(lockingClause.strength)}`;
293
- if (lockingClause.config.of) {
294
- clauseSql.append(
295
- import_sql2.sql` of ${import_sql2.sql.join(
296
- Array.isArray(lockingClause.config.of) ? lockingClause.config.of : [lockingClause.config.of],
297
- import_sql2.sql`, `
298
- )}`
299
- );
300
- }
301
- if (lockingClause.config.noWait) {
302
- clauseSql.append(import_sql2.sql` no wait`);
303
- } else if (lockingClause.config.skipLocked) {
304
- clauseSql.append(import_sql2.sql` skip locked`);
305
- }
306
- lockingClauseSql.append(clauseSql);
307
- }
308
- const finalQuery = import_sql2.sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}${lockingClauseSql}`;
309
- if (setOperators.length > 0) {
310
- return this.buildSetOperations(finalQuery, setOperators);
311
- }
312
- return finalQuery;
313
- }
314
- buildSetOperations(leftSelect, setOperators) {
315
- const [setOperator, ...rest] = setOperators;
316
- if (!setOperator) {
317
- throw new Error("Cannot pass undefined values to any set operator");
318
- }
319
- if (rest.length === 0) {
320
- return this.buildSetOperationQuery({ leftSelect, setOperator });
321
- }
322
- return this.buildSetOperations(
323
- this.buildSetOperationQuery({ leftSelect, setOperator }),
324
- rest
325
- );
326
- }
327
- buildSetOperationQuery({
328
- leftSelect,
329
- setOperator: { type, isAll, rightSelect, limit, orderBy, offset }
330
- }) {
331
- const leftChunk = import_sql2.sql`(${leftSelect.getSQL()}) `;
332
- const rightChunk = import_sql2.sql`(${rightSelect.getSQL()})`;
333
- let orderBySql;
334
- if (orderBy && orderBy.length > 0) {
335
- const orderByValues = [];
336
- for (const singleOrderBy of orderBy) {
337
- if ((0, import_entity.is)(singleOrderBy, import_columns.GelColumn)) {
338
- orderByValues.push(import_sql2.sql.identifier(singleOrderBy.name));
339
- } else if ((0, import_entity.is)(singleOrderBy, import_sql2.SQL)) {
340
- for (let i = 0; i < singleOrderBy.queryChunks.length; i++) {
341
- const chunk = singleOrderBy.queryChunks[i];
342
- if ((0, import_entity.is)(chunk, import_columns.GelColumn)) {
343
- singleOrderBy.queryChunks[i] = import_sql2.sql.identifier(chunk.name);
344
- }
345
- }
346
- orderByValues.push(import_sql2.sql`${singleOrderBy}`);
347
- } else {
348
- orderByValues.push(import_sql2.sql`${singleOrderBy}`);
349
- }
350
- }
351
- orderBySql = import_sql2.sql` order by ${import_sql2.sql.join(orderByValues, import_sql2.sql`, `)} `;
352
- }
353
- const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? import_sql2.sql` limit ${limit}` : void 0;
354
- const operatorChunk = import_sql2.sql.raw(`${type} ${isAll ? "all " : ""}`);
355
- const offsetSql = offset ? import_sql2.sql` offset ${offset}` : void 0;
356
- return import_sql2.sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
357
- }
358
- buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_ }) {
359
- const valuesSqlList = [];
360
- const columns = table[import_table2.Table.Symbol.Columns];
361
- const colEntries = Object.entries(columns).filter(([_, col]) => !col.shouldDisableInsert());
362
- const insertOrder = colEntries.map(
363
- ([, column]) => import_sql2.sql.identifier(this.casing.getColumnCasing(column))
364
- );
365
- if (select) {
366
- const select2 = valuesOrSelect;
367
- if ((0, import_entity.is)(select2, import_sql2.SQL)) {
368
- valuesSqlList.push(select2);
369
- } else {
370
- valuesSqlList.push(select2.getSQL());
371
- }
372
- } else {
373
- const values = valuesOrSelect;
374
- valuesSqlList.push(import_sql2.sql.raw("values "));
375
- for (const [valueIndex, value] of values.entries()) {
376
- const valueList = [];
377
- for (const [fieldName, col] of colEntries) {
378
- const colValue = value[fieldName];
379
- if (colValue === void 0 || (0, import_entity.is)(colValue, import_sql2.Param) && colValue.value === void 0) {
380
- if (col.defaultFn !== void 0) {
381
- const defaultFnResult = col.defaultFn();
382
- const defaultValue = (0, import_entity.is)(defaultFnResult, import_sql2.SQL) ? defaultFnResult : import_sql2.sql.param(defaultFnResult, col);
383
- valueList.push(defaultValue);
384
- } else if (!col.default && col.onUpdateFn !== void 0) {
385
- const onUpdateFnResult = col.onUpdateFn();
386
- const newValue = (0, import_entity.is)(onUpdateFnResult, import_sql2.SQL) ? onUpdateFnResult : import_sql2.sql.param(onUpdateFnResult, col);
387
- valueList.push(newValue);
388
- } else {
389
- valueList.push(import_sql2.sql`default`);
390
- }
391
- } else {
392
- valueList.push(colValue);
393
- }
394
- }
395
- valuesSqlList.push(valueList);
396
- if (valueIndex < values.length - 1) {
397
- valuesSqlList.push(import_sql2.sql`, `);
398
- }
399
- }
400
- }
401
- const withSql = this.buildWithCTE(withList);
402
- const valuesSql = import_sql2.sql.join(valuesSqlList);
403
- const returningSql = returning ? import_sql2.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
404
- const onConflictSql = onConflict ? import_sql2.sql` on conflict ${onConflict}` : void 0;
405
- const overridingSql = overridingSystemValue_ === true ? import_sql2.sql`overriding system value ` : void 0;
406
- return import_sql2.sql`${withSql}insert into ${table} ${insertOrder} ${overridingSql}${valuesSql}${onConflictSql}${returningSql}`;
407
- }
408
- buildRefreshMaterializedViewQuery({ view, concurrently, withNoData }) {
409
- const concurrentlySql = concurrently ? import_sql2.sql` concurrently` : void 0;
410
- const withNoDataSql = withNoData ? import_sql2.sql` with no data` : void 0;
411
- return import_sql2.sql`refresh materialized view${concurrentlySql} ${view}${withNoDataSql}`;
412
- }
413
- prepareTyping(encoder) {
414
- if ((0, import_entity.is)(encoder, import_columns.GelJson)) {
415
- return "json";
416
- } else if ((0, import_entity.is)(encoder, import_columns.GelDecimal)) {
417
- return "decimal";
418
- } else if ((0, import_entity.is)(encoder, import_timestamp.GelTimestamp)) {
419
- return "timestamp";
420
- } else if ((0, import_entity.is)(encoder, import_columns.GelUUID)) {
421
- return "uuid";
422
- } else {
423
- return "none";
424
- }
425
- }
426
- sqlToQuery(sql2, invokeSource) {
427
- return sql2.toQuery({
428
- casing: this.casing,
429
- escapeName: this.escapeName,
430
- escapeParam: this.escapeParam,
431
- escapeString: this.escapeString,
432
- prepareTyping: this.prepareTyping,
433
- invokeSource
434
- });
435
- }
436
- // buildRelationalQueryWithPK({
437
- // fullSchema,
438
- // schema,
439
- // tableNamesMap,
440
- // table,
441
- // tableConfig,
442
- // queryConfig: config,
443
- // tableAlias,
444
- // isRoot = false,
445
- // joinOn,
446
- // }: {
447
- // fullSchema: Record<string, unknown>;
448
- // schema: TablesRelationalConfig;
449
- // tableNamesMap: Record<string, string>;
450
- // table: GelTable;
451
- // tableConfig: TableRelationalConfig;
452
- // queryConfig: true | DBQueryConfig<'many', true>;
453
- // tableAlias: string;
454
- // isRoot?: boolean;
455
- // joinOn?: SQL;
456
- // }): BuildRelationalQueryResult<GelTable, GelColumn> {
457
- // // For { "<relation>": true }, return a table with selection of all columns
458
- // if (config === true) {
459
- // const selectionEntries = Object.entries(tableConfig.columns);
460
- // const selection: BuildRelationalQueryResult<GelTable, GelColumn>['selection'] = selectionEntries.map((
461
- // [key, value],
462
- // ) => ({
463
- // dbKey: value.name,
464
- // tsKey: key,
465
- // field: value as GelColumn,
466
- // relationTableTsKey: undefined,
467
- // isJson: false,
468
- // selection: [],
469
- // }));
470
- // return {
471
- // tableTsKey: tableConfig.tsName,
472
- // sql: table,
473
- // selection,
474
- // };
475
- // }
476
- // // let selection: BuildRelationalQueryResult<GelTable, GelColumn>['selection'] = [];
477
- // // let selectionForBuild = selection;
478
- // const aliasedColumns = Object.fromEntries(
479
- // Object.entries(tableConfig.columns).map(([key, value]) => [key, aliasedTableColumn(value, tableAlias)]),
480
- // );
481
- // const aliasedRelations = Object.fromEntries(
482
- // Object.entries(tableConfig.relations).map(([key, value]) => [key, aliasedRelation(value, tableAlias)]),
483
- // );
484
- // const aliasedFields = Object.assign({}, aliasedColumns, aliasedRelations);
485
- // let where, hasUserDefinedWhere;
486
- // if (config.where) {
487
- // const whereSql = typeof config.where === 'function' ? config.where(aliasedFields, operators) : config.where;
488
- // where = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);
489
- // hasUserDefinedWhere = !!where;
490
- // }
491
- // where = and(joinOn, where);
492
- // // const fieldsSelection: { tsKey: string; value: GelColumn | SQL.Aliased; isExtra?: boolean }[] = [];
493
- // let joins: Join[] = [];
494
- // let selectedColumns: string[] = [];
495
- // // Figure out which columns to select
496
- // if (config.columns) {
497
- // let isIncludeMode = false;
498
- // for (const [field, value] of Object.entries(config.columns)) {
499
- // if (value === undefined) {
500
- // continue;
501
- // }
502
- // if (field in tableConfig.columns) {
503
- // if (!isIncludeMode && value === true) {
504
- // isIncludeMode = true;
505
- // }
506
- // selectedColumns.push(field);
507
- // }
508
- // }
509
- // if (selectedColumns.length > 0) {
510
- // selectedColumns = isIncludeMode
511
- // ? selectedColumns.filter((c) => config.columns?.[c] === true)
512
- // : Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));
513
- // }
514
- // } else {
515
- // // Select all columns if selection is not specified
516
- // selectedColumns = Object.keys(tableConfig.columns);
517
- // }
518
- // // for (const field of selectedColumns) {
519
- // // const column = tableConfig.columns[field]! as GelColumn;
520
- // // fieldsSelection.push({ tsKey: field, value: column });
521
- // // }
522
- // let initiallySelectedRelations: {
523
- // tsKey: string;
524
- // queryConfig: true | DBQueryConfig<'many', false>;
525
- // relation: Relation;
526
- // }[] = [];
527
- // // let selectedRelations: BuildRelationalQueryResult<GelTable, GelColumn>['selection'] = [];
528
- // // Figure out which relations to select
529
- // if (config.with) {
530
- // initiallySelectedRelations = Object.entries(config.with)
531
- // .filter((entry): entry is [typeof entry[0], NonNullable<typeof entry[1]>] => !!entry[1])
532
- // .map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey]! }));
533
- // }
534
- // const manyRelations = initiallySelectedRelations.filter((r) =>
535
- // is(r.relation, Many)
536
- // && (schema[tableNamesMap[r.relation.referencedTable[Table.Symbol.Name]]!]?.primaryKey.length ?? 0) > 0
537
- // );
538
- // // If this is the last Many relation (or there are no Many relations), we are on the innermost subquery level
539
- // const isInnermostQuery = manyRelations.length < 2;
540
- // const selectedExtras: {
541
- // tsKey: string;
542
- // value: SQL.Aliased;
543
- // }[] = [];
544
- // // Figure out which extras to select
545
- // if (isInnermostQuery && config.extras) {
546
- // const extras = typeof config.extras === 'function'
547
- // ? config.extras(aliasedFields, { sql })
548
- // : config.extras;
549
- // for (const [tsKey, value] of Object.entries(extras)) {
550
- // selectedExtras.push({
551
- // tsKey,
552
- // value: mapColumnsInAliasedSQLToAlias(value, tableAlias),
553
- // });
554
- // }
555
- // }
556
- // // Transform `fieldsSelection` into `selection`
557
- // // `fieldsSelection` shouldn't be used after this point
558
- // // for (const { tsKey, value, isExtra } of fieldsSelection) {
559
- // // selection.push({
560
- // // dbKey: is(value, SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey]!.name,
561
- // // tsKey,
562
- // // field: is(value, Column) ? aliasedTableColumn(value, tableAlias) : value,
563
- // // relationTableTsKey: undefined,
564
- // // isJson: false,
565
- // // isExtra,
566
- // // selection: [],
567
- // // });
568
- // // }
569
- // let orderByOrig = typeof config.orderBy === 'function'
570
- // ? config.orderBy(aliasedFields, orderByOperators)
571
- // : config.orderBy ?? [];
572
- // if (!Array.isArray(orderByOrig)) {
573
- // orderByOrig = [orderByOrig];
574
- // }
575
- // const orderBy = orderByOrig.map((orderByValue) => {
576
- // if (is(orderByValue, Column)) {
577
- // return aliasedTableColumn(orderByValue, tableAlias) as GelColumn;
578
- // }
579
- // return mapColumnsInSQLToAlias(orderByValue, tableAlias);
580
- // });
581
- // const limit = isInnermostQuery ? config.limit : undefined;
582
- // const offset = isInnermostQuery ? config.offset : undefined;
583
- // // For non-root queries without additional config except columns, return a table with selection
584
- // if (
585
- // !isRoot
586
- // && initiallySelectedRelations.length === 0
587
- // && selectedExtras.length === 0
588
- // && !where
589
- // && orderBy.length === 0
590
- // && limit === undefined
591
- // && offset === undefined
592
- // ) {
593
- // return {
594
- // tableTsKey: tableConfig.tsName,
595
- // sql: table,
596
- // selection: selectedColumns.map((key) => ({
597
- // dbKey: tableConfig.columns[key]!.name,
598
- // tsKey: key,
599
- // field: tableConfig.columns[key] as GelColumn,
600
- // relationTableTsKey: undefined,
601
- // isJson: false,
602
- // selection: [],
603
- // })),
604
- // };
605
- // }
606
- // const selectedRelationsWithoutPK:
607
- // // Process all relations without primary keys, because they need to be joined differently and will all be on the same query level
608
- // for (
609
- // const {
610
- // tsKey: selectedRelationTsKey,
611
- // queryConfig: selectedRelationConfigValue,
612
- // relation,
613
- // } of initiallySelectedRelations
614
- // ) {
615
- // const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
616
- // const relationTableName = relation.referencedTable[Table.Symbol.Name];
617
- // const relationTableTsName = tableNamesMap[relationTableName]!;
618
- // const relationTable = schema[relationTableTsName]!;
619
- // if (relationTable.primaryKey.length > 0) {
620
- // continue;
621
- // }
622
- // const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
623
- // const joinOn = and(
624
- // ...normalizedRelation.fields.map((field, i) =>
625
- // eq(
626
- // aliasedTableColumn(normalizedRelation.references[i]!, relationTableAlias),
627
- // aliasedTableColumn(field, tableAlias),
628
- // )
629
- // ),
630
- // );
631
- // const builtRelation = this.buildRelationalQueryWithoutPK({
632
- // fullSchema,
633
- // schema,
634
- // tableNamesMap,
635
- // table: fullSchema[relationTableTsName] as GelTable,
636
- // tableConfig: schema[relationTableTsName]!,
637
- // queryConfig: selectedRelationConfigValue,
638
- // tableAlias: relationTableAlias,
639
- // joinOn,
640
- // nestedQueryRelation: relation,
641
- // });
642
- // const field = sql`${sql.identifier(relationTableAlias)}.${sql.identifier('data')}`.as(selectedRelationTsKey);
643
- // joins.push({
644
- // on: sql`true`,
645
- // table: new Subquery(builtRelation.sql as SQL, {}, relationTableAlias),
646
- // alias: relationTableAlias,
647
- // joinType: 'left',
648
- // lateral: true,
649
- // });
650
- // selectedRelations.push({
651
- // dbKey: selectedRelationTsKey,
652
- // tsKey: selectedRelationTsKey,
653
- // field,
654
- // relationTableTsKey: relationTableTsName,
655
- // isJson: true,
656
- // selection: builtRelation.selection,
657
- // });
658
- // }
659
- // const oneRelations = initiallySelectedRelations.filter((r): r is typeof r & { relation: One } =>
660
- // is(r.relation, One)
661
- // );
662
- // // Process all One relations with PKs, because they can all be joined on the same level
663
- // for (
664
- // const {
665
- // tsKey: selectedRelationTsKey,
666
- // queryConfig: selectedRelationConfigValue,
667
- // relation,
668
- // } of oneRelations
669
- // ) {
670
- // const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
671
- // const relationTableName = relation.referencedTable[Table.Symbol.Name];
672
- // const relationTableTsName = tableNamesMap[relationTableName]!;
673
- // const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
674
- // const relationTable = schema[relationTableTsName]!;
675
- // if (relationTable.primaryKey.length === 0) {
676
- // continue;
677
- // }
678
- // const joinOn = and(
679
- // ...normalizedRelation.fields.map((field, i) =>
680
- // eq(
681
- // aliasedTableColumn(normalizedRelation.references[i]!, relationTableAlias),
682
- // aliasedTableColumn(field, tableAlias),
683
- // )
684
- // ),
685
- // );
686
- // const builtRelation = this.buildRelationalQueryWithPK({
687
- // fullSchema,
688
- // schema,
689
- // tableNamesMap,
690
- // table: fullSchema[relationTableTsName] as GelTable,
691
- // tableConfig: schema[relationTableTsName]!,
692
- // queryConfig: selectedRelationConfigValue,
693
- // tableAlias: relationTableAlias,
694
- // joinOn,
695
- // });
696
- // const field = sql`case when ${sql.identifier(relationTableAlias)} is null then null else json_build_array(${
697
- // sql.join(
698
- // builtRelation.selection.map(({ field }) =>
699
- // is(field, SQL.Aliased)
700
- // ? sql`${sql.identifier(relationTableAlias)}.${sql.identifier(field.fieldAlias)}`
701
- // : is(field, Column)
702
- // ? aliasedTableColumn(field, relationTableAlias)
703
- // : field
704
- // ),
705
- // sql`, `,
706
- // )
707
- // }) end`.as(selectedRelationTsKey);
708
- // const isLateralJoin = is(builtRelation.sql, SQL);
709
- // joins.push({
710
- // on: isLateralJoin ? sql`true` : joinOn,
711
- // table: is(builtRelation.sql, SQL)
712
- // ? new Subquery(builtRelation.sql, {}, relationTableAlias)
713
- // : aliasedTable(builtRelation.sql, relationTableAlias),
714
- // alias: relationTableAlias,
715
- // joinType: 'left',
716
- // lateral: is(builtRelation.sql, SQL),
717
- // });
718
- // selectedRelations.push({
719
- // dbKey: selectedRelationTsKey,
720
- // tsKey: selectedRelationTsKey,
721
- // field,
722
- // relationTableTsKey: relationTableTsName,
723
- // isJson: true,
724
- // selection: builtRelation.selection,
725
- // });
726
- // }
727
- // let distinct: GelSelectConfig['distinct'];
728
- // let tableFrom: GelTable | Subquery = table;
729
- // // Process first Many relation - each one requires a nested subquery
730
- // const manyRelation = manyRelations[0];
731
- // if (manyRelation) {
732
- // const {
733
- // tsKey: selectedRelationTsKey,
734
- // queryConfig: selectedRelationQueryConfig,
735
- // relation,
736
- // } = manyRelation;
737
- // distinct = {
738
- // on: tableConfig.primaryKey.map((c) => aliasedTableColumn(c as GelColumn, tableAlias)),
739
- // };
740
- // const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
741
- // const relationTableName = relation.referencedTable[Table.Symbol.Name];
742
- // const relationTableTsName = tableNamesMap[relationTableName]!;
743
- // const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
744
- // const joinOn = and(
745
- // ...normalizedRelation.fields.map((field, i) =>
746
- // eq(
747
- // aliasedTableColumn(normalizedRelation.references[i]!, relationTableAlias),
748
- // aliasedTableColumn(field, tableAlias),
749
- // )
750
- // ),
751
- // );
752
- // const builtRelationJoin = this.buildRelationalQueryWithPK({
753
- // fullSchema,
754
- // schema,
755
- // tableNamesMap,
756
- // table: fullSchema[relationTableTsName] as GelTable,
757
- // tableConfig: schema[relationTableTsName]!,
758
- // queryConfig: selectedRelationQueryConfig,
759
- // tableAlias: relationTableAlias,
760
- // joinOn,
761
- // });
762
- // const builtRelationSelectionField = sql`case when ${
763
- // sql.identifier(relationTableAlias)
764
- // } is null then '[]' else json_agg(json_build_array(${
765
- // sql.join(
766
- // builtRelationJoin.selection.map(({ field }) =>
767
- // is(field, SQL.Aliased)
768
- // ? sql`${sql.identifier(relationTableAlias)}.${sql.identifier(field.fieldAlias)}`
769
- // : is(field, Column)
770
- // ? aliasedTableColumn(field, relationTableAlias)
771
- // : field
772
- // ),
773
- // sql`, `,
774
- // )
775
- // })) over (partition by ${sql.join(distinct.on, sql`, `)}) end`.as(selectedRelationTsKey);
776
- // const isLateralJoin = is(builtRelationJoin.sql, SQL);
777
- // joins.push({
778
- // on: isLateralJoin ? sql`true` : joinOn,
779
- // table: isLateralJoin
780
- // ? new Subquery(builtRelationJoin.sql as SQL, {}, relationTableAlias)
781
- // : aliasedTable(builtRelationJoin.sql as GelTable, relationTableAlias),
782
- // alias: relationTableAlias,
783
- // joinType: 'left',
784
- // lateral: isLateralJoin,
785
- // });
786
- // // Build the "from" subquery with the remaining Many relations
787
- // const builtTableFrom = this.buildRelationalQueryWithPK({
788
- // fullSchema,
789
- // schema,
790
- // tableNamesMap,
791
- // table,
792
- // tableConfig,
793
- // queryConfig: {
794
- // ...config,
795
- // where: undefined,
796
- // orderBy: undefined,
797
- // limit: undefined,
798
- // offset: undefined,
799
- // with: manyRelations.slice(1).reduce<NonNullable<typeof config['with']>>(
800
- // (result, { tsKey, queryConfig: configValue }) => {
801
- // result[tsKey] = configValue;
802
- // return result;
803
- // },
804
- // {},
805
- // ),
806
- // },
807
- // tableAlias,
808
- // });
809
- // selectedRelations.push({
810
- // dbKey: selectedRelationTsKey,
811
- // tsKey: selectedRelationTsKey,
812
- // field: builtRelationSelectionField,
813
- // relationTableTsKey: relationTableTsName,
814
- // isJson: true,
815
- // selection: builtRelationJoin.selection,
816
- // });
817
- // // selection = builtTableFrom.selection.map((item) =>
818
- // // is(item.field, SQL.Aliased)
819
- // // ? { ...item, field: sql`${sql.identifier(tableAlias)}.${sql.identifier(item.field.fieldAlias)}` }
820
- // // : item
821
- // // );
822
- // // selectionForBuild = [{
823
- // // dbKey: '*',
824
- // // tsKey: '*',
825
- // // field: sql`${sql.identifier(tableAlias)}.*`,
826
- // // selection: [],
827
- // // isJson: false,
828
- // // relationTableTsKey: undefined,
829
- // // }];
830
- // // const newSelectionItem: (typeof selection)[number] = {
831
- // // dbKey: selectedRelationTsKey,
832
- // // tsKey: selectedRelationTsKey,
833
- // // field,
834
- // // relationTableTsKey: relationTableTsName,
835
- // // isJson: true,
836
- // // selection: builtRelationJoin.selection,
837
- // // };
838
- // // selection.push(newSelectionItem);
839
- // // selectionForBuild.push(newSelectionItem);
840
- // tableFrom = is(builtTableFrom.sql, GelTable)
841
- // ? builtTableFrom.sql
842
- // : new Subquery(builtTableFrom.sql, {}, tableAlias);
843
- // }
844
- // if (selectedColumns.length === 0 && selectedRelations.length === 0 && selectedExtras.length === 0) {
845
- // throw new DrizzleError(`No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")`);
846
- // }
847
- // let selection: BuildRelationalQueryResult<GelTable, GelColumn>['selection'];
848
- // function prepareSelectedColumns() {
849
- // return selectedColumns.map((key) => ({
850
- // dbKey: tableConfig.columns[key]!.name,
851
- // tsKey: key,
852
- // field: tableConfig.columns[key] as GelColumn,
853
- // relationTableTsKey: undefined,
854
- // isJson: false,
855
- // selection: [],
856
- // }));
857
- // }
858
- // function prepareSelectedExtras() {
859
- // return selectedExtras.map((item) => ({
860
- // dbKey: item.value.fieldAlias,
861
- // tsKey: item.tsKey,
862
- // field: item.value,
863
- // relationTableTsKey: undefined,
864
- // isJson: false,
865
- // selection: [],
866
- // }));
867
- // }
868
- // if (isRoot) {
869
- // selection = [
870
- // ...prepareSelectedColumns(),
871
- // ...prepareSelectedExtras(),
872
- // ];
873
- // }
874
- // if (hasUserDefinedWhere || orderBy.length > 0) {
875
- // tableFrom = new Subquery(
876
- // this.buildSelectQuery({
877
- // table: is(tableFrom, GelTable) ? aliasedTable(tableFrom, tableAlias) : tableFrom,
878
- // fields: {},
879
- // fieldsFlat: selectionForBuild.map(({ field }) => ({
880
- // path: [],
881
- // field: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field,
882
- // })),
883
- // joins,
884
- // distinct,
885
- // }),
886
- // {},
887
- // tableAlias,
888
- // );
889
- // selectionForBuild = selection.map((item) =>
890
- // is(item.field, SQL.Aliased)
891
- // ? { ...item, field: sql`${sql.identifier(tableAlias)}.${sql.identifier(item.field.fieldAlias)}` }
892
- // : item
893
- // );
894
- // joins = [];
895
- // distinct = undefined;
896
- // }
897
- // const result = this.buildSelectQuery({
898
- // table: is(tableFrom, GelTable) ? aliasedTable(tableFrom, tableAlias) : tableFrom,
899
- // fields: {},
900
- // fieldsFlat: selectionForBuild.map(({ field }) => ({
901
- // path: [],
902
- // field: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field,
903
- // })),
904
- // where,
905
- // limit,
906
- // offset,
907
- // joins,
908
- // orderBy,
909
- // distinct,
910
- // });
911
- // return {
912
- // tableTsKey: tableConfig.tsName,
913
- // sql: result,
914
- // selection,
915
- // };
916
- // }
917
- buildRelationalQueryWithoutPK({
918
- fullSchema,
919
- schema,
920
- tableNamesMap,
921
- table,
922
- tableConfig,
923
- queryConfig: config,
924
- tableAlias,
925
- nestedQueryRelation,
926
- joinOn
927
- }) {
928
- let selection = [];
929
- let limit, offset, orderBy = [], where;
930
- const joins = [];
931
- if (config === true) {
932
- const selectionEntries = Object.entries(tableConfig.columns);
933
- selection = selectionEntries.map(([key, value]) => ({
934
- dbKey: value.name,
935
- tsKey: key,
936
- field: (0, import_alias.aliasedTableColumn)(value, tableAlias),
937
- relationTableTsKey: void 0,
938
- isJson: false,
939
- selection: []
940
- }));
941
- } else {
942
- const aliasedColumns = Object.fromEntries(
943
- Object.entries(tableConfig.columns).map(([key, value]) => [key, (0, import_alias.aliasedTableColumn)(value, tableAlias)])
944
- );
945
- if (config.where) {
946
- const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, (0, import_relations.getOperators)()) : config.where;
947
- where = whereSql && (0, import_alias.mapColumnsInSQLToAlias)(whereSql, tableAlias);
948
- }
949
- const fieldsSelection = [];
950
- let selectedColumns = [];
951
- if (config.columns) {
952
- let isIncludeMode = false;
953
- for (const [field, value] of Object.entries(config.columns)) {
954
- if (value === void 0) {
955
- continue;
956
- }
957
- if (field in tableConfig.columns) {
958
- if (!isIncludeMode && value === true) {
959
- isIncludeMode = true;
960
- }
961
- selectedColumns.push(field);
962
- }
963
- }
964
- if (selectedColumns.length > 0) {
965
- selectedColumns = isIncludeMode ? selectedColumns.filter((c) => config.columns?.[c] === true) : Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));
966
- }
967
- } else {
968
- selectedColumns = Object.keys(tableConfig.columns);
969
- }
970
- for (const field of selectedColumns) {
971
- const column = tableConfig.columns[field];
972
- fieldsSelection.push({ tsKey: field, value: column });
973
- }
974
- let selectedRelations = [];
975
- if (config.with) {
976
- selectedRelations = Object.entries(config.with).filter((entry) => !!entry[1]).map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey] }));
977
- }
978
- let extras;
979
- if (config.extras) {
980
- extras = typeof config.extras === "function" ? config.extras(aliasedColumns, { sql: import_sql2.sql }) : config.extras;
981
- for (const [tsKey, value] of Object.entries(extras)) {
982
- fieldsSelection.push({
983
- tsKey,
984
- value: (0, import_alias.mapColumnsInAliasedSQLToAlias)(value, tableAlias)
985
- });
986
- }
987
- }
988
- for (const { tsKey, value } of fieldsSelection) {
989
- selection.push({
990
- dbKey: (0, import_entity.is)(value, import_sql2.SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey].name,
991
- tsKey,
992
- field: (0, import_entity.is)(value, import_column.Column) ? (0, import_alias.aliasedTableColumn)(value, tableAlias) : value,
993
- relationTableTsKey: void 0,
994
- isJson: false,
995
- selection: []
996
- });
997
- }
998
- let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, (0, import_relations.getOrderByOperators)()) : config.orderBy ?? [];
999
- if (!Array.isArray(orderByOrig)) {
1000
- orderByOrig = [orderByOrig];
1001
- }
1002
- orderBy = orderByOrig.map((orderByValue) => {
1003
- if ((0, import_entity.is)(orderByValue, import_column.Column)) {
1004
- return (0, import_alias.aliasedTableColumn)(orderByValue, tableAlias);
1005
- }
1006
- return (0, import_alias.mapColumnsInSQLToAlias)(orderByValue, tableAlias);
1007
- });
1008
- limit = config.limit;
1009
- offset = config.offset;
1010
- for (const {
1011
- tsKey: selectedRelationTsKey,
1012
- queryConfig: selectedRelationConfigValue,
1013
- relation
1014
- } of selectedRelations) {
1015
- const normalizedRelation = (0, import_relations.normalizeRelation)(schema, tableNamesMap, relation);
1016
- const relationTableName = (0, import_table2.getTableUniqueName)(relation.referencedTable);
1017
- const relationTableTsName = tableNamesMap[relationTableName];
1018
- const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
1019
- const joinOn2 = (0, import_sql.and)(
1020
- ...normalizedRelation.fields.map(
1021
- (field2, i) => (0, import_sql.eq)(
1022
- (0, import_alias.aliasedTableColumn)(normalizedRelation.references[i], relationTableAlias),
1023
- (0, import_alias.aliasedTableColumn)(field2, tableAlias)
1024
- )
1025
- )
1026
- );
1027
- const builtRelation = this.buildRelationalQueryWithoutPK({
1028
- fullSchema,
1029
- schema,
1030
- tableNamesMap,
1031
- table: fullSchema[relationTableTsName],
1032
- tableConfig: schema[relationTableTsName],
1033
- queryConfig: (0, import_entity.is)(relation, import_relations.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
1034
- tableAlias: relationTableAlias,
1035
- joinOn: joinOn2,
1036
- nestedQueryRelation: relation
1037
- });
1038
- const field = import_sql2.sql`${import_sql2.sql.identifier(relationTableAlias)}.${import_sql2.sql.identifier("data")}`.as(selectedRelationTsKey);
1039
- joins.push({
1040
- on: import_sql2.sql`true`,
1041
- table: new import_subquery.Subquery(builtRelation.sql, {}, relationTableAlias),
1042
- alias: relationTableAlias,
1043
- joinType: "left",
1044
- lateral: true
1045
- });
1046
- selection.push({
1047
- dbKey: selectedRelationTsKey,
1048
- tsKey: selectedRelationTsKey,
1049
- field,
1050
- relationTableTsKey: relationTableTsName,
1051
- isJson: true,
1052
- selection: builtRelation.selection
1053
- });
1054
- }
1055
- }
1056
- if (selection.length === 0) {
1057
- throw new import_errors.DrizzleError({ message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")` });
1058
- }
1059
- let result;
1060
- where = (0, import_sql.and)(joinOn, where);
1061
- if (nestedQueryRelation) {
1062
- let field = import_sql2.sql`json_build_array(${import_sql2.sql.join(
1063
- selection.map(
1064
- ({ field: field2, tsKey, isJson }) => isJson ? import_sql2.sql`${import_sql2.sql.identifier(`${tableAlias}_${tsKey}`)}.${import_sql2.sql.identifier("data")}` : (0, import_entity.is)(field2, import_sql2.SQL.Aliased) ? field2.sql : field2
1065
- ),
1066
- import_sql2.sql`, `
1067
- )})`;
1068
- if ((0, import_entity.is)(nestedQueryRelation, import_relations.Many)) {
1069
- field = import_sql2.sql`coalesce(json_agg(${field}${orderBy.length > 0 ? import_sql2.sql` order by ${import_sql2.sql.join(orderBy, import_sql2.sql`, `)}` : void 0}), '[]'::json)`;
1070
- }
1071
- const nestedSelection = [{
1072
- dbKey: "data",
1073
- tsKey: "data",
1074
- field: field.as("data"),
1075
- isJson: true,
1076
- relationTableTsKey: tableConfig.tsName,
1077
- selection
1078
- }];
1079
- const needsSubquery = limit !== void 0 || offset !== void 0 || orderBy.length > 0;
1080
- if (needsSubquery) {
1081
- result = this.buildSelectQuery({
1082
- table: (0, import_alias.aliasedTable)(table, tableAlias),
1083
- fields: {},
1084
- fieldsFlat: [{
1085
- path: [],
1086
- field: import_sql2.sql.raw("*")
1087
- }],
1088
- where,
1089
- limit,
1090
- offset,
1091
- orderBy,
1092
- setOperators: []
1093
- });
1094
- where = void 0;
1095
- limit = void 0;
1096
- offset = void 0;
1097
- orderBy = [];
1098
- } else {
1099
- result = (0, import_alias.aliasedTable)(table, tableAlias);
1100
- }
1101
- result = this.buildSelectQuery({
1102
- table: (0, import_entity.is)(result, import_table.GelTable) ? result : new import_subquery.Subquery(result, {}, tableAlias),
1103
- fields: {},
1104
- fieldsFlat: nestedSelection.map(({ field: field2 }) => ({
1105
- path: [],
1106
- field: (0, import_entity.is)(field2, import_column.Column) ? (0, import_alias.aliasedTableColumn)(field2, tableAlias) : field2
1107
- })),
1108
- joins,
1109
- where,
1110
- limit,
1111
- offset,
1112
- orderBy,
1113
- setOperators: []
1114
- });
1115
- } else {
1116
- result = this.buildSelectQuery({
1117
- table: (0, import_alias.aliasedTable)(table, tableAlias),
1118
- fields: {},
1119
- fieldsFlat: selection.map(({ field }) => ({
1120
- path: [],
1121
- field: (0, import_entity.is)(field, import_column.Column) ? (0, import_alias.aliasedTableColumn)(field, tableAlias) : field
1122
- })),
1123
- joins,
1124
- where,
1125
- limit,
1126
- offset,
1127
- orderBy,
1128
- setOperators: []
1129
- });
1130
- }
1131
- return {
1132
- tableTsKey: tableConfig.tsName,
1133
- sql: result,
1134
- selection
1135
- };
1136
- }
1137
- }
1138
- // Annotate the CommonJS export names for ESM import in node:
1139
- 0 && (module.exports = {
1140
- GelDialect
1141
- });
1142
- //# sourceMappingURL=dialect.cjs.map