kysely 0.23.4 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/README.md +49 -25
  2. package/dist/cjs/dialect/database-introspector.d.ts +4 -2
  3. package/dist/cjs/dialect/mysql/mysql-adapter.js +2 -2
  4. package/dist/cjs/dialect/mysql/mysql-driver.d.ts +1 -1
  5. package/dist/cjs/dialect/mysql/mysql-driver.js +1 -1
  6. package/dist/cjs/dialect/mysql/mysql-introspector.d.ts +1 -1
  7. package/dist/cjs/dialect/mysql/mysql-introspector.js +19 -13
  8. package/dist/cjs/dialect/postgres/postgres-adapter.js +1 -1
  9. package/dist/cjs/dialect/postgres/postgres-introspector.d.ts +1 -1
  10. package/dist/cjs/dialect/postgres/postgres-introspector.js +3 -1
  11. package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +1 -0
  12. package/dist/cjs/dialect/sqlite/sqlite-dialect.js +1 -0
  13. package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +1 -1
  14. package/dist/cjs/dialect/sqlite/sqlite-introspector.js +6 -5
  15. package/dist/cjs/driver/runtime-driver.js +4 -2
  16. package/dist/cjs/expression/expression-builder.d.ts +386 -0
  17. package/dist/cjs/expression/expression-builder.js +92 -0
  18. package/dist/cjs/expression/expression-wrapper.d.ts +92 -0
  19. package/dist/cjs/expression/expression-wrapper.js +54 -0
  20. package/dist/cjs/expression/expression.d.ts +1 -1
  21. package/dist/cjs/helpers/postgres.d.ts +133 -0
  22. package/dist/cjs/helpers/postgres.js +141 -0
  23. package/dist/cjs/index.d.ts +4 -3
  24. package/dist/cjs/index.js +4 -2
  25. package/dist/cjs/kysely.d.ts +10 -0
  26. package/dist/cjs/kysely.js +12 -1
  27. package/dist/cjs/migration/file-migration-provider.d.ts +5 -2
  28. package/dist/cjs/migration/migrator.d.ts +5 -2
  29. package/dist/cjs/operation-node/aggregate-function-node.d.ts +3 -2
  30. package/dist/cjs/operation-node/aggregate-function-node.js +2 -2
  31. package/dist/cjs/operation-node/create-index-node.d.ts +2 -0
  32. package/dist/cjs/operation-node/delete-query-node.d.ts +1 -2
  33. package/dist/cjs/operation-node/delete-query-node.js +2 -8
  34. package/dist/cjs/operation-node/function-node.d.ts +13 -0
  35. package/dist/cjs/operation-node/function-node.js +19 -0
  36. package/dist/cjs/operation-node/operation-node-transformer.d.ts +2 -0
  37. package/dist/cjs/operation-node/operation-node-transformer.js +11 -2
  38. package/dist/cjs/operation-node/operation-node-visitor.d.ts +2 -0
  39. package/dist/cjs/operation-node/operation-node-visitor.js +1 -0
  40. package/dist/cjs/operation-node/operation-node.d.ts +1 -1
  41. package/dist/cjs/operation-node/operator-node.d.ts +13 -2
  42. package/dist/cjs/operation-node/operator-node.js +38 -3
  43. package/dist/cjs/operation-node/query-node.d.ts +25 -8
  44. package/dist/cjs/operation-node/query-node.js +9 -2
  45. package/dist/cjs/operation-node/select-query-node.d.ts +0 -1
  46. package/dist/cjs/operation-node/select-query-node.js +0 -6
  47. package/dist/cjs/operation-node/update-query-node.d.ts +0 -1
  48. package/dist/cjs/operation-node/update-query-node.js +0 -6
  49. package/dist/cjs/parser/binary-operation-parser.d.ts +9 -10
  50. package/dist/cjs/parser/binary-operation-parser.js +89 -39
  51. package/dist/cjs/parser/coalesce-parser.d.ts +0 -2
  52. package/dist/cjs/parser/coalesce-parser.js +0 -9
  53. package/dist/cjs/parser/expression-parser.d.ts +7 -3
  54. package/dist/cjs/parser/expression-parser.js +4 -4
  55. package/dist/cjs/parser/group-by-parser.d.ts +3 -2
  56. package/dist/cjs/parser/group-by-parser.js +3 -0
  57. package/dist/cjs/parser/insert-values-parser.d.ts +4 -1
  58. package/dist/cjs/parser/insert-values-parser.js +19 -13
  59. package/dist/cjs/parser/join-parser.js +1 -1
  60. package/dist/cjs/parser/parse-utils.d.ts +0 -2
  61. package/dist/cjs/parser/parse-utils.js +1 -8
  62. package/dist/cjs/parser/returning-parser.d.ts +2 -1
  63. package/dist/cjs/parser/select-parser.d.ts +5 -13
  64. package/dist/cjs/parser/select-parser.js +8 -4
  65. package/dist/cjs/parser/table-parser.d.ts +6 -3
  66. package/dist/cjs/parser/unary-operation-parser.d.ts +5 -2
  67. package/dist/cjs/parser/unary-operation-parser.js +9 -8
  68. package/dist/cjs/parser/update-set-parser.d.ts +4 -1
  69. package/dist/cjs/parser/update-set-parser.js +9 -4
  70. package/dist/cjs/parser/value-parser.d.ts +5 -0
  71. package/dist/cjs/parser/value-parser.js +1 -3
  72. package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +7 -0
  73. package/dist/cjs/plugin/camel-case/camel-case-plugin.js +10 -4
  74. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +1 -1
  75. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
  76. package/dist/cjs/query-builder/aggregate-function-builder.d.ts +40 -113
  77. package/dist/cjs/query-builder/aggregate-function-builder.js +23 -63
  78. package/dist/cjs/query-builder/delete-query-builder.d.ts +224 -205
  79. package/dist/cjs/query-builder/delete-query-builder.js +21 -27
  80. package/dist/cjs/query-builder/delete-result.js +3 -0
  81. package/dist/cjs/query-builder/deprecated-having-expression-builder.d.ts +62 -0
  82. package/dist/cjs/query-builder/deprecated-having-expression-builder.js +2 -0
  83. package/dist/cjs/query-builder/deprecated-on-expression-builder.d.ts +62 -0
  84. package/dist/cjs/query-builder/deprecated-on-expression-builder.js +2 -0
  85. package/dist/cjs/query-builder/deprecated-where-expression-builder.d.ts +62 -0
  86. package/dist/cjs/query-builder/deprecated-where-expression-builder.js +2 -0
  87. package/dist/cjs/query-builder/function-module.d.ts +304 -42
  88. package/dist/cjs/query-builder/function-module.js +44 -208
  89. package/dist/cjs/query-builder/having-interface.d.ts +19 -16
  90. package/dist/cjs/query-builder/insert-query-builder.d.ts +78 -30
  91. package/dist/cjs/query-builder/insert-query-builder.js +21 -30
  92. package/dist/cjs/query-builder/insert-result.js +3 -0
  93. package/dist/cjs/query-builder/join-builder.d.ts +23 -26
  94. package/dist/cjs/query-builder/join-builder.js +17 -22
  95. package/dist/cjs/query-builder/no-result-error.d.ts +1 -0
  96. package/dist/cjs/query-builder/no-result-error.js +5 -1
  97. package/dist/cjs/query-builder/on-conflict-builder.d.ts +158 -276
  98. package/dist/cjs/query-builder/on-conflict-builder.js +52 -36
  99. package/dist/cjs/query-builder/over-builder.d.ts +5 -0
  100. package/dist/cjs/query-builder/over-builder.js +7 -0
  101. package/dist/cjs/query-builder/returning-interface.d.ts +2 -2
  102. package/dist/cjs/query-builder/select-query-builder.d.ts +155 -243
  103. package/dist/cjs/query-builder/select-query-builder.js +333 -78
  104. package/dist/cjs/query-builder/update-query-builder.d.ts +149 -217
  105. package/dist/cjs/query-builder/update-query-builder.js +21 -115
  106. package/dist/cjs/query-builder/update-result.js +3 -0
  107. package/dist/cjs/query-builder/where-interface.d.ts +71 -184
  108. package/dist/cjs/query-compiler/default-query-compiler.d.ts +3 -0
  109. package/dist/cjs/query-compiler/default-query-compiler.js +18 -2
  110. package/dist/cjs/query-creator.d.ts +38 -2
  111. package/dist/cjs/query-creator.js +3 -45
  112. package/dist/cjs/query-executor/query-executor.d.ts +3 -3
  113. package/dist/cjs/raw-builder/raw-builder.d.ts +5 -3
  114. package/dist/cjs/raw-builder/raw-builder.js +13 -7
  115. package/dist/cjs/raw-builder/sql.d.ts +17 -9
  116. package/dist/cjs/raw-builder/sql.js +8 -2
  117. package/dist/cjs/schema/alter-column-builder.d.ts +5 -0
  118. package/dist/cjs/schema/alter-column-builder.js +7 -0
  119. package/dist/cjs/schema/alter-table-add-foreign-key-constraint-builder.d.ts +5 -0
  120. package/dist/cjs/schema/alter-table-add-foreign-key-constraint-builder.js +7 -0
  121. package/dist/cjs/schema/alter-table-drop-constraint-builder.d.ts +5 -0
  122. package/dist/cjs/schema/alter-table-drop-constraint-builder.js +7 -0
  123. package/dist/cjs/schema/column-definition-builder.d.ts +6 -1
  124. package/dist/cjs/schema/column-definition-builder.js +8 -1
  125. package/dist/cjs/schema/create-index-builder.d.ts +51 -9
  126. package/dist/cjs/schema/create-index-builder.js +17 -0
  127. package/dist/cjs/schema/create-schema-builder.d.ts +5 -0
  128. package/dist/cjs/schema/create-schema-builder.js +7 -0
  129. package/dist/cjs/schema/create-table-builder.d.ts +3 -1
  130. package/dist/cjs/schema/create-table-builder.js +3 -1
  131. package/dist/cjs/schema/create-type-builder.d.ts +5 -0
  132. package/dist/cjs/schema/create-type-builder.js +7 -0
  133. package/dist/cjs/schema/create-view-builder.d.ts +5 -0
  134. package/dist/cjs/schema/create-view-builder.js +7 -0
  135. package/dist/cjs/schema/drop-index-builder.d.ts +5 -0
  136. package/dist/cjs/schema/drop-index-builder.js +7 -0
  137. package/dist/cjs/schema/drop-schema-builder.d.ts +5 -0
  138. package/dist/cjs/schema/drop-schema-builder.js +7 -0
  139. package/dist/cjs/schema/drop-table-builder.d.ts +5 -0
  140. package/dist/cjs/schema/drop-table-builder.js +7 -0
  141. package/dist/cjs/schema/drop-type-builder.d.ts +5 -0
  142. package/dist/cjs/schema/drop-type-builder.js +7 -0
  143. package/dist/cjs/schema/drop-view-builder.d.ts +5 -0
  144. package/dist/cjs/schema/drop-view-builder.js +7 -0
  145. package/dist/cjs/schema/foreign-key-constraint-builder.d.ts +5 -0
  146. package/dist/cjs/schema/foreign-key-constraint-builder.js +7 -0
  147. package/dist/cjs/util/compilable.d.ts +1 -0
  148. package/dist/cjs/util/compilable.js +6 -0
  149. package/dist/cjs/util/explainable.d.ts +35 -0
  150. package/dist/cjs/util/log.d.ts +2 -0
  151. package/dist/cjs/util/object-utils.js +1 -1
  152. package/dist/cjs/util/streamable.d.ts +29 -0
  153. package/dist/cjs/util/streamable.js +2 -0
  154. package/dist/cjs/util/type-utils.d.ts +6 -4
  155. package/dist/esm/dialect/database-introspector.d.ts +4 -2
  156. package/dist/esm/dialect/mysql/mysql-adapter.js +2 -2
  157. package/dist/esm/dialect/mysql/mysql-driver.d.ts +1 -1
  158. package/dist/esm/dialect/mysql/mysql-driver.js +1 -1
  159. package/dist/esm/dialect/mysql/mysql-introspector.d.ts +1 -1
  160. package/dist/esm/dialect/mysql/mysql-introspector.js +19 -13
  161. package/dist/esm/dialect/postgres/postgres-adapter.js +1 -1
  162. package/dist/esm/dialect/postgres/postgres-introspector.d.ts +1 -1
  163. package/dist/esm/dialect/postgres/postgres-introspector.js +3 -1
  164. package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +1 -0
  165. package/dist/esm/dialect/sqlite/sqlite-dialect.js +1 -0
  166. package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +1 -1
  167. package/dist/esm/dialect/sqlite/sqlite-introspector.js +6 -5
  168. package/dist/esm/driver/runtime-driver.js +4 -2
  169. package/dist/esm/expression/expression-builder.d.ts +386 -0
  170. package/dist/esm/expression/expression-builder.js +88 -0
  171. package/dist/esm/expression/expression-wrapper.d.ts +92 -0
  172. package/dist/esm/expression/expression-wrapper.js +50 -0
  173. package/dist/esm/expression/expression.d.ts +1 -1
  174. package/dist/esm/helpers/postgres.d.ts +133 -0
  175. package/dist/esm/helpers/postgres.js +136 -0
  176. package/dist/esm/index.d.ts +4 -3
  177. package/dist/esm/index.js +2 -1
  178. package/dist/esm/kysely.d.ts +10 -0
  179. package/dist/esm/kysely.js +13 -2
  180. package/dist/esm/migration/file-migration-provider.d.ts +5 -2
  181. package/dist/esm/migration/migrator.d.ts +5 -2
  182. package/dist/esm/operation-node/aggregate-function-node.d.ts +3 -2
  183. package/dist/esm/operation-node/aggregate-function-node.js +2 -2
  184. package/dist/esm/operation-node/create-index-node.d.ts +2 -0
  185. package/dist/esm/operation-node/delete-query-node.d.ts +1 -2
  186. package/dist/esm/operation-node/delete-query-node.js +2 -8
  187. package/dist/esm/operation-node/function-node.d.ts +13 -0
  188. package/dist/esm/operation-node/function-node.js +17 -0
  189. package/dist/esm/operation-node/operation-node-transformer.d.ts +2 -0
  190. package/dist/esm/operation-node/operation-node-transformer.js +11 -2
  191. package/dist/esm/operation-node/operation-node-visitor.d.ts +2 -0
  192. package/dist/esm/operation-node/operation-node-visitor.js +1 -0
  193. package/dist/esm/operation-node/operation-node.d.ts +1 -1
  194. package/dist/esm/operation-node/operator-node.d.ts +13 -2
  195. package/dist/esm/operation-node/operator-node.js +34 -3
  196. package/dist/esm/operation-node/query-node.d.ts +25 -8
  197. package/dist/esm/operation-node/query-node.js +9 -2
  198. package/dist/esm/operation-node/select-query-node.d.ts +0 -1
  199. package/dist/esm/operation-node/select-query-node.js +0 -6
  200. package/dist/esm/operation-node/update-query-node.d.ts +0 -1
  201. package/dist/esm/operation-node/update-query-node.js +0 -6
  202. package/dist/esm/parser/binary-operation-parser.d.ts +9 -10
  203. package/dist/esm/parser/binary-operation-parser.js +85 -37
  204. package/dist/esm/parser/coalesce-parser.d.ts +0 -2
  205. package/dist/esm/parser/coalesce-parser.js +1 -7
  206. package/dist/esm/parser/expression-parser.d.ts +7 -3
  207. package/dist/esm/parser/expression-parser.js +5 -5
  208. package/dist/esm/parser/group-by-parser.d.ts +3 -2
  209. package/dist/esm/parser/group-by-parser.js +3 -0
  210. package/dist/esm/parser/insert-values-parser.d.ts +4 -1
  211. package/dist/esm/parser/insert-values-parser.js +18 -12
  212. package/dist/esm/parser/join-parser.js +2 -2
  213. package/dist/esm/parser/parse-utils.d.ts +0 -2
  214. package/dist/esm/parser/parse-utils.js +0 -6
  215. package/dist/esm/parser/returning-parser.d.ts +2 -1
  216. package/dist/esm/parser/select-parser.d.ts +5 -13
  217. package/dist/esm/parser/select-parser.js +7 -3
  218. package/dist/esm/parser/table-parser.d.ts +6 -3
  219. package/dist/esm/parser/unary-operation-parser.d.ts +5 -2
  220. package/dist/esm/parser/unary-operation-parser.js +8 -8
  221. package/dist/esm/parser/update-set-parser.d.ts +4 -1
  222. package/dist/esm/parser/update-set-parser.js +7 -2
  223. package/dist/esm/parser/value-parser.d.ts +5 -0
  224. package/dist/esm/parser/value-parser.js +1 -3
  225. package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +7 -0
  226. package/dist/esm/plugin/camel-case/camel-case-plugin.js +10 -4
  227. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +1 -1
  228. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
  229. package/dist/esm/query-builder/aggregate-function-builder.d.ts +40 -113
  230. package/dist/esm/query-builder/aggregate-function-builder.js +24 -64
  231. package/dist/esm/query-builder/delete-query-builder.d.ts +224 -205
  232. package/dist/esm/query-builder/delete-query-builder.js +24 -30
  233. package/dist/esm/query-builder/delete-result.js +3 -0
  234. package/dist/esm/query-builder/deprecated-having-expression-builder.d.ts +62 -0
  235. package/dist/esm/query-builder/deprecated-having-expression-builder.js +2 -0
  236. package/dist/esm/query-builder/deprecated-on-expression-builder.d.ts +62 -0
  237. package/dist/esm/query-builder/deprecated-on-expression-builder.js +2 -0
  238. package/dist/esm/query-builder/deprecated-where-expression-builder.d.ts +62 -0
  239. package/dist/esm/query-builder/deprecated-where-expression-builder.js +2 -0
  240. package/dist/esm/query-builder/function-module.d.ts +304 -42
  241. package/dist/esm/query-builder/function-module.js +43 -207
  242. package/dist/esm/query-builder/having-interface.d.ts +19 -16
  243. package/dist/esm/query-builder/insert-query-builder.d.ts +78 -30
  244. package/dist/esm/query-builder/insert-query-builder.js +25 -34
  245. package/dist/esm/query-builder/insert-result.js +3 -0
  246. package/dist/esm/query-builder/join-builder.d.ts +23 -26
  247. package/dist/esm/query-builder/join-builder.js +18 -23
  248. package/dist/esm/query-builder/no-result-error.d.ts +1 -0
  249. package/dist/esm/query-builder/no-result-error.js +3 -0
  250. package/dist/esm/query-builder/on-conflict-builder.d.ts +158 -276
  251. package/dist/esm/query-builder/on-conflict-builder.js +54 -38
  252. package/dist/esm/query-builder/over-builder.d.ts +5 -0
  253. package/dist/esm/query-builder/over-builder.js +7 -0
  254. package/dist/esm/query-builder/returning-interface.d.ts +2 -2
  255. package/dist/esm/query-builder/select-query-builder.d.ts +155 -243
  256. package/dist/esm/query-builder/select-query-builder.js +337 -82
  257. package/dist/esm/query-builder/update-query-builder.d.ts +149 -217
  258. package/dist/esm/query-builder/update-query-builder.js +25 -119
  259. package/dist/esm/query-builder/update-result.js +3 -0
  260. package/dist/esm/query-builder/where-interface.d.ts +71 -184
  261. package/dist/esm/query-compiler/default-query-compiler.d.ts +3 -0
  262. package/dist/esm/query-compiler/default-query-compiler.js +18 -2
  263. package/dist/esm/query-creator.d.ts +38 -2
  264. package/dist/esm/query-creator.js +3 -45
  265. package/dist/esm/query-executor/query-executor.d.ts +3 -3
  266. package/dist/esm/raw-builder/raw-builder.d.ts +5 -3
  267. package/dist/esm/raw-builder/raw-builder.js +13 -7
  268. package/dist/esm/raw-builder/sql.d.ts +17 -9
  269. package/dist/esm/raw-builder/sql.js +8 -2
  270. package/dist/esm/schema/alter-column-builder.d.ts +5 -0
  271. package/dist/esm/schema/alter-column-builder.js +7 -0
  272. package/dist/esm/schema/alter-table-add-foreign-key-constraint-builder.d.ts +5 -0
  273. package/dist/esm/schema/alter-table-add-foreign-key-constraint-builder.js +7 -0
  274. package/dist/esm/schema/alter-table-drop-constraint-builder.d.ts +5 -0
  275. package/dist/esm/schema/alter-table-drop-constraint-builder.js +7 -0
  276. package/dist/esm/schema/column-definition-builder.d.ts +6 -1
  277. package/dist/esm/schema/column-definition-builder.js +8 -1
  278. package/dist/esm/schema/create-index-builder.d.ts +51 -9
  279. package/dist/esm/schema/create-index-builder.js +17 -0
  280. package/dist/esm/schema/create-schema-builder.d.ts +5 -0
  281. package/dist/esm/schema/create-schema-builder.js +7 -0
  282. package/dist/esm/schema/create-table-builder.d.ts +3 -1
  283. package/dist/esm/schema/create-table-builder.js +3 -1
  284. package/dist/esm/schema/create-type-builder.d.ts +5 -0
  285. package/dist/esm/schema/create-type-builder.js +7 -0
  286. package/dist/esm/schema/create-view-builder.d.ts +5 -0
  287. package/dist/esm/schema/create-view-builder.js +7 -0
  288. package/dist/esm/schema/drop-index-builder.d.ts +5 -0
  289. package/dist/esm/schema/drop-index-builder.js +7 -0
  290. package/dist/esm/schema/drop-schema-builder.d.ts +5 -0
  291. package/dist/esm/schema/drop-schema-builder.js +7 -0
  292. package/dist/esm/schema/drop-table-builder.d.ts +5 -0
  293. package/dist/esm/schema/drop-table-builder.js +7 -0
  294. package/dist/esm/schema/drop-type-builder.d.ts +5 -0
  295. package/dist/esm/schema/drop-type-builder.js +7 -0
  296. package/dist/esm/schema/drop-view-builder.d.ts +5 -0
  297. package/dist/esm/schema/drop-view-builder.js +7 -0
  298. package/dist/esm/schema/foreign-key-constraint-builder.d.ts +5 -0
  299. package/dist/esm/schema/foreign-key-constraint-builder.js +7 -0
  300. package/dist/esm/util/compilable.d.ts +1 -0
  301. package/dist/esm/util/compilable.js +4 -1
  302. package/dist/esm/util/explainable.d.ts +35 -0
  303. package/dist/esm/util/log.d.ts +2 -0
  304. package/dist/esm/util/object-utils.js +1 -1
  305. package/dist/esm/util/streamable.d.ts +29 -0
  306. package/dist/esm/util/streamable.js +2 -0
  307. package/dist/esm/util/type-utils.d.ts +6 -4
  308. package/helpers/postgres.d.ts +1 -0
  309. package/helpers/postgres.js +1 -0
  310. package/package.json +20 -9
  311. package/dist/cjs/query-builder/expression-builder.d.ts +0 -126
  312. package/dist/cjs/query-builder/expression-builder.js +0 -107
  313. package/dist/esm/query-builder/expression-builder.d.ts +0 -126
  314. package/dist/esm/query-builder/expression-builder.js +0 -104
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Discord](https://img.shields.io/discord/890118421587578920)](https://discord.gg/xyBJ3GwvAm)
4
4
  [![Tests](https://github.com/koskimas/kysely/actions/workflows/test.yml/badge.svg)](https://github.com/koskimas/kysely)
5
5
 
6
- # [Kysely](https://koskimas.github.io/kysely/index.html)
6
+ # [Kysely](https://kysely-org.github.io/kysely/index.html)
7
7
 
8
8
  Kysely (pronounce “Key-Seh-Lee”) is a type-safe and autocompletion-friendly typescript SQL query builder. Inspired by
9
9
  [knex](http://knexjs.org/). Mainly developed for [node.js](https://nodejs.org/en/) but also runs on [deno](https://deno.land/)
@@ -21,8 +21,8 @@ column names, aliases and types from selected subqueries, joined subqueries, `wi
21
21
  much anything you can think of.
22
22
 
23
23
  Of course there are cases where things cannot be typed at compile time, and Kysely offers escape
24
- hatches for these situations. See the [sql template tag](https://koskimas.github.io/kysely/interfaces/Sql.html)
25
- and the [DynamicModule](https://koskimas.github.io/kysely/classes/DynamicModule.html#ref) for more info.
24
+ hatches for these situations. See the [sql template tag](https://kysely-org.github.io/kysely/interfaces/Sql.html)
25
+ and the [DynamicModule](https://kysely-org.github.io/kysely/classes/DynamicModule.html#ref) for more info.
26
26
 
27
27
  All API documentation is written in the typing files and you can simply `cmd-click` on the module, class
28
28
  or method you're using to see it. The same documentation is also hosted [here](https://github.com/koskimas/kysely).
@@ -69,7 +69,7 @@ npm install kysely better-sqlite3
69
69
  ```
70
70
 
71
71
  More dialects will be added soon. Kysely also has a simple interface
72
- for [3rd party dialects](https://koskimas.github.io/kysely/interfaces/Dialect.html).
72
+ for [3rd party dialects](https://kysely-org.github.io/kysely/interfaces/Dialect.html).
73
73
 
74
74
  ### 3rd party dialects
75
75
 
@@ -78,6 +78,9 @@ for [3rd party dialects](https://koskimas.github.io/kysely/interfaces/Dialect.ht
78
78
  - [SingleStore Data API](https://github.com/igalklebanov/kysely-singlestore)
79
79
  - [D1](https://github.com/aidenwallis/kysely-d1)
80
80
  - [SurrealDB](https://github.com/igalklebanov/kysely-surrealdb)
81
+ - [sqld](https://github.com/libsql/kysely-libsql)
82
+ - [Neon](https://github.com/seveibar/kysely-neon)
83
+ - [AWS S3 Select](https://github.com/igalklebanov/kysely-s3-select)
81
84
 
82
85
  # Minimal example
83
86
 
@@ -183,20 +186,33 @@ type UpdateablePerson = Updateable<PersonTable>
183
186
 
184
187
  # Playground
185
188
 
186
- [@wirekang](https://github.com/wirekang) has created a [playground for Kysely](https://wirekang.github.io/kysely-playground/#eyJkaWFsZWN0IjoibXlzcWwiLCJ0cyI6ImludGVyZmFjZSBEQiB7XG4gIHVzZXI6IFVzZXJUYWJsZVxufVxuXG5pbnRlcmZhY2UgVXNlclRhYmxlIHtcbiAgaWQ6IEdlbmVyYXRlZDxzdHJpbmc+XG4gIGZpcnN0X25hbWU6IHN0cmluZyB8IG51bGxcbiAgbGFzdF9uYW1lOiBzdHJpbmcgfCBudWxsXG4gIGNyZWF0ZWRfYXQ6IEdlbmVyYXRlZDxEYXRlPlxufVxuXG5yZXN1bHQgPSBreXNlbHlcbiAgLnNlbGVjdEZyb20oXCJ1c2VyXCIpXG4gIC5zZWxlY3RBbGwoKVxuICAub3JkZXJCeShcImNyZWF0ZWRfYXRcIikifQ==). You can use to quickly test stuff out and for creating code examples for your issues, PRs and discord messages.
189
+ [@wirekang](https://github.com/wirekang) has created a [playground for Kysely](https://wirekang.github.io/kysely-playground/?p=f&i=-NLp3n_P5fyeQKMQda8n). You can use to quickly test stuff out and for creating code examples for your issues, PRs and discord messages.
187
190
 
188
191
  # Generating types
189
192
 
190
- If you want to generate the table types automatically from the database schema please
191
- check out [this awesome project](https://github.com/RobinBlomberg/kysely-codegen).
193
+ To work with Kysely, you're required to provide a database schema type definition to the Kysely constructor.
194
+
195
+ In many cases, defining your database schema definitions manually is good enough.
196
+
197
+ However, when building production applications, its best to stay aligned with the
198
+ database schema, by automatically generating the database schema type definitions.
199
+
200
+ There are several ways to do this using 3rd party libraries:
201
+
202
+ - [kysely-codegen](https://github.com/RobinBlomberg/kysely-codegen) - This library
203
+ generates Kysely database schema type definitions by connecting to and introspecting
204
+ your database. This library works with all built-in dialects.
205
+
206
+ - [prisma-kysely](https://github.com/valtyr/prisma-kysely) - This library generates
207
+ Kysely database schema type definitions from your existing Prisma schemas.
192
208
 
193
209
  # Query examples
194
210
 
195
211
  ## Select queries
196
212
 
197
213
  You can find examples of select queries in the documentation of the
198
- [select method](https://koskimas.github.io/kysely/classes/SelectQueryBuilder.html#select) and
199
- the [where method](https://koskimas.github.io/kysely/classes/SelectQueryBuilder.html#where)
214
+ [select method](https://kysely-org.github.io/kysely/classes/SelectQueryBuilder.html#select) and
215
+ the [where method](https://kysely-org.github.io/kysely/classes/SelectQueryBuilder.html#where)
200
216
  among other places.
201
217
 
202
218
  ### Stream select query results
@@ -240,32 +256,36 @@ async function demo() {
240
256
 
241
257
  ## Update queries
242
258
 
243
- See the [set method](https://koskimas.github.io/kysely/classes/UpdateQueryBuilder.html#set) and the
244
- [updateTable method](https://koskimas.github.io/kysely/classes/Kysely.html#updateTable)
259
+ See the [set method](https://kysely-org.github.io/kysely/classes/UpdateQueryBuilder.html#set) and the
260
+ [updateTable method](https://kysely-org.github.io/kysely/classes/Kysely.html#updateTable)
245
261
  documentation.
246
262
 
247
263
  ## Insert queries
248
264
 
249
- See the [values method](https://koskimas.github.io/kysely/classes/InsertQueryBuilder.html#values) and the
250
- [insertInto method](https://koskimas.github.io/kysely/classes/Kysely.html#insertInto)
265
+ See the [values method](https://kysely-org.github.io/kysely/classes/InsertQueryBuilder.html#values) and the
266
+ [insertInto method](https://kysely-org.github.io/kysely/classes/Kysely.html#insertInto)
251
267
  documentation.
252
268
 
253
269
  ## Delete queries
254
270
 
255
- See the [deleteFrom method](https://koskimas.github.io/kysely/classes/Kysely.html#deleteFrom)
271
+ See the [deleteFrom method](https://kysely-org.github.io/kysely/classes/Kysely.html#deleteFrom)
256
272
  documentation.
257
273
 
258
274
  # Recipes
259
275
 
260
- The [recipes](https://github.com/koskimas/kysely/tree/master/recipes) folder contains a bunch of small tutorials
276
+ The [recipes](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/) folder contains a bunch of small tutorials
261
277
  or "recipes" for common use cases.
262
278
 
263
- * [Conditional selects](https://github.com/koskimas/kysely/tree/master/recipes/conditional-selects.md)
264
- * [Deduplicate joins](https://github.com/koskimas/kysely/tree/master/recipes/deduplicate-joins.md)
265
- * [Extending kysely](https://github.com/koskimas/kysely/tree/master/recipes/extending-kysely.md)
266
- * [Raw SQL](https://github.com/koskimas/kysely/tree/master/recipes/raw-sql.md)
267
- * [Schemas](https://github.com/koskimas/kysely/tree/master/recipes/schemas.md)
268
- * [Dealing with the `Type instantiation is excessively deep and possibly infinite` error](https://github.com/koskimas/kysely/tree/master/recipes/excessively-deep-types.md)
279
+ * [Expressions](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/expressions.md)
280
+ * [Conditional selects](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/conditional-selects.md)
281
+ * [Dealing with the `Type instantiation is excessively deep and possibly infinite` error](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/excessively-deep-types.md)
282
+ * [Deduplicate joins](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/deduplicate-joins.md)
283
+ * [Extending kysely](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/extending-kysely.md)
284
+ * [Introspecting relation metadata](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/introspecting-relation-metadata.md)
285
+ * [Raw SQL](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/raw-sql.md)
286
+ * [Relations](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/relations.md)
287
+ * [Schemas](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/schemas.md)
288
+ * [Splitting build, compile and execute code](https://github.com/koskimas/kysely/tree/master/site/docs/recipes/splitting-build-compile-and-execute-code.md)
269
289
 
270
290
  # Migrations
271
291
 
@@ -290,7 +310,7 @@ when you go back to previous version. The only argument for the functions is an
290
310
  Migrations should never depend on the current code of your app because they need to work even when the app
291
311
  changes. Migrations need to be "frozen in time".
292
312
 
293
- The migrations can use the [Kysely.schema](https://koskimas.github.io/kysely/classes/SchemaModule.html)
313
+ The migrations can use the [Kysely.schema](https://kysely-org.github.io/kysely/classes/SchemaModule.html)
294
314
  module to modify the schema. Migrations can also run normal queries to modify data.
295
315
 
296
316
  Execution order of the migrations is the alpabetical order of their names. An excellent way to name your
@@ -299,8 +319,8 @@ where multiple team members may add migrations at the same time in parallel comm
299
319
  about the other migrations.
300
320
 
301
321
  You don't need to store your migrations as separate files if you don't want to. You can easily
302
- implement your own [MigrationProvider](https://koskimas.github.io/kysely/interfaces/MigrationProvider.html)
303
- and give it to the [Migrator](https://koskimas.github.io/kysely/classes/Migrator.html) class
322
+ implement your own [MigrationProvider](https://kysely-org.github.io/kysely/interfaces/MigrationProvider.html)
323
+ and give it to the [Migrator](https://kysely-org.github.io/kysely/classes/Migrator.html) class
304
324
  when you instantiate one.
305
325
 
306
326
  ### PostgreSQL migration example
@@ -388,7 +408,7 @@ await migrator.migrateToLatest(pathToMigrationsFolder)
388
408
  ```
389
409
 
390
410
  to run all migrations that have not yet been run. See the
391
- [Migrator](https://koskimas.github.io/kysely/classes/Migrator.html)
411
+ [Migrator](https://kysely-org.github.io/kysely/classes/Migrator.html)
392
412
  class's documentation for more info.
393
413
 
394
414
  Kysely doesn't have a CLI for running migrations and probably never will. This is because Kysely's
@@ -570,3 +590,7 @@ a library for typescript from the ground up produces much better and simpler typ
570
590
  # How to contribute to Kysely
571
591
 
572
592
  See [CONTRIBUTING.md](./CONTRIBUTING.md).
593
+
594
+ # Sponsors
595
+
596
+ <a href="https://vercel.com/?utm_source=kysely&utm_campaign=oss"><img src="https://kysely.dev/img/powered-by-vercel.svg" alt="Powered by Vercel" /></a>
@@ -7,7 +7,7 @@ export interface DatabaseIntrospector {
7
7
  */
8
8
  getSchemas(): Promise<SchemaMetadata[]>;
9
9
  /**
10
- * Get table metadata.
10
+ * Get tables and views metadata.
11
11
  */
12
12
  getTables(options?: DatabaseMetadataOptions): Promise<TableMetadata[]>;
13
13
  /**
@@ -29,12 +29,14 @@ export interface SchemaMetadata {
29
29
  }
30
30
  export interface DatabaseMetadata {
31
31
  /**
32
- * The tables found in the database.
32
+ * The tables and views found in the database.
33
+ * * The propery isView can be used to tell them apart.
33
34
  */
34
35
  readonly tables: TableMetadata[];
35
36
  }
36
37
  export interface TableMetadata {
37
38
  readonly name: string;
39
+ readonly isView: boolean;
38
40
  readonly columns: ColumnMetadata[];
39
41
  readonly schema?: string;
40
42
  }
@@ -19,10 +19,10 @@ class MysqlAdapter extends dialect_adapter_base_js_1.DialectAdapterBase {
19
19
  // is released using `release_lock`. This way we know that the lock is either
20
20
  // released by us after successfull or failed migrations OR it's released by
21
21
  // MySQL if the process gets killed for some reason.
22
- await (0, sql_js_1.sql) `select get_lock(${sql_js_1.sql.literal(LOCK_ID)}, ${sql_js_1.sql.literal(LOCK_TIMEOUT_SECONDS)})`.execute(db);
22
+ await (0, sql_js_1.sql) `select get_lock(${sql_js_1.sql.lit(LOCK_ID)}, ${sql_js_1.sql.lit(LOCK_TIMEOUT_SECONDS)})`.execute(db);
23
23
  }
24
24
  async releaseMigrationLock(db) {
25
- await (0, sql_js_1.sql) `select release_lock(${sql_js_1.sql.literal(LOCK_ID)})`.execute(db);
25
+ await (0, sql_js_1.sql) `select release_lock(${sql_js_1.sql.lit(LOCK_ID)})`.execute(db);
26
26
  }
27
27
  }
28
28
  exports.MysqlAdapter = MysqlAdapter;
@@ -42,7 +42,7 @@ declare class MysqlConnection implements DatabaseConnection {
42
42
  #private;
43
43
  constructor(rawConnection: MysqlPoolConnection);
44
44
  executeQuery<O>(compiledQuery: CompiledQuery): Promise<QueryResult<O>>;
45
- streamQuery<O>(compiledQuery: CompiledQuery, chunkSize: number): AsyncIterableIterator<QueryResult<O>>;
45
+ streamQuery<O>(compiledQuery: CompiledQuery, _chunkSize: number): AsyncIterableIterator<QueryResult<O>>;
46
46
  [PRIVATE_RELEASE_METHOD](): void;
47
47
  }
48
48
  export {};
@@ -127,7 +127,7 @@ class MysqlConnection {
127
127
  });
128
128
  });
129
129
  }
130
- async *streamQuery(compiledQuery, chunkSize) {
130
+ async *streamQuery(compiledQuery, _chunkSize) {
131
131
  const stream = this.#rawConnection
132
132
  .query(compiledQuery.sql, compiledQuery.parameters)
133
133
  .stream({
@@ -8,7 +8,7 @@ export declare class MysqlIntrospector implements DatabaseIntrospector {
8
8
  */
9
9
  getSchemas(): Promise<SchemaMetadata[]>;
10
10
  /**
11
- * Get table metadata.
11
+ * Get tables and views metadata.
12
12
  */
13
13
  getTables(options?: DatabaseMetadataOptions): Promise<TableMetadata[]>;
14
14
  /**
@@ -19,24 +19,29 @@ class MysqlIntrospector {
19
19
  }
20
20
  async getTables(options = { withInternalKyselyTables: false }) {
21
21
  let query = this.#db
22
- .selectFrom('information_schema.columns')
22
+ .selectFrom('information_schema.columns as columns')
23
+ .innerJoin('information_schema.tables as tables', (b) => b
24
+ .onRef('columns.TABLE_CATALOG', '=', 'tables.TABLE_CATALOG')
25
+ .onRef('columns.TABLE_SCHEMA', '=', 'tables.TABLE_SCHEMA')
26
+ .onRef('columns.TABLE_NAME', '=', 'tables.TABLE_NAME'))
23
27
  .select([
24
- 'COLUMN_NAME',
25
- 'COLUMN_DEFAULT',
26
- 'TABLE_NAME',
27
- 'TABLE_SCHEMA',
28
- 'IS_NULLABLE',
29
- 'DATA_TYPE',
30
- 'EXTRA',
28
+ 'columns.COLUMN_NAME',
29
+ 'columns.COLUMN_DEFAULT',
30
+ 'columns.TABLE_NAME',
31
+ 'columns.TABLE_SCHEMA',
32
+ 'tables.TABLE_TYPE',
33
+ 'columns.IS_NULLABLE',
34
+ 'columns.DATA_TYPE',
35
+ 'columns.EXTRA',
31
36
  ])
32
- .where('table_schema', '=', (0, sql_js_1.sql) `database()`)
33
- .orderBy('table_name')
34
- .orderBy('ordinal_position')
37
+ .where('columns.TABLE_SCHEMA', '=', (0, sql_js_1.sql) `database()`)
38
+ .orderBy('columns.TABLE_NAME')
39
+ .orderBy('columns.ORDINAL_POSITION')
35
40
  .$castTo();
36
41
  if (!options.withInternalKyselyTables) {
37
42
  query = query
38
- .where('table_name', '!=', migrator_js_1.DEFAULT_MIGRATION_TABLE)
39
- .where('table_name', '!=', migrator_js_1.DEFAULT_MIGRATION_LOCK_TABLE);
43
+ .where('columns.TABLE_NAME', '!=', migrator_js_1.DEFAULT_MIGRATION_TABLE)
44
+ .where('columns.TABLE_NAME', '!=', migrator_js_1.DEFAULT_MIGRATION_LOCK_TABLE);
40
45
  }
41
46
  const rawColumns = await query.execute();
42
47
  return this.#parseTableMetadata(rawColumns);
@@ -52,6 +57,7 @@ class MysqlIntrospector {
52
57
  if (!table) {
53
58
  table = (0, object_utils_js_1.freeze)({
54
59
  name: it.TABLE_NAME,
60
+ isView: it.TABLE_TYPE === 'VIEW',
55
61
  schema: it.TABLE_SCHEMA,
56
62
  columns: [],
57
63
  });
@@ -14,7 +14,7 @@ class PostgresAdapter extends dialect_adapter_base_js_1.DialectAdapterBase {
14
14
  }
15
15
  async acquireMigrationLock(db) {
16
16
  // Acquire a transaction level advisory lock.
17
- await (0, sql_js_1.sql) `select pg_advisory_xact_lock(${sql_js_1.sql.literal(LOCK_ID)})`.execute(db);
17
+ await (0, sql_js_1.sql) `select pg_advisory_xact_lock(${sql_js_1.sql.lit(LOCK_ID)})`.execute(db);
18
18
  }
19
19
  async releaseMigrationLock() {
20
20
  // Nothing to do here. `pg_advisory_xact_lock` is automatically released at the
@@ -8,7 +8,7 @@ export declare class PostgresIntrospector implements DatabaseIntrospector {
8
8
  */
9
9
  getSchemas(): Promise<SchemaMetadata[]>;
10
10
  /**
11
- * Get table metadata.
11
+ * Get tables and views metadata.
12
12
  */
13
13
  getTables(options?: DatabaseMetadataOptions): Promise<TableMetadata[]>;
14
14
  /**
@@ -34,6 +34,7 @@ class PostgresIntrospector {
34
34
  'a.attnotnull as not_null',
35
35
  'a.atthasdef as has_default',
36
36
  'c.relname as table',
37
+ 'c.relkind as table_type',
37
38
  'ns.nspname as schema',
38
39
  'typ.typname as type',
39
40
  'dtns.nspname as type_schema',
@@ -49,7 +50,7 @@ class PostgresIntrospector {
49
50
  .as('auto_incrementing'),
50
51
  ])
51
52
  // r == normal table
52
- .where('c.relkind', '=', 'r')
53
+ .where('c.relkind', 'in', ['r', 'v'])
53
54
  .where('ns.nspname', '!~', '^pg_')
54
55
  .where('ns.nspname', '!=', 'information_schema')
55
56
  // No system columns
@@ -78,6 +79,7 @@ class PostgresIntrospector {
78
79
  if (!table) {
79
80
  table = (0, object_utils_js_1.freeze)({
80
81
  name: it.table,
82
+ isView: it.table_type === 'v',
81
83
  schema: it.schema,
82
84
  columns: [],
83
85
  });
@@ -27,6 +27,7 @@ import { SqliteDialectConfig } from './sqlite-dialect-config.js';
27
27
  * new SqliteDialect({
28
28
  * database: async () => new Database('db.sqlite')
29
29
  * })
30
+ * ```
30
31
  */
31
32
  export declare class SqliteDialect implements Dialect {
32
33
  #private;
@@ -28,6 +28,7 @@ const object_utils_js_1 = require("../../util/object-utils.js");
28
28
  * new SqliteDialect({
29
29
  * database: async () => new Database('db.sqlite')
30
30
  * })
31
+ * ```
31
32
  */
32
33
  class SqliteDialect {
33
34
  #config;
@@ -8,7 +8,7 @@ export declare class SqliteIntrospector implements DatabaseIntrospector {
8
8
  */
9
9
  getSchemas(): Promise<SchemaMetadata[]>;
10
10
  /**
11
- * Get table metadata.
11
+ * Get tables and views metadata.
12
12
  */
13
13
  getTables(options?: DatabaseMetadataOptions): Promise<TableMetadata[]>;
14
14
  /**
@@ -15,7 +15,7 @@ class SqliteIntrospector {
15
15
  async getTables(options = { withInternalKyselyTables: false }) {
16
16
  let query = this.#db
17
17
  .selectFrom('sqlite_schema')
18
- .where('type', '=', 'table')
18
+ .where('type', 'in', ['table', 'view'])
19
19
  .where('name', 'not like', 'sqlite_%')
20
20
  .select('name')
21
21
  .orderBy('name')
@@ -36,14 +36,14 @@ class SqliteIntrospector {
36
36
  async #getTableMetadata(table) {
37
37
  const db = this.#db;
38
38
  // Get the SQL that was used to create the table.
39
- const createSql = await db
39
+ const tableDefinition = await db
40
40
  .selectFrom('sqlite_master')
41
41
  .where('name', '=', table)
42
- .select('sql')
42
+ .select(['sql', 'type'])
43
43
  .$castTo()
44
- .execute();
44
+ .executeTakeFirstOrThrow();
45
45
  // Try to find the name of the column that has `autoincrement` 🤦
46
- const autoIncrementCol = createSql[0]?.sql
46
+ const autoIncrementCol = tableDefinition.sql
47
47
  ?.split(/[\(\),]/)
48
48
  ?.find((it) => it.toLowerCase().includes('autoincrement'))
49
49
  ?.trimStart()
@@ -56,6 +56,7 @@ class SqliteIntrospector {
56
56
  .execute();
57
57
  return {
58
58
  name: table,
59
+ isView: tableDefinition.type === 'view',
59
60
  columns: columns.map((col) => ({
60
61
  name: col.name,
61
62
  dataType: col.type,
@@ -76,7 +76,7 @@ class RuntimeDriver {
76
76
  return await executeQuery.call(connection, compiledQuery);
77
77
  }
78
78
  catch (error) {
79
- this.#logError(error);
79
+ this.#logError(error, compiledQuery, startTime);
80
80
  throw error;
81
81
  }
82
82
  finally {
@@ -84,10 +84,12 @@ class RuntimeDriver {
84
84
  }
85
85
  };
86
86
  }
87
- #logError(error) {
87
+ #logError(error, compiledQuery, startTime) {
88
88
  this.#log.error(() => ({
89
89
  level: 'error',
90
90
  error,
91
+ query: compiledQuery,
92
+ queryDurationMillis: this.#calculateDurationMillis(startTime),
91
93
  }));
92
94
  }
93
95
  #logQuery(compiledQuery, startTime) {