drizzle-orm 0.39.1 → 0.39.2-2fb137b

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 (387) hide show
  1. package/column-builder.cjs.map +1 -1
  2. package/column-builder.d.cts +6 -5
  3. package/column-builder.d.ts +6 -5
  4. package/column-builder.js.map +1 -1
  5. package/gel/driver.cjs +97 -0
  6. package/gel/driver.cjs.map +1 -0
  7. package/gel/driver.d.cts +38 -0
  8. package/gel/driver.d.ts +38 -0
  9. package/gel/driver.js +74 -0
  10. package/gel/driver.js.map +1 -0
  11. package/gel/index.cjs +25 -0
  12. package/gel/index.cjs.map +1 -0
  13. package/gel/index.d.cts +2 -0
  14. package/gel/index.d.ts +2 -0
  15. package/gel/index.js +3 -0
  16. package/gel/index.js.map +1 -0
  17. package/gel/migrator.cjs +5 -0
  18. package/gel/migrator.cjs.map +1 -0
  19. package/gel/migrator.d.cts +1 -0
  20. package/gel/migrator.d.ts +1 -0
  21. package/gel/migrator.js +4 -0
  22. package/gel/migrator.js.map +1 -0
  23. package/gel/session.cjs +139 -0
  24. package/gel/session.cjs.map +1 -0
  25. package/gel/session.d.cts +47 -0
  26. package/gel/session.d.ts +47 -0
  27. package/gel/session.js +113 -0
  28. package/gel/session.js.map +1 -0
  29. package/gel-core/alias.cjs +32 -0
  30. package/gel-core/alias.cjs.map +1 -0
  31. package/gel-core/alias.d.cts +4 -0
  32. package/gel-core/alias.d.ts +4 -0
  33. package/gel-core/alias.js +8 -0
  34. package/gel-core/alias.js.map +1 -0
  35. package/gel-core/checks.cjs +58 -0
  36. package/gel-core/checks.cjs.map +1 -0
  37. package/gel-core/checks.d.cts +18 -0
  38. package/gel-core/checks.d.ts +18 -0
  39. package/gel-core/checks.js +32 -0
  40. package/gel-core/checks.js.map +1 -0
  41. package/gel-core/columns/all.cjs +72 -0
  42. package/gel-core/columns/all.cjs.map +1 -0
  43. package/gel-core/columns/all.d.cts +43 -0
  44. package/gel-core/columns/all.d.ts +43 -0
  45. package/gel-core/columns/all.js +48 -0
  46. package/gel-core/columns/all.js.map +1 -0
  47. package/gel-core/columns/bigint.cjs +54 -0
  48. package/gel-core/columns/bigint.cjs.map +1 -0
  49. package/gel-core/columns/bigint.d.cts +23 -0
  50. package/gel-core/columns/bigint.d.ts +23 -0
  51. package/gel-core/columns/bigint.js +28 -0
  52. package/gel-core/columns/bigint.js.map +1 -0
  53. package/gel-core/columns/bigintT.cjs +60 -0
  54. package/gel-core/columns/bigintT.cjs.map +1 -0
  55. package/gel-core/columns/bigintT.d.cts +24 -0
  56. package/gel-core/columns/bigintT.d.ts +24 -0
  57. package/gel-core/columns/bigintT.js +34 -0
  58. package/gel-core/columns/bigintT.js.map +1 -0
  59. package/gel-core/columns/boolean.cjs +53 -0
  60. package/gel-core/columns/boolean.cjs.map +1 -0
  61. package/gel-core/columns/boolean.d.cts +22 -0
  62. package/gel-core/columns/boolean.d.ts +22 -0
  63. package/gel-core/columns/boolean.js +27 -0
  64. package/gel-core/columns/boolean.js.map +1 -0
  65. package/gel-core/columns/bytes.cjs +56 -0
  66. package/gel-core/columns/bytes.cjs.map +1 -0
  67. package/gel-core/columns/bytes.d.cts +22 -0
  68. package/gel-core/columns/bytes.d.ts +22 -0
  69. package/gel-core/columns/bytes.js +30 -0
  70. package/gel-core/columns/bytes.js.map +1 -0
  71. package/gel-core/columns/common.cjs +213 -0
  72. package/gel-core/columns/common.cjs.map +1 -0
  73. package/gel-core/columns/common.d.cts +147 -0
  74. package/gel-core/columns/common.d.ts +147 -0
  75. package/gel-core/columns/common.js +184 -0
  76. package/gel-core/columns/common.js.map +1 -0
  77. package/gel-core/columns/custom.cjs +77 -0
  78. package/gel-core/columns/custom.cjs.map +1 -0
  79. package/gel-core/columns/custom.d.cts +155 -0
  80. package/gel-core/columns/custom.d.ts +155 -0
  81. package/gel-core/columns/custom.js +51 -0
  82. package/gel-core/columns/custom.js.map +1 -0
  83. package/gel-core/columns/date-duration.cjs +56 -0
  84. package/gel-core/columns/date-duration.cjs.map +1 -0
  85. package/gel-core/columns/date-duration.d.cts +23 -0
  86. package/gel-core/columns/date-duration.d.ts +23 -0
  87. package/gel-core/columns/date-duration.js +30 -0
  88. package/gel-core/columns/date-duration.js.map +1 -0
  89. package/gel-core/columns/date.common.cjs +37 -0
  90. package/gel-core/columns/date.common.cjs.map +1 -0
  91. package/gel-core/columns/date.common.d.cts +7 -0
  92. package/gel-core/columns/date.common.d.ts +7 -0
  93. package/gel-core/columns/date.common.js +13 -0
  94. package/gel-core/columns/date.common.js.map +1 -0
  95. package/gel-core/columns/decimal.cjs +56 -0
  96. package/gel-core/columns/decimal.cjs.map +1 -0
  97. package/gel-core/columns/decimal.d.cts +26 -0
  98. package/gel-core/columns/decimal.d.ts +26 -0
  99. package/gel-core/columns/decimal.js +30 -0
  100. package/gel-core/columns/decimal.js.map +1 -0
  101. package/gel-core/columns/double-precision.cjs +62 -0
  102. package/gel-core/columns/double-precision.cjs.map +1 -0
  103. package/gel-core/columns/double-precision.d.cts +23 -0
  104. package/gel-core/columns/double-precision.d.ts +23 -0
  105. package/gel-core/columns/double-precision.js +36 -0
  106. package/gel-core/columns/double-precision.js.map +1 -0
  107. package/gel-core/columns/duration.cjs +53 -0
  108. package/gel-core/columns/duration.cjs.map +1 -0
  109. package/gel-core/columns/duration.d.cts +23 -0
  110. package/gel-core/columns/duration.d.ts +23 -0
  111. package/gel-core/columns/duration.js +27 -0
  112. package/gel-core/columns/duration.js.map +1 -0
  113. package/gel-core/columns/index.cjs +65 -0
  114. package/gel-core/columns/index.cjs.map +1 -0
  115. package/gel-core/columns/index.d.cts +22 -0
  116. package/gel-core/columns/index.d.ts +22 -0
  117. package/gel-core/columns/index.js +23 -0
  118. package/gel-core/columns/index.js.map +1 -0
  119. package/gel-core/columns/int.common.cjs +67 -0
  120. package/gel-core/columns/int.common.cjs.map +1 -0
  121. package/gel-core/columns/int.common.d.cts +15 -0
  122. package/gel-core/columns/int.common.d.ts +15 -0
  123. package/gel-core/columns/int.common.js +43 -0
  124. package/gel-core/columns/int.common.js.map +1 -0
  125. package/gel-core/columns/integer.cjs +54 -0
  126. package/gel-core/columns/integer.cjs.map +1 -0
  127. package/gel-core/columns/integer.d.cts +23 -0
  128. package/gel-core/columns/integer.d.ts +23 -0
  129. package/gel-core/columns/integer.js +28 -0
  130. package/gel-core/columns/integer.js.map +1 -0
  131. package/gel-core/columns/json.cjs +56 -0
  132. package/gel-core/columns/json.cjs.map +1 -0
  133. package/gel-core/columns/json.d.cts +26 -0
  134. package/gel-core/columns/json.d.ts +26 -0
  135. package/gel-core/columns/json.js +30 -0
  136. package/gel-core/columns/json.js.map +1 -0
  137. package/gel-core/columns/localdate.cjs +57 -0
  138. package/gel-core/columns/localdate.cjs.map +1 -0
  139. package/gel-core/columns/localdate.d.cts +24 -0
  140. package/gel-core/columns/localdate.d.ts +24 -0
  141. package/gel-core/columns/localdate.js +31 -0
  142. package/gel-core/columns/localdate.js.map +1 -0
  143. package/gel-core/columns/localtime.cjs +57 -0
  144. package/gel-core/columns/localtime.cjs.map +1 -0
  145. package/gel-core/columns/localtime.d.cts +24 -0
  146. package/gel-core/columns/localtime.d.ts +24 -0
  147. package/gel-core/columns/localtime.js +31 -0
  148. package/gel-core/columns/localtime.js.map +1 -0
  149. package/gel-core/columns/real.cjs +57 -0
  150. package/gel-core/columns/real.cjs.map +1 -0
  151. package/gel-core/columns/real.d.cts +28 -0
  152. package/gel-core/columns/real.d.ts +28 -0
  153. package/gel-core/columns/real.js +31 -0
  154. package/gel-core/columns/real.js.map +1 -0
  155. package/gel-core/columns/relative-duration.cjs +56 -0
  156. package/gel-core/columns/relative-duration.cjs.map +1 -0
  157. package/gel-core/columns/relative-duration.d.cts +23 -0
  158. package/gel-core/columns/relative-duration.d.ts +23 -0
  159. package/gel-core/columns/relative-duration.js +30 -0
  160. package/gel-core/columns/relative-duration.js.map +1 -0
  161. package/gel-core/columns/smallint.cjs +54 -0
  162. package/gel-core/columns/smallint.cjs.map +1 -0
  163. package/gel-core/columns/smallint.d.cts +23 -0
  164. package/gel-core/columns/smallint.d.ts +23 -0
  165. package/gel-core/columns/smallint.js +28 -0
  166. package/gel-core/columns/smallint.js.map +1 -0
  167. package/gel-core/columns/text.cjs +54 -0
  168. package/gel-core/columns/text.cjs.map +1 -0
  169. package/gel-core/columns/text.d.cts +26 -0
  170. package/gel-core/columns/text.d.ts +26 -0
  171. package/gel-core/columns/text.js +28 -0
  172. package/gel-core/columns/text.js.map +1 -0
  173. package/gel-core/columns/timestamp.cjs +60 -0
  174. package/gel-core/columns/timestamp.cjs.map +1 -0
  175. package/gel-core/columns/timestamp.d.cts +28 -0
  176. package/gel-core/columns/timestamp.d.ts +28 -0
  177. package/gel-core/columns/timestamp.js +34 -0
  178. package/gel-core/columns/timestamp.js.map +1 -0
  179. package/gel-core/columns/timestamptz.cjs +60 -0
  180. package/gel-core/columns/timestamptz.cjs.map +1 -0
  181. package/gel-core/columns/timestamptz.d.cts +27 -0
  182. package/gel-core/columns/timestamptz.d.ts +27 -0
  183. package/gel-core/columns/timestamptz.js +34 -0
  184. package/gel-core/columns/timestamptz.js.map +1 -0
  185. package/gel-core/columns/uuid.cjs +53 -0
  186. package/gel-core/columns/uuid.cjs.map +1 -0
  187. package/gel-core/columns/uuid.d.cts +22 -0
  188. package/gel-core/columns/uuid.d.ts +22 -0
  189. package/gel-core/columns/uuid.js +27 -0
  190. package/gel-core/columns/uuid.js.map +1 -0
  191. package/gel-core/db.cjs +338 -0
  192. package/gel-core/db.cjs.map +1 -0
  193. package/gel-core/db.d.cts +281 -0
  194. package/gel-core/db.d.ts +281 -0
  195. package/gel-core/db.js +319 -0
  196. package/gel-core/db.js.map +1 -0
  197. package/gel-core/dialect.cjs +1142 -0
  198. package/gel-core/dialect.cjs.map +1 -0
  199. package/gel-core/dialect.d.cts +62 -0
  200. package/gel-core/dialect.d.ts +62 -0
  201. package/gel-core/dialect.js +1128 -0
  202. package/gel-core/dialect.js.map +1 -0
  203. package/gel-core/expressions.cjs +49 -0
  204. package/gel-core/expressions.cjs.map +1 -0
  205. package/gel-core/expressions.d.cts +8 -0
  206. package/gel-core/expressions.d.ts +8 -0
  207. package/gel-core/expressions.js +22 -0
  208. package/gel-core/expressions.js.map +1 -0
  209. package/gel-core/foreign-keys.cjs +100 -0
  210. package/gel-core/foreign-keys.cjs.map +1 -0
  211. package/gel-core/foreign-keys.d.cts +48 -0
  212. package/gel-core/foreign-keys.d.ts +48 -0
  213. package/gel-core/foreign-keys.js +74 -0
  214. package/gel-core/foreign-keys.js.map +1 -0
  215. package/gel-core/index.cjs +61 -0
  216. package/gel-core/index.cjs.map +1 -0
  217. package/gel-core/index.d.cts +20 -0
  218. package/gel-core/index.d.ts +20 -0
  219. package/gel-core/index.js +21 -0
  220. package/gel-core/index.js.map +1 -0
  221. package/gel-core/indexes.cjs +149 -0
  222. package/gel-core/indexes.cjs.map +1 -0
  223. package/gel-core/indexes.d.cts +79 -0
  224. package/gel-core/indexes.d.ts +79 -0
  225. package/gel-core/indexes.js +121 -0
  226. package/gel-core/indexes.js.map +1 -0
  227. package/gel-core/policies.cjs +58 -0
  228. package/gel-core/policies.cjs.map +1 -0
  229. package/gel-core/policies.d.cts +24 -0
  230. package/gel-core/policies.d.ts +24 -0
  231. package/gel-core/policies.js +33 -0
  232. package/gel-core/policies.js.map +1 -0
  233. package/gel-core/primary-keys.cjs +68 -0
  234. package/gel-core/primary-keys.cjs.map +1 -0
  235. package/gel-core/primary-keys.d.cts +30 -0
  236. package/gel-core/primary-keys.d.ts +30 -0
  237. package/gel-core/primary-keys.js +42 -0
  238. package/gel-core/primary-keys.js.map +1 -0
  239. package/gel-core/query-builders/count.cjs +73 -0
  240. package/gel-core/query-builders/count.cjs.map +1 -0
  241. package/gel-core/query-builders/count.d.cts +25 -0
  242. package/gel-core/query-builders/count.d.ts +25 -0
  243. package/gel-core/query-builders/count.js +49 -0
  244. package/gel-core/query-builders/count.js.map +1 -0
  245. package/gel-core/query-builders/delete.cjs +105 -0
  246. package/gel-core/query-builders/delete.cjs.map +1 -0
  247. package/gel-core/query-builders/delete.d.cts +99 -0
  248. package/gel-core/query-builders/delete.d.ts +99 -0
  249. package/gel-core/query-builders/delete.js +81 -0
  250. package/gel-core/query-builders/delete.js.map +1 -0
  251. package/gel-core/query-builders/index.cjs +35 -0
  252. package/gel-core/query-builders/index.cjs.map +1 -0
  253. package/gel-core/query-builders/index.d.cts +7 -0
  254. package/gel-core/query-builders/index.d.ts +7 -0
  255. package/gel-core/query-builders/index.js +8 -0
  256. package/gel-core/query-builders/index.js.map +1 -0
  257. package/gel-core/query-builders/insert.cjs +218 -0
  258. package/gel-core/query-builders/insert.cjs.map +1 -0
  259. package/gel-core/query-builders/insert.d.cts +116 -0
  260. package/gel-core/query-builders/insert.d.ts +116 -0
  261. package/gel-core/query-builders/insert.js +193 -0
  262. package/gel-core/query-builders/insert.js.map +1 -0
  263. package/gel-core/query-builders/query-builder.cjs +114 -0
  264. package/gel-core/query-builders/query-builder.cjs.map +1 -0
  265. package/gel-core/query-builders/query-builder.d.cts +40 -0
  266. package/gel-core/query-builders/query-builder.d.ts +40 -0
  267. package/gel-core/query-builders/query-builder.js +90 -0
  268. package/gel-core/query-builders/query-builder.js.map +1 -0
  269. package/gel-core/query-builders/query.cjs +139 -0
  270. package/gel-core/query-builders/query.cjs.map +1 -0
  271. package/gel-core/query-builders/query.d.cts +46 -0
  272. package/gel-core/query-builders/query.d.ts +46 -0
  273. package/gel-core/query-builders/query.js +116 -0
  274. package/gel-core/query-builders/query.js.map +1 -0
  275. package/gel-core/query-builders/raw.cjs +57 -0
  276. package/gel-core/query-builders/raw.cjs.map +1 -0
  277. package/gel-core/query-builders/raw.d.cts +22 -0
  278. package/gel-core/query-builders/raw.d.ts +22 -0
  279. package/gel-core/query-builders/raw.js +33 -0
  280. package/gel-core/query-builders/raw.js.map +1 -0
  281. package/gel-core/query-builders/refresh-materialized-view.cjs +77 -0
  282. package/gel-core/query-builders/refresh-materialized-view.cjs.map +1 -0
  283. package/gel-core/query-builders/refresh-materialized-view.d.cts +27 -0
  284. package/gel-core/query-builders/refresh-materialized-view.d.ts +27 -0
  285. package/gel-core/query-builders/refresh-materialized-view.js +53 -0
  286. package/gel-core/query-builders/refresh-materialized-view.js.map +1 -0
  287. package/gel-core/query-builders/select.cjs +775 -0
  288. package/gel-core/query-builders/select.cjs.map +1 -0
  289. package/gel-core/query-builders/select.d.cts +721 -0
  290. package/gel-core/query-builders/select.d.ts +721 -0
  291. package/gel-core/query-builders/select.js +748 -0
  292. package/gel-core/query-builders/select.js.map +1 -0
  293. package/gel-core/query-builders/select.types.cjs +17 -0
  294. package/gel-core/query-builders/select.types.cjs.map +1 -0
  295. package/gel-core/query-builders/select.types.d.cts +138 -0
  296. package/gel-core/query-builders/select.types.d.ts +138 -0
  297. package/gel-core/query-builders/select.types.js +1 -0
  298. package/gel-core/query-builders/select.types.js.map +1 -0
  299. package/gel-core/query-builders/update.cjs +226 -0
  300. package/gel-core/query-builders/update.cjs.map +1 -0
  301. package/gel-core/query-builders/update.d.cts +166 -0
  302. package/gel-core/query-builders/update.d.ts +166 -0
  303. package/gel-core/query-builders/update.js +205 -0
  304. package/gel-core/query-builders/update.js.map +1 -0
  305. package/gel-core/roles.cjs +57 -0
  306. package/gel-core/roles.cjs.map +1 -0
  307. package/gel-core/roles.d.cts +13 -0
  308. package/gel-core/roles.d.ts +13 -0
  309. package/gel-core/roles.js +32 -0
  310. package/gel-core/roles.js.map +1 -0
  311. package/gel-core/schema.cjs +74 -0
  312. package/gel-core/schema.cjs.map +1 -0
  313. package/gel-core/schema.d.cts +15 -0
  314. package/gel-core/schema.d.ts +15 -0
  315. package/gel-core/schema.js +48 -0
  316. package/gel-core/schema.js.map +1 -0
  317. package/gel-core/sequence.cjs +52 -0
  318. package/gel-core/sequence.cjs.map +1 -0
  319. package/gel-core/sequence.d.cts +18 -0
  320. package/gel-core/sequence.d.ts +18 -0
  321. package/gel-core/sequence.js +25 -0
  322. package/gel-core/sequence.js.map +1 -0
  323. package/gel-core/session.cjs +94 -0
  324. package/gel-core/session.cjs.map +1 -0
  325. package/gel-core/session.d.cts +56 -0
  326. package/gel-core/session.d.ts +56 -0
  327. package/gel-core/session.js +68 -0
  328. package/gel-core/session.js.map +1 -0
  329. package/gel-core/subquery.cjs +17 -0
  330. package/gel-core/subquery.cjs.map +1 -0
  331. package/gel-core/subquery.d.cts +5 -0
  332. package/gel-core/subquery.d.ts +5 -0
  333. package/gel-core/subquery.js +1 -0
  334. package/gel-core/subquery.js.map +1 -0
  335. package/gel-core/table.cjs +100 -0
  336. package/gel-core/table.cjs.map +1 -0
  337. package/gel-core/table.d.cts +95 -0
  338. package/gel-core/table.d.ts +95 -0
  339. package/gel-core/table.js +71 -0
  340. package/gel-core/table.js.map +1 -0
  341. package/gel-core/unique-constraint.cjs +89 -0
  342. package/gel-core/unique-constraint.cjs.map +1 -0
  343. package/gel-core/unique-constraint.d.cts +25 -0
  344. package/gel-core/unique-constraint.d.ts +25 -0
  345. package/gel-core/unique-constraint.js +61 -0
  346. package/gel-core/unique-constraint.js.map +1 -0
  347. package/gel-core/utils.cjs +100 -0
  348. package/gel-core/utils.cjs.map +1 -0
  349. package/gel-core/utils.d.cts +51 -0
  350. package/gel-core/utils.d.ts +51 -0
  351. package/gel-core/utils.js +74 -0
  352. package/gel-core/utils.js.map +1 -0
  353. package/gel-core/view-base.cjs +33 -0
  354. package/gel-core/view-base.cjs.map +1 -0
  355. package/gel-core/view-base.d.cts +8 -0
  356. package/gel-core/view-base.d.ts +8 -0
  357. package/gel-core/view-base.js +9 -0
  358. package/gel-core/view-base.js.map +1 -0
  359. package/gel-core/view-common.cjs +29 -0
  360. package/gel-core/view-common.cjs.map +1 -0
  361. package/gel-core/view-common.d.cts +1 -0
  362. package/gel-core/view-common.d.ts +1 -0
  363. package/gel-core/view-common.js +5 -0
  364. package/gel-core/view-common.js.map +1 -0
  365. package/gel-core/view.cjs +302 -0
  366. package/gel-core/view.cjs.map +1 -0
  367. package/gel-core/view.d.cts +150 -0
  368. package/gel-core/view.d.ts +150 -0
  369. package/gel-core/view.js +268 -0
  370. package/gel-core/view.js.map +1 -0
  371. package/neon/neon-identity.cjs +2 -2
  372. package/neon/neon-identity.cjs.map +1 -1
  373. package/neon/neon-identity.d.cts +3 -3
  374. package/neon/neon-identity.d.ts +3 -3
  375. package/neon/neon-identity.js +2 -2
  376. package/neon/neon-identity.js.map +1 -1
  377. package/package.json +782 -49
  378. package/pg-core/table.cjs +2 -0
  379. package/pg-core/table.cjs.map +1 -1
  380. package/pg-core/table.js +2 -0
  381. package/pg-core/table.js.map +1 -1
  382. package/table.cjs.map +1 -1
  383. package/table.js.map +1 -1
  384. package/version.cjs +1 -1
  385. package/version.d.cts +1 -1
  386. package/version.d.ts +1 -1
  387. package/version.js +1 -1
@@ -0,0 +1,205 @@
1
+ import { entityKind, is } from "../../entity.js";
2
+ import { GelTable } from "../table.js";
3
+ import { QueryPromise } from "../../query-promise.js";
4
+ import { SelectionProxyHandler } from "../../selection-proxy.js";
5
+ import { SQL } from "../../sql/sql.js";
6
+ import { Subquery } from "../../subquery.js";
7
+ import { Table } from "../../table.js";
8
+ import {
9
+ getTableLikeName,
10
+ mapUpdateSet,
11
+ orderSelectedFields
12
+ } from "../../utils.js";
13
+ import { ViewBaseConfig } from "../../view-common.js";
14
+ class GelUpdateBuilder {
15
+ constructor(table, session, dialect, withList) {
16
+ this.table = table;
17
+ this.session = session;
18
+ this.dialect = dialect;
19
+ this.withList = withList;
20
+ }
21
+ static [entityKind] = "GelUpdateBuilder";
22
+ authToken;
23
+ setToken(token) {
24
+ this.authToken = token;
25
+ return this;
26
+ }
27
+ set(values) {
28
+ return new GelUpdateBase(
29
+ this.table,
30
+ mapUpdateSet(this.table, values),
31
+ this.session,
32
+ this.dialect,
33
+ this.withList
34
+ );
35
+ }
36
+ }
37
+ class GelUpdateBase extends QueryPromise {
38
+ constructor(table, set, session, dialect, withList) {
39
+ super();
40
+ this.session = session;
41
+ this.dialect = dialect;
42
+ this.config = { set, table, withList, joins: [] };
43
+ this.tableName = getTableLikeName(table);
44
+ this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
45
+ }
46
+ static [entityKind] = "GelUpdate";
47
+ config;
48
+ tableName;
49
+ joinsNotNullableMap;
50
+ from(source) {
51
+ const tableName = getTableLikeName(source);
52
+ if (typeof tableName === "string") {
53
+ this.joinsNotNullableMap[tableName] = true;
54
+ }
55
+ this.config.from = source;
56
+ return this;
57
+ }
58
+ getTableLikeFields(table) {
59
+ if (is(table, GelTable)) {
60
+ return table[Table.Symbol.Columns];
61
+ } else if (is(table, Subquery)) {
62
+ return table._.selectedFields;
63
+ }
64
+ return table[ViewBaseConfig].selectedFields;
65
+ }
66
+ createJoin(joinType) {
67
+ return (table, on) => {
68
+ const tableName = getTableLikeName(table);
69
+ if (typeof tableName === "string" && this.config.joins.some((join) => join.alias === tableName)) {
70
+ throw new Error(`Alias "${tableName}" is already used in this query`);
71
+ }
72
+ if (typeof on === "function") {
73
+ const from = this.config.from && !is(this.config.from, SQL) ? this.getTableLikeFields(this.config.from) : void 0;
74
+ on = on(
75
+ new Proxy(
76
+ this.config.table[Table.Symbol.Columns],
77
+ new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
78
+ ),
79
+ from && new Proxy(
80
+ from,
81
+ new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
82
+ )
83
+ );
84
+ }
85
+ this.config.joins.push({ on, table, joinType, alias: tableName });
86
+ if (typeof tableName === "string") {
87
+ switch (joinType) {
88
+ case "left": {
89
+ this.joinsNotNullableMap[tableName] = false;
90
+ break;
91
+ }
92
+ case "right": {
93
+ this.joinsNotNullableMap = Object.fromEntries(
94
+ Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
95
+ );
96
+ this.joinsNotNullableMap[tableName] = true;
97
+ break;
98
+ }
99
+ case "inner": {
100
+ this.joinsNotNullableMap[tableName] = true;
101
+ break;
102
+ }
103
+ case "full": {
104
+ this.joinsNotNullableMap = Object.fromEntries(
105
+ Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
106
+ );
107
+ this.joinsNotNullableMap[tableName] = false;
108
+ break;
109
+ }
110
+ }
111
+ }
112
+ return this;
113
+ };
114
+ }
115
+ leftJoin = this.createJoin("left");
116
+ rightJoin = this.createJoin("right");
117
+ innerJoin = this.createJoin("inner");
118
+ fullJoin = this.createJoin("full");
119
+ /**
120
+ * Adds a 'where' clause to the query.
121
+ *
122
+ * Calling this method will update only those rows that fulfill a specified condition.
123
+ *
124
+ * See docs: {@link https://orm.drizzle.team/docs/update}
125
+ *
126
+ * @param where the 'where' clause.
127
+ *
128
+ * @example
129
+ * You can use conditional operators and `sql function` to filter the rows to be updated.
130
+ *
131
+ * ```ts
132
+ * // Update all cars with green color
133
+ * await db.update(cars).set({ color: 'red' })
134
+ * .where(eq(cars.color, 'green'));
135
+ * // or
136
+ * await db.update(cars).set({ color: 'red' })
137
+ * .where(sql`${cars.color} = 'green'`)
138
+ * ```
139
+ *
140
+ * You can logically combine conditional operators with `and()` and `or()` operators:
141
+ *
142
+ * ```ts
143
+ * // Update all BMW cars with a green color
144
+ * await db.update(cars).set({ color: 'red' })
145
+ * .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
146
+ *
147
+ * // Update all cars with the green or blue color
148
+ * await db.update(cars).set({ color: 'red' })
149
+ * .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
150
+ * ```
151
+ */
152
+ where(where) {
153
+ this.config.where = where;
154
+ return this;
155
+ }
156
+ returning(fields) {
157
+ if (!fields) {
158
+ fields = Object.assign({}, this.config.table[Table.Symbol.Columns]);
159
+ if (this.config.from) {
160
+ const tableName = getTableLikeName(this.config.from);
161
+ if (typeof tableName === "string" && this.config.from && !is(this.config.from, SQL)) {
162
+ const fromFields = this.getTableLikeFields(this.config.from);
163
+ fields[tableName] = fromFields;
164
+ }
165
+ for (const join of this.config.joins) {
166
+ const tableName2 = getTableLikeName(join.table);
167
+ if (typeof tableName2 === "string" && !is(join.table, SQL)) {
168
+ const fromFields = this.getTableLikeFields(join.table);
169
+ fields[tableName2] = fromFields;
170
+ }
171
+ }
172
+ }
173
+ }
174
+ this.config.returning = orderSelectedFields(fields);
175
+ return this;
176
+ }
177
+ /** @internal */
178
+ getSQL() {
179
+ return this.dialect.buildUpdateQuery(this.config);
180
+ }
181
+ toSQL() {
182
+ const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
183
+ return rest;
184
+ }
185
+ /** @internal */
186
+ _prepare(name) {
187
+ const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true);
188
+ query.joinsNotNullableMap = this.joinsNotNullableMap;
189
+ return query;
190
+ }
191
+ prepare(name) {
192
+ return this._prepare(name);
193
+ }
194
+ execute = (placeholderValues) => {
195
+ return this._prepare().execute(placeholderValues);
196
+ };
197
+ $dynamic() {
198
+ return this;
199
+ }
200
+ }
201
+ export {
202
+ GelUpdateBase,
203
+ GelUpdateBuilder
204
+ };
205
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/gel-core/query-builders/update.ts"],"sourcesContent":["import type { GetColumnData } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type {\n\tGelPreparedQuery,\n\tGelQueryResultHKT,\n\tGelQueryResultKind,\n\tGelSession,\n\tPreparedQueryConfig,\n} from '~/gel-core/session.ts';\nimport { GelTable } from '~/gel-core/table.ts';\nimport type {\n\tAppendToNullabilityMap,\n\tAppendToResult,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tJoinType,\n\tSelectMode,\n\tSelectResult,\n} from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { type ColumnsSelection, type Query, SQL, type SQLWrapper } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport {\n\ttype Assume,\n\tgetTableLikeName,\n\tmapUpdateSet,\n\ttype NeonAuthToken,\n\torderSelectedFields,\n\ttype UpdateSet,\n} from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { GelColumn } from '../columns/common.ts';\nimport type { GelViewBase } from '../view-base.ts';\nimport type { GelSelectJoinConfig, SelectedFields, SelectedFieldsOrdered } from './select.types.ts';\n\nexport interface GelUpdateConfig {\n\twhere?: SQL | undefined;\n\tset: UpdateSet;\n\ttable: GelTable;\n\tfrom?: GelTable | Subquery | GelViewBase | SQL;\n\tjoins: GelSelectJoinConfig[];\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type GelUpdateSetSource<TTable extends GelTable> =\n\t& {\n\t\t[Key in keyof TTable['$inferInsert']]?:\n\t\t\t| GetColumnData<TTable['_']['columns'][Key]>\n\t\t\t| SQL\n\t\t\t| GelColumn;\n\t}\n\t& {};\n\nexport class GelUpdateBuilder<TTable extends GelTable, TQueryResult extends GelQueryResultHKT> {\n\tstatic readonly [entityKind]: string = 'GelUpdateBuilder';\n\n\tdeclare readonly _: {\n\t\treadonly table: TTable;\n\t};\n\n\tconstructor(\n\t\tprivate table: TTable,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\tprivate withList?: Subquery[],\n\t) {}\n\n\tprivate authToken?: NeonAuthToken;\n\tsetToken(token: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\tset(\n\t\tvalues: GelUpdateSetSource<TTable>,\n\t): GelUpdateWithout<GelUpdateBase<TTable, TQueryResult>, false, 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'> {\n\t\treturn new GelUpdateBase<TTable, TQueryResult>(\n\t\t\tthis.table,\n\t\t\tmapUpdateSet(this.table, values),\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t);\n\t}\n}\n\nexport type GelUpdateWithout<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T : Omit<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tT['_']['returning'],\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods'] | K\n\t>,\n\tT['_']['excludedMethods'] | K\n>;\n\nexport type GelUpdateWithJoins<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL,\n> = TDynamic extends true ? T : Omit<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tTFrom,\n\t\tT['_']['returning'],\n\t\tAppendToNullabilityMap<T['_']['nullabilityMap'], GetSelectTableName<TFrom>, 'inner'>,\n\t\t[...T['_']['joins'], {\n\t\t\tname: GetSelectTableName<TFrom>;\n\t\t\tjoinType: 'inner';\n\t\t\ttable: TFrom;\n\t\t}],\n\t\tTDynamic,\n\t\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n\t>,\n\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n>;\n\nexport type GelUpdateJoinFn<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n> = <\n\tTJoinedTable extends GelTable | Subquery | GelViewBase | SQL,\n>(\n\ttable: TJoinedTable,\n\ton:\n\t\t| (\n\t\t\t(\n\t\t\t\tupdateTable: T['_']['table']['_']['columns'],\n\t\t\t\tfrom: T['_']['from'] extends GelTable ? T['_']['from']['_']['columns']\n\t\t\t\t\t: T['_']['from'] extends Subquery | GelViewBase ? T['_']['from']['_']['selectedFields']\n\t\t\t\t\t: never,\n\t\t\t) => SQL | undefined\n\t\t)\n\t\t| SQL\n\t\t| undefined,\n) => GelUpdateJoin<T, TDynamic, TJoinType, TJoinedTable>;\n\nexport type GelUpdateJoin<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n\tTJoinedTable extends GelTable | Subquery | GelViewBase | SQL,\n> = TDynamic extends true ? T : GelUpdateBase<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['from'],\n\tT['_']['returning'],\n\tAppendToNullabilityMap<T['_']['nullabilityMap'], GetSelectTableName<TJoinedTable>, TJoinType>,\n\t[...T['_']['joins'], {\n\t\tname: GetSelectTableName<TJoinedTable>;\n\t\tjoinType: TJoinType;\n\t\ttable: TJoinedTable;\n\t}],\n\tTDynamic,\n\tT['_']['excludedMethods']\n>;\n\ntype Join = {\n\tname: string | undefined;\n\tjoinType: JoinType;\n\ttable: GelTable | Subquery | GelViewBase | SQL;\n};\n\ntype AccumulateToResult<\n\tT extends AnyGelUpdate,\n\tTSelectMode extends SelectMode,\n\tTJoins extends Join[],\n\tTSelectedFields extends ColumnsSelection,\n> = TJoins extends [infer TJoin extends Join, ...infer TRest extends Join[]] ? AccumulateToResult<\n\t\tT,\n\t\tTSelectMode extends 'partial' ? TSelectMode : 'multiple',\n\t\tTRest,\n\t\tAppendToResult<\n\t\t\tT['_']['table']['_']['name'],\n\t\t\tTSelectedFields,\n\t\t\tTJoin['name'],\n\t\t\tTJoin['table'] extends Table ? TJoin['table']['_']['columns']\n\t\t\t\t: TJoin['table'] extends Subquery ? Assume<TJoin['table']['_']['selectedFields'], SelectedFields>\n\t\t\t\t: never,\n\t\t\tTSelectMode extends 'partial' ? TSelectMode : 'multiple'\n\t\t>\n\t>\n\t: TSelectedFields;\n\nexport type GelUpdateReturningAll<T extends AnyGelUpdate, TDynamic extends boolean> = GelUpdateWithout<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tSelectResult<\n\t\t\tAccumulateToResult<\n\t\t\t\tT,\n\t\t\t\t'single',\n\t\t\t\tT['_']['joins'],\n\t\t\t\tGetSelectTableSelection<T['_']['table']>\n\t\t\t>,\n\t\t\t'partial',\n\t\t\tT['_']['nullabilityMap']\n\t\t>,\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelUpdateReturning<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFields,\n> = GelUpdateWithout<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tSelectResult<\n\t\t\tAccumulateToResult<\n\t\t\t\tT,\n\t\t\t\t'partial',\n\t\t\t\tT['_']['joins'],\n\t\t\t\tTSelectedFields\n\t\t\t>,\n\t\t\t'partial',\n\t\t\tT['_']['nullabilityMap']\n\t\t>,\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelUpdatePrepare<T extends AnyGelUpdate> = GelPreparedQuery<\n\tPreparedQueryConfig & {\n\t\texecute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never>\n\t\t\t: T['_']['returning'][];\n\t}\n>;\n\nexport type GelUpdateDynamic<T extends AnyGelUpdate> = GelUpdate<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['from'],\n\tT['_']['returning'],\n\tT['_']['nullabilityMap']\n>;\n\nexport type GelUpdate<\n\tTTable extends GelTable = GelTable,\n\tTQueryResult extends GelQueryResultHKT = GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\tTJoins extends Join[] = [],\n> = GelUpdateBase<TTable, TQueryResult, TFrom, TReturning, TNullabilityMap, TJoins, true, never>;\n\nexport type AnyGelUpdate = GelUpdateBase<any, any, any, any, any, any, any, any>;\n\nexport interface GelUpdateBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\tTJoins extends Join[] = [],\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends\n\tQueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>,\n\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\tSQLWrapper\n{\n\treadonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly table: TTable;\n\t\treadonly joins: TJoins;\n\t\treadonly nullabilityMap: TNullabilityMap;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly from: TFrom;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t};\n}\n\nexport class GelUpdateBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTJoins extends Join[] = [],\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTDynamic extends boolean = false,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTExcludedMethods extends string = never,\n> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>\n\timplements\n\t\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\t\tSQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelUpdate';\n\n\tprivate config: GelUpdateConfig;\n\tprivate tableName: string | undefined;\n\tprivate joinsNotNullableMap: Record<string, boolean>;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tset: UpdateSet,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { set, table, withList, joins: [] };\n\t\tthis.tableName = getTableLikeName(table);\n\t\tthis.joinsNotNullableMap = typeof this.tableName === 'string' ? { [this.tableName]: true } : {};\n\t}\n\n\tfrom<TFrom extends GelTable | Subquery | GelViewBase | SQL>(\n\t\tsource: TFrom,\n\t): GelUpdateWithJoins<this, TDynamic, TFrom> {\n\t\tconst tableName = getTableLikeName(source);\n\t\tif (typeof tableName === 'string') {\n\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t}\n\t\tthis.config.from = source;\n\t\treturn this as any;\n\t}\n\n\tprivate getTableLikeFields(table: GelTable | Subquery | GelViewBase): Record<string, unknown> {\n\t\tif (is(table, GelTable)) {\n\t\t\treturn table[Table.Symbol.Columns];\n\t\t} else if (is(table, Subquery)) {\n\t\t\treturn table._.selectedFields;\n\t\t}\n\t\treturn table[ViewBaseConfig].selectedFields;\n\t}\n\n\tprivate createJoin<TJoinType extends JoinType>(\n\t\tjoinType: TJoinType,\n\t): GelUpdateJoinFn<this, TDynamic, TJoinType> {\n\t\treturn ((\n\t\t\ttable: GelTable | Subquery | GelViewBase | SQL,\n\t\t\ton: ((updateTable: TTable, from: TFrom) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\tconst from = this.config.from && !is(this.config.from, SQL)\n\t\t\t\t\t? this.getTableLikeFields(this.config.from)\n\t\t\t\t\t: undefined;\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.table[Table.Symbol.Columns],\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t\tfrom && new Proxy(\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName });\n\n\t\t\tif (typeof tableName === 'string') {\n\t\t\t\tswitch (joinType) {\n\t\t\t\t\tcase 'left': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'right': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'inner': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'full': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this as any;\n\t\t}) as any;\n\t}\n\n\tleftJoin = this.createJoin('left');\n\n\trightJoin = this.createJoin('right');\n\n\tinnerJoin = this.createJoin('inner');\n\n\tfullJoin = this.createJoin('full');\n\n\t/**\n\t * Adds a 'where' clause to the query.\n\t *\n\t * Calling this method will update only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param where the 'where' clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be updated.\n\t *\n\t * ```ts\n\t * // Update all cars with green color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Update all BMW cars with a green color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Update all cars with the green or blue color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(where: SQL | undefined): GelUpdateWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `returning` clause to the query.\n\t *\n\t * Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}\n\t *\n\t * @example\n\t * ```ts\n\t * // Update all cars with the green color and return all fields\n\t * const updatedCars: Car[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning();\n\t *\n\t * // Update all cars with the green color and return only their id and brand fields\n\t * const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning({ id: cars.id, brand: cars.brand });\n\t * ```\n\t */\n\treturning(): GelUpdateReturningAll<this, TDynamic>;\n\treturning<TSelectedFields extends SelectedFields>(\n\t\tfields: TSelectedFields,\n\t): GelUpdateReturning<this, TDynamic, TSelectedFields>;\n\treturning(\n\t\tfields?: SelectedFields,\n\t): GelUpdateWithout<AnyGelUpdate, TDynamic, 'returning'> {\n\t\tif (!fields) {\n\t\t\tfields = Object.assign({}, this.config.table[Table.Symbol.Columns]);\n\n\t\t\tif (this.config.from) {\n\t\t\t\tconst tableName = getTableLikeName(this.config.from);\n\n\t\t\t\tif (typeof tableName === 'string' && this.config.from && !is(this.config.from, SQL)) {\n\t\t\t\t\tconst fromFields = this.getTableLikeFields(this.config.from);\n\t\t\t\t\tfields[tableName] = fromFields as any;\n\t\t\t\t}\n\n\t\t\t\tfor (const join of this.config.joins) {\n\t\t\t\t\tconst tableName = getTableLikeName(join.table);\n\n\t\t\t\t\tif (typeof tableName === 'string' && !is(join.table, SQL)) {\n\t\t\t\t\t\tconst fromFields = this.getTableLikeFields(join.table);\n\t\t\t\t\t\tfields[tableName] = fromFields as any;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.config.returning = orderSelectedFields<GelColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildUpdateQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\t/** @internal */\n\t_prepare(name?: string): GelUpdatePrepare<this> {\n\t\tconst query = this.session.prepareQuery<\n\t\t\tPreparedQueryConfig & { execute: TReturning[] }\n\t\t>(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true);\n\t\tquery.joinsNotNullableMap = this.joinsNotNullableMap;\n\t\treturn query;\n\t}\n\n\tprepare(name: string): GelUpdatePrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn this._prepare().execute(placeholderValues);\n\t};\n\n\t$dynamic(): GelUpdateDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":"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","names":["tableName"]}
@@ -0,0 +1,57 @@
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 roles_exports = {};
20
+ __export(roles_exports, {
21
+ GelRole: () => GelRole,
22
+ gelRole: () => gelRole
23
+ });
24
+ module.exports = __toCommonJS(roles_exports);
25
+ var import_entity = require("../entity.cjs");
26
+ class GelRole {
27
+ constructor(name, config) {
28
+ this.name = name;
29
+ if (config) {
30
+ this.createDb = config.createDb;
31
+ this.createRole = config.createRole;
32
+ this.inherit = config.inherit;
33
+ }
34
+ }
35
+ static [import_entity.entityKind] = "GelRole";
36
+ /** @internal */
37
+ _existing;
38
+ /** @internal */
39
+ createDb;
40
+ /** @internal */
41
+ createRole;
42
+ /** @internal */
43
+ inherit;
44
+ existing() {
45
+ this._existing = true;
46
+ return this;
47
+ }
48
+ }
49
+ function gelRole(name, config) {
50
+ return new GelRole(name, config);
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ GelRole,
55
+ gelRole
56
+ });
57
+ //# sourceMappingURL=roles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/gel-core/roles.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\n\nexport interface GelRoleConfig {\n\tcreateDb?: boolean;\n\tcreateRole?: boolean;\n\tinherit?: boolean;\n}\n\nexport class GelRole implements GelRoleConfig {\n\tstatic readonly [entityKind]: string = 'GelRole';\n\n\t/** @internal */\n\t_existing?: boolean;\n\n\t/** @internal */\n\treadonly createDb: GelRoleConfig['createDb'];\n\t/** @internal */\n\treadonly createRole: GelRoleConfig['createRole'];\n\t/** @internal */\n\treadonly inherit: GelRoleConfig['inherit'];\n\n\tconstructor(\n\t\treadonly name: string,\n\t\tconfig?: GelRoleConfig,\n\t) {\n\t\tif (config) {\n\t\t\tthis.createDb = config.createDb;\n\t\t\tthis.createRole = config.createRole;\n\t\t\tthis.inherit = config.inherit;\n\t\t}\n\t}\n\n\texisting(): this {\n\t\tthis._existing = true;\n\t\treturn this;\n\t}\n}\n\nexport function gelRole(name: string, config?: GelRoleConfig) {\n\treturn new GelRole(name, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAQpB,MAAM,QAAiC;AAAA,EAa7C,YACU,MACT,QACC;AAFQ;AAGT,QAAI,QAAQ;AACX,WAAK,WAAW,OAAO;AACvB,WAAK,aAAa,OAAO;AACzB,WAAK,UAAU,OAAO;AAAA,IACvB;AAAA,EACD;AAAA,EArBA,QAAiB,wBAAU,IAAY;AAAA;AAAA,EAGvC;AAAA;AAAA,EAGS;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAaT,WAAiB;AAChB,SAAK,YAAY;AACjB,WAAO;AAAA,EACR;AACD;AAEO,SAAS,QAAQ,MAAc,QAAwB;AAC7D,SAAO,IAAI,QAAQ,MAAM,MAAM;AAChC;","names":[]}
@@ -0,0 +1,13 @@
1
+ import { entityKind } from "../entity.cjs";
2
+ export interface GelRoleConfig {
3
+ createDb?: boolean;
4
+ createRole?: boolean;
5
+ inherit?: boolean;
6
+ }
7
+ export declare class GelRole implements GelRoleConfig {
8
+ readonly name: string;
9
+ static readonly [entityKind]: string;
10
+ constructor(name: string, config?: GelRoleConfig);
11
+ existing(): this;
12
+ }
13
+ export declare function gelRole(name: string, config?: GelRoleConfig): GelRole;
@@ -0,0 +1,13 @@
1
+ import { entityKind } from "../entity.js";
2
+ export interface GelRoleConfig {
3
+ createDb?: boolean;
4
+ createRole?: boolean;
5
+ inherit?: boolean;
6
+ }
7
+ export declare class GelRole implements GelRoleConfig {
8
+ readonly name: string;
9
+ static readonly [entityKind]: string;
10
+ constructor(name: string, config?: GelRoleConfig);
11
+ existing(): this;
12
+ }
13
+ export declare function gelRole(name: string, config?: GelRoleConfig): GelRole;
@@ -0,0 +1,32 @@
1
+ import { entityKind } from "../entity.js";
2
+ class GelRole {
3
+ constructor(name, config) {
4
+ this.name = name;
5
+ if (config) {
6
+ this.createDb = config.createDb;
7
+ this.createRole = config.createRole;
8
+ this.inherit = config.inherit;
9
+ }
10
+ }
11
+ static [entityKind] = "GelRole";
12
+ /** @internal */
13
+ _existing;
14
+ /** @internal */
15
+ createDb;
16
+ /** @internal */
17
+ createRole;
18
+ /** @internal */
19
+ inherit;
20
+ existing() {
21
+ this._existing = true;
22
+ return this;
23
+ }
24
+ }
25
+ function gelRole(name, config) {
26
+ return new GelRole(name, config);
27
+ }
28
+ export {
29
+ GelRole,
30
+ gelRole
31
+ };
32
+ //# sourceMappingURL=roles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/gel-core/roles.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\n\nexport interface GelRoleConfig {\n\tcreateDb?: boolean;\n\tcreateRole?: boolean;\n\tinherit?: boolean;\n}\n\nexport class GelRole implements GelRoleConfig {\n\tstatic readonly [entityKind]: string = 'GelRole';\n\n\t/** @internal */\n\t_existing?: boolean;\n\n\t/** @internal */\n\treadonly createDb: GelRoleConfig['createDb'];\n\t/** @internal */\n\treadonly createRole: GelRoleConfig['createRole'];\n\t/** @internal */\n\treadonly inherit: GelRoleConfig['inherit'];\n\n\tconstructor(\n\t\treadonly name: string,\n\t\tconfig?: GelRoleConfig,\n\t) {\n\t\tif (config) {\n\t\t\tthis.createDb = config.createDb;\n\t\t\tthis.createRole = config.createRole;\n\t\t\tthis.inherit = config.inherit;\n\t\t}\n\t}\n\n\texisting(): this {\n\t\tthis._existing = true;\n\t\treturn this;\n\t}\n}\n\nexport function gelRole(name: string, config?: GelRoleConfig) {\n\treturn new GelRole(name, config);\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAQpB,MAAM,QAAiC;AAAA,EAa7C,YACU,MACT,QACC;AAFQ;AAGT,QAAI,QAAQ;AACX,WAAK,WAAW,OAAO;AACvB,WAAK,aAAa,OAAO;AACzB,WAAK,UAAU,OAAO;AAAA,IACvB;AAAA,EACD;AAAA,EArBA,QAAiB,UAAU,IAAY;AAAA;AAAA,EAGvC;AAAA;AAAA,EAGS;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAaT,WAAiB;AAChB,SAAK,YAAY;AACjB,WAAO;AAAA,EACR;AACD;AAEO,SAAS,QAAQ,MAAc,QAAwB;AAC7D,SAAO,IAAI,QAAQ,MAAM,MAAM;AAChC;","names":[]}
@@ -0,0 +1,74 @@
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 schema_exports = {};
20
+ __export(schema_exports, {
21
+ GelSchema: () => GelSchema,
22
+ gelSchema: () => gelSchema,
23
+ isGelSchema: () => isGelSchema
24
+ });
25
+ module.exports = __toCommonJS(schema_exports);
26
+ var import_entity = require("../entity.cjs");
27
+ var import_sql = require("../sql/sql.cjs");
28
+ var import_sequence = require("./sequence.cjs");
29
+ var import_table = require("./table.cjs");
30
+ class GelSchema {
31
+ constructor(schemaName) {
32
+ this.schemaName = schemaName;
33
+ }
34
+ static [import_entity.entityKind] = "GelSchema";
35
+ table = (name, columns, extraConfig) => {
36
+ return (0, import_table.gelTableWithSchema)(name, columns, extraConfig, this.schemaName);
37
+ };
38
+ // view = ((name, columns) => {
39
+ // return gelViewWithSchema(name, columns, this.schemaName);
40
+ // }) as typeof gelView;
41
+ // materializedView = ((name, columns) => {
42
+ // return gelMaterializedViewWithSchema(name, columns, this.schemaName);
43
+ // }) as typeof gelMaterializedView;
44
+ // enum: typeof gelEnum = ((name, values) => {
45
+ // return gelEnumWithSchema(name, values, this.schemaName);
46
+ // });
47
+ sequence = (name, options) => {
48
+ return (0, import_sequence.gelSequenceWithSchema)(name, options, this.schemaName);
49
+ };
50
+ getSQL() {
51
+ return new import_sql.SQL([import_sql.sql.identifier(this.schemaName)]);
52
+ }
53
+ shouldOmitSQLParens() {
54
+ return true;
55
+ }
56
+ }
57
+ function isGelSchema(obj) {
58
+ return (0, import_entity.is)(obj, GelSchema);
59
+ }
60
+ function gelSchema(name) {
61
+ if (name === "public") {
62
+ throw new Error(
63
+ `You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use GelTable() instead of creating a schema`
64
+ );
65
+ }
66
+ return new GelSchema(name);
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ GelSchema,
71
+ gelSchema,
72
+ isGelSchema
73
+ });
74
+ //# sourceMappingURL=schema.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/gel-core/schema.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { gelSequence } from './sequence.ts';\nimport { gelSequenceWithSchema } from './sequence.ts';\nimport { type GelTableFn, gelTableWithSchema } from './table.ts';\n// import type { gelMaterializedView, gelView } from './view.ts';\n// import { gelMaterializedViewWithSchema, gelViewWithSchema } from './view.ts';\n\nexport class GelSchema<TName extends string = string> implements SQLWrapper {\n\tstatic readonly [entityKind]: string = 'GelSchema';\n\tconstructor(\n\t\tpublic readonly schemaName: TName,\n\t) {}\n\n\ttable: GelTableFn<TName> = ((name, columns, extraConfig) => {\n\t\treturn gelTableWithSchema(name, columns, extraConfig, this.schemaName);\n\t});\n\n\t// view = ((name, columns) => {\n\t// \treturn gelViewWithSchema(name, columns, this.schemaName);\n\t// }) as typeof gelView;\n\n\t// materializedView = ((name, columns) => {\n\t// \treturn gelMaterializedViewWithSchema(name, columns, this.schemaName);\n\t// }) as typeof gelMaterializedView;\n\n\t// enum: typeof gelEnum = ((name, values) => {\n\t// \treturn gelEnumWithSchema(name, values, this.schemaName);\n\t// });\n\n\tsequence: typeof gelSequence = ((name, options) => {\n\t\treturn gelSequenceWithSchema(name, options, this.schemaName);\n\t});\n\n\tgetSQL(): SQL {\n\t\treturn new SQL([sql.identifier(this.schemaName)]);\n\t}\n\n\tshouldOmitSQLParens(): boolean {\n\t\treturn true;\n\t}\n}\n\nexport function isGelSchema(obj: unknown): obj is GelSchema {\n\treturn is(obj, GelSchema);\n}\n\nexport function gelSchema<T extends string>(name: T) {\n\tif (name === 'public') {\n\t\tthrow new Error(\n\t\t\t`You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use GelTable() instead of creating a schema`,\n\t\t);\n\t}\n\n\treturn new GelSchema(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAC/B,iBAA0C;AAE1C,sBAAsC;AACtC,mBAAoD;AAI7C,MAAM,UAA+D;AAAA,EAE3E,YACiB,YACf;AADe;AAAA,EACd;AAAA,EAHH,QAAiB,wBAAU,IAAY;AAAA,EAKvC,QAA4B,CAAC,MAAM,SAAS,gBAAgB;AAC3D,eAAO,iCAAmB,MAAM,SAAS,aAAa,KAAK,UAAU;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,WAAgC,CAAC,MAAM,YAAY;AAClD,eAAO,uCAAsB,MAAM,SAAS,KAAK,UAAU;AAAA,EAC5D;AAAA,EAEA,SAAc;AACb,WAAO,IAAI,eAAI,CAAC,eAAI,WAAW,KAAK,UAAU,CAAC,CAAC;AAAA,EACjD;AAAA,EAEA,sBAA+B;AAC9B,WAAO;AAAA,EACR;AACD;AAEO,SAAS,YAAY,KAAgC;AAC3D,aAAO,kBAAG,KAAK,SAAS;AACzB;AAEO,SAAS,UAA4B,MAAS;AACpD,MAAI,SAAS,UAAU;AACtB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,IAAI,UAAU,IAAI;AAC1B;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { entityKind } from "../entity.cjs";
2
+ import { SQL, type SQLWrapper } from "../sql/sql.cjs";
3
+ import type { gelSequence } from "./sequence.cjs";
4
+ import { type GelTableFn } from "./table.cjs";
5
+ export declare class GelSchema<TName extends string = string> implements SQLWrapper {
6
+ readonly schemaName: TName;
7
+ static readonly [entityKind]: string;
8
+ constructor(schemaName: TName);
9
+ table: GelTableFn<TName>;
10
+ sequence: typeof gelSequence;
11
+ getSQL(): SQL;
12
+ shouldOmitSQLParens(): boolean;
13
+ }
14
+ export declare function isGelSchema(obj: unknown): obj is GelSchema;
15
+ export declare function gelSchema<T extends string>(name: T): GelSchema<T>;
@@ -0,0 +1,15 @@
1
+ import { entityKind } from "../entity.js";
2
+ import { SQL, type SQLWrapper } from "../sql/sql.js";
3
+ import type { gelSequence } from "./sequence.js";
4
+ import { type GelTableFn } from "./table.js";
5
+ export declare class GelSchema<TName extends string = string> implements SQLWrapper {
6
+ readonly schemaName: TName;
7
+ static readonly [entityKind]: string;
8
+ constructor(schemaName: TName);
9
+ table: GelTableFn<TName>;
10
+ sequence: typeof gelSequence;
11
+ getSQL(): SQL;
12
+ shouldOmitSQLParens(): boolean;
13
+ }
14
+ export declare function isGelSchema(obj: unknown): obj is GelSchema;
15
+ export declare function gelSchema<T extends string>(name: T): GelSchema<T>;
@@ -0,0 +1,48 @@
1
+ import { entityKind, is } from "../entity.js";
2
+ import { SQL, sql } from "../sql/sql.js";
3
+ import { gelSequenceWithSchema } from "./sequence.js";
4
+ import { gelTableWithSchema } from "./table.js";
5
+ class GelSchema {
6
+ constructor(schemaName) {
7
+ this.schemaName = schemaName;
8
+ }
9
+ static [entityKind] = "GelSchema";
10
+ table = (name, columns, extraConfig) => {
11
+ return gelTableWithSchema(name, columns, extraConfig, this.schemaName);
12
+ };
13
+ // view = ((name, columns) => {
14
+ // return gelViewWithSchema(name, columns, this.schemaName);
15
+ // }) as typeof gelView;
16
+ // materializedView = ((name, columns) => {
17
+ // return gelMaterializedViewWithSchema(name, columns, this.schemaName);
18
+ // }) as typeof gelMaterializedView;
19
+ // enum: typeof gelEnum = ((name, values) => {
20
+ // return gelEnumWithSchema(name, values, this.schemaName);
21
+ // });
22
+ sequence = (name, options) => {
23
+ return gelSequenceWithSchema(name, options, this.schemaName);
24
+ };
25
+ getSQL() {
26
+ return new SQL([sql.identifier(this.schemaName)]);
27
+ }
28
+ shouldOmitSQLParens() {
29
+ return true;
30
+ }
31
+ }
32
+ function isGelSchema(obj) {
33
+ return is(obj, GelSchema);
34
+ }
35
+ function gelSchema(name) {
36
+ if (name === "public") {
37
+ throw new Error(
38
+ `You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use GelTable() instead of creating a schema`
39
+ );
40
+ }
41
+ return new GelSchema(name);
42
+ }
43
+ export {
44
+ GelSchema,
45
+ gelSchema,
46
+ isGelSchema
47
+ };
48
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/gel-core/schema.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { gelSequence } from './sequence.ts';\nimport { gelSequenceWithSchema } from './sequence.ts';\nimport { type GelTableFn, gelTableWithSchema } from './table.ts';\n// import type { gelMaterializedView, gelView } from './view.ts';\n// import { gelMaterializedViewWithSchema, gelViewWithSchema } from './view.ts';\n\nexport class GelSchema<TName extends string = string> implements SQLWrapper {\n\tstatic readonly [entityKind]: string = 'GelSchema';\n\tconstructor(\n\t\tpublic readonly schemaName: TName,\n\t) {}\n\n\ttable: GelTableFn<TName> = ((name, columns, extraConfig) => {\n\t\treturn gelTableWithSchema(name, columns, extraConfig, this.schemaName);\n\t});\n\n\t// view = ((name, columns) => {\n\t// \treturn gelViewWithSchema(name, columns, this.schemaName);\n\t// }) as typeof gelView;\n\n\t// materializedView = ((name, columns) => {\n\t// \treturn gelMaterializedViewWithSchema(name, columns, this.schemaName);\n\t// }) as typeof gelMaterializedView;\n\n\t// enum: typeof gelEnum = ((name, values) => {\n\t// \treturn gelEnumWithSchema(name, values, this.schemaName);\n\t// });\n\n\tsequence: typeof gelSequence = ((name, options) => {\n\t\treturn gelSequenceWithSchema(name, options, this.schemaName);\n\t});\n\n\tgetSQL(): SQL {\n\t\treturn new SQL([sql.identifier(this.schemaName)]);\n\t}\n\n\tshouldOmitSQLParens(): boolean {\n\t\treturn true;\n\t}\n}\n\nexport function isGelSchema(obj: unknown): obj is GelSchema {\n\treturn is(obj, GelSchema);\n}\n\nexport function gelSchema<T extends string>(name: T) {\n\tif (name === 'public') {\n\t\tthrow new Error(\n\t\t\t`You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use GelTable() instead of creating a schema`,\n\t\t);\n\t}\n\n\treturn new GelSchema(name);\n}\n"],"mappings":"AAAA,SAAS,YAAY,UAAU;AAC/B,SAAS,KAAK,WAA4B;AAE1C,SAAS,6BAA6B;AACtC,SAA0B,0BAA0B;AAI7C,MAAM,UAA+D;AAAA,EAE3E,YACiB,YACf;AADe;AAAA,EACd;AAAA,EAHH,QAAiB,UAAU,IAAY;AAAA,EAKvC,QAA4B,CAAC,MAAM,SAAS,gBAAgB;AAC3D,WAAO,mBAAmB,MAAM,SAAS,aAAa,KAAK,UAAU;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,WAAgC,CAAC,MAAM,YAAY;AAClD,WAAO,sBAAsB,MAAM,SAAS,KAAK,UAAU;AAAA,EAC5D;AAAA,EAEA,SAAc;AACb,WAAO,IAAI,IAAI,CAAC,IAAI,WAAW,KAAK,UAAU,CAAC,CAAC;AAAA,EACjD;AAAA,EAEA,sBAA+B;AAC9B,WAAO;AAAA,EACR;AACD;AAEO,SAAS,YAAY,KAAgC;AAC3D,SAAO,GAAG,KAAK,SAAS;AACzB;AAEO,SAAS,UAA4B,MAAS;AACpD,MAAI,SAAS,UAAU;AACtB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,IAAI,UAAU,IAAI;AAC1B;","names":[]}
@@ -0,0 +1,52 @@
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 sequence_exports = {};
20
+ __export(sequence_exports, {
21
+ GelSequence: () => GelSequence,
22
+ gelSequence: () => gelSequence,
23
+ gelSequenceWithSchema: () => gelSequenceWithSchema,
24
+ isGelSequence: () => isGelSequence
25
+ });
26
+ module.exports = __toCommonJS(sequence_exports);
27
+ var import_entity = require("../entity.cjs");
28
+ class GelSequence {
29
+ constructor(seqName, seqOptions, schema) {
30
+ this.seqName = seqName;
31
+ this.seqOptions = seqOptions;
32
+ this.schema = schema;
33
+ }
34
+ static [import_entity.entityKind] = "GelSequence";
35
+ }
36
+ function gelSequence(name, options) {
37
+ return gelSequenceWithSchema(name, options, void 0);
38
+ }
39
+ function gelSequenceWithSchema(name, options, schema) {
40
+ return new GelSequence(name, options, schema);
41
+ }
42
+ function isGelSequence(obj) {
43
+ return (0, import_entity.is)(obj, GelSequence);
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ GelSequence,
48
+ gelSequence,
49
+ gelSequenceWithSchema,
50
+ isGelSequence
51
+ });
52
+ //# sourceMappingURL=sequence.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/gel-core/sequence.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\n\nexport type GelSequenceOptions = {\n\tincrement?: number | string;\n\tminValue?: number | string;\n\tmaxValue?: number | string;\n\tstartWith?: number | string;\n\tcache?: number | string;\n\tcycle?: boolean;\n};\n\nexport class GelSequence {\n\tstatic readonly [entityKind]: string = 'GelSequence';\n\n\tconstructor(\n\t\tpublic readonly seqName: string | undefined,\n\t\tpublic readonly seqOptions: GelSequenceOptions | undefined,\n\t\tpublic readonly schema: string | undefined,\n\t) {\n\t}\n}\n\nexport function gelSequence(\n\tname: string,\n\toptions?: GelSequenceOptions,\n): GelSequence {\n\treturn gelSequenceWithSchema(name, options, undefined);\n}\n\n/** @internal */\nexport function gelSequenceWithSchema(\n\tname: string,\n\toptions?: GelSequenceOptions,\n\tschema?: string,\n): GelSequence {\n\treturn new GelSequence(name, options, schema);\n}\n\nexport function isGelSequence(obj: unknown): obj is GelSequence {\n\treturn is(obj, GelSequence);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAWxB,MAAM,YAAY;AAAA,EAGxB,YACiB,SACA,YACA,QACf;AAHe;AACA;AACA;AAAA,EAEjB;AAAA,EAPA,QAAiB,wBAAU,IAAY;AAQxC;AAEO,SAAS,YACf,MACA,SACc;AACd,SAAO,sBAAsB,MAAM,SAAS,MAAS;AACtD;AAGO,SAAS,sBACf,MACA,SACA,QACc;AACd,SAAO,IAAI,YAAY,MAAM,SAAS,MAAM;AAC7C;AAEO,SAAS,cAAc,KAAkC;AAC/D,aAAO,kBAAG,KAAK,WAAW;AAC3B;","names":[]}
@@ -0,0 +1,18 @@
1
+ import { entityKind } from "../entity.cjs";
2
+ export type GelSequenceOptions = {
3
+ increment?: number | string;
4
+ minValue?: number | string;
5
+ maxValue?: number | string;
6
+ startWith?: number | string;
7
+ cache?: number | string;
8
+ cycle?: boolean;
9
+ };
10
+ export declare class GelSequence {
11
+ readonly seqName: string | undefined;
12
+ readonly seqOptions: GelSequenceOptions | undefined;
13
+ readonly schema: string | undefined;
14
+ static readonly [entityKind]: string;
15
+ constructor(seqName: string | undefined, seqOptions: GelSequenceOptions | undefined, schema: string | undefined);
16
+ }
17
+ export declare function gelSequence(name: string, options?: GelSequenceOptions): GelSequence;
18
+ export declare function isGelSequence(obj: unknown): obj is GelSequence;
@@ -0,0 +1,18 @@
1
+ import { entityKind } from "../entity.js";
2
+ export type GelSequenceOptions = {
3
+ increment?: number | string;
4
+ minValue?: number | string;
5
+ maxValue?: number | string;
6
+ startWith?: number | string;
7
+ cache?: number | string;
8
+ cycle?: boolean;
9
+ };
10
+ export declare class GelSequence {
11
+ readonly seqName: string | undefined;
12
+ readonly seqOptions: GelSequenceOptions | undefined;
13
+ readonly schema: string | undefined;
14
+ static readonly [entityKind]: string;
15
+ constructor(seqName: string | undefined, seqOptions: GelSequenceOptions | undefined, schema: string | undefined);
16
+ }
17
+ export declare function gelSequence(name: string, options?: GelSequenceOptions): GelSequence;
18
+ export declare function isGelSequence(obj: unknown): obj is GelSequence;