kysely 0.11.4 → 0.13.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 (262) hide show
  1. package/README.md +35 -11
  2. package/dist/cjs/dialect/dialect-adapter-base.d.ts +36 -0
  3. package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +38 -2
  4. package/dist/cjs/dialect/mysql/mysql-adapter.js +2 -1
  5. package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +16 -0
  6. package/dist/cjs/dialect/mysql/mysql-driver.d.ts +29 -0
  7. package/dist/cjs/dialect/mysql/mysql-introspector.d.ts +3 -0
  8. package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +38 -2
  9. package/dist/cjs/dialect/postgres/postgres-adapter.js +2 -1
  10. package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +16 -0
  11. package/dist/cjs/dialect/postgres/postgres-driver.d.ts +29 -0
  12. package/dist/cjs/dialect/postgres/postgres-introspector.d.ts +3 -0
  13. package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +38 -2
  14. package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +16 -0
  15. package/dist/cjs/dialect/sqlite/sqlite-driver.d.ts +29 -0
  16. package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +3 -0
  17. package/dist/cjs/driver/default-connection-provider.d.ts +4 -0
  18. package/dist/cjs/driver/runtime-driver.d.ts +29 -0
  19. package/dist/cjs/driver/single-connection-provider.d.ts +4 -0
  20. package/dist/cjs/dynamic/dynamic-reference-builder.d.ts +1 -0
  21. package/dist/cjs/dynamic/dynamic-reference-builder.js +9 -1
  22. package/dist/cjs/dynamic/dynamic.d.ts +6 -7
  23. package/dist/cjs/dynamic/dynamic.js +6 -7
  24. package/dist/cjs/index.d.ts +15 -4
  25. package/dist/cjs/index.js +12 -1
  26. package/dist/cjs/kysely.d.ts +170 -11
  27. package/dist/cjs/kysely.js +69 -9
  28. package/dist/cjs/migration/migration.d.ts +156 -13
  29. package/dist/cjs/migration/migration.js +256 -135
  30. package/dist/cjs/operation-node/column-definition-node.d.ts +6 -5
  31. package/dist/cjs/operation-node/column-definition-node.js +0 -4
  32. package/dist/cjs/operation-node/common-table-expression-name-node.d.ts +15 -0
  33. package/dist/cjs/operation-node/common-table-expression-name-node.js +23 -0
  34. package/dist/cjs/operation-node/common-table-expression-node.d.ts +3 -3
  35. package/dist/cjs/operation-node/create-table-node.d.ts +6 -2
  36. package/dist/cjs/operation-node/create-table-node.js +6 -6
  37. package/dist/cjs/operation-node/create-view-node.d.ts +1 -0
  38. package/dist/cjs/operation-node/insert-query-node.d.ts +4 -4
  39. package/dist/cjs/operation-node/operation-node-transformer.d.ts +4 -0
  40. package/dist/cjs/operation-node/operation-node-transformer.js +22 -2
  41. package/dist/cjs/operation-node/operation-node-visitor.d.ts +4 -0
  42. package/dist/cjs/operation-node/operation-node-visitor.js +2 -0
  43. package/dist/cjs/operation-node/operation-node.d.ts +1 -1
  44. package/dist/cjs/operation-node/query-node.d.ts +0 -2
  45. package/dist/cjs/operation-node/query-node.js +0 -10
  46. package/dist/cjs/operation-node/values-node.d.ts +15 -0
  47. package/dist/cjs/operation-node/values-node.js +18 -0
  48. package/dist/cjs/operation-node/with-node.d.ts +3 -1
  49. package/dist/cjs/operation-node/with-node.js +2 -1
  50. package/dist/cjs/package.json +1 -3
  51. package/dist/cjs/parser/complex-expression-parser.d.ts +9 -0
  52. package/dist/cjs/parser/complex-expression-parser.js +25 -0
  53. package/dist/cjs/parser/filter-parser.d.ts +13 -4
  54. package/dist/cjs/parser/filter-parser.js +21 -24
  55. package/dist/cjs/parser/insert-values-parser.d.ts +5 -9
  56. package/dist/cjs/parser/insert-values-parser.js +27 -41
  57. package/dist/cjs/parser/order-by-parser.d.ts +1 -1
  58. package/dist/cjs/parser/parse-context.d.ts +22 -8
  59. package/dist/cjs/parser/parse-context.js +10 -10
  60. package/dist/cjs/parser/reference-parser.d.ts +8 -7
  61. package/dist/cjs/parser/reference-parser.js +8 -17
  62. package/dist/cjs/parser/returning-parser.d.ts +1 -5
  63. package/dist/cjs/parser/select-parser.d.ts +12 -14
  64. package/dist/cjs/parser/select-parser.js +5 -9
  65. package/dist/cjs/parser/table-parser.d.ts +9 -11
  66. package/dist/cjs/parser/table-parser.js +2 -8
  67. package/dist/cjs/parser/union-parser.d.ts +2 -2
  68. package/dist/cjs/parser/union-parser.js +1 -6
  69. package/dist/cjs/parser/update-set-parser.d.ts +2 -8
  70. package/dist/cjs/parser/update-set-parser.js +6 -26
  71. package/dist/cjs/parser/value-parser.d.ts +9 -6
  72. package/dist/cjs/parser/value-parser.js +7 -30
  73. package/dist/cjs/parser/with-parser.d.ts +36 -6
  74. package/dist/cjs/parser/with-parser.js +13 -2
  75. package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +36 -2
  76. package/dist/cjs/plugin/immediate-value.ts/immediate-value-plugin.d.ts +34 -0
  77. package/dist/cjs/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
  78. package/dist/cjs/plugin/with-schema/with-schema-plugin.d.ts +34 -0
  79. package/dist/cjs/plugin/with-schema/with-schema-transformer.js +8 -0
  80. package/dist/cjs/query-builder/delete-query-builder.d.ts +647 -0
  81. package/dist/cjs/query-builder/delete-query-builder.js +185 -0
  82. package/dist/cjs/query-builder/expression-builder.d.ts +8 -6
  83. package/dist/cjs/query-builder/expression-builder.js +3 -3
  84. package/dist/cjs/query-builder/function-builder.d.ts +2 -1
  85. package/dist/cjs/query-builder/function-builder.js +2 -1
  86. package/dist/cjs/query-builder/having-interface.d.ts +49 -0
  87. package/dist/cjs/query-builder/having-interface.js +2 -0
  88. package/dist/cjs/query-builder/insert-query-builder.d.ts +504 -0
  89. package/dist/cjs/query-builder/insert-query-builder.js +256 -0
  90. package/dist/cjs/query-builder/insert-result.d.ts +3 -2
  91. package/dist/cjs/query-builder/insert-result.js +3 -2
  92. package/dist/cjs/query-builder/join-builder.d.ts +19 -20
  93. package/dist/cjs/query-builder/join-builder.js +12 -12
  94. package/dist/cjs/query-builder/join-interface.d.ts +130 -0
  95. package/dist/cjs/query-builder/join-interface.js +2 -0
  96. package/dist/cjs/query-builder/no-result-error.d.ts +9 -0
  97. package/dist/cjs/query-builder/no-result-error.js +14 -0
  98. package/dist/cjs/query-builder/returning-interface.d.ts +73 -0
  99. package/dist/cjs/query-builder/returning-interface.js +2 -0
  100. package/dist/cjs/query-builder/{query-builder.d.ts → select-query-builder.d.ts} +145 -651
  101. package/dist/cjs/query-builder/select-query-builder.js +571 -0
  102. package/dist/cjs/query-builder/update-query-builder.d.ts +735 -0
  103. package/dist/cjs/query-builder/update-query-builder.js +279 -0
  104. package/dist/cjs/query-builder/where-interface.d.ts +378 -0
  105. package/dist/cjs/query-builder/where-interface.js +2 -0
  106. package/dist/cjs/query-compiler/default-query-compiler.d.ts +4 -0
  107. package/dist/cjs/query-compiler/default-query-compiler.js +37 -6
  108. package/dist/cjs/query-creator.d.ts +69 -43
  109. package/dist/cjs/query-creator.js +66 -29
  110. package/dist/cjs/query-executor/default-query-executor.d.ts +19 -0
  111. package/dist/cjs/query-executor/noop-query-executor.d.ts +19 -0
  112. package/dist/cjs/query-executor/query-executor.d.ts +1 -1
  113. package/dist/cjs/query-executor/query-executor.js +1 -1
  114. package/dist/cjs/raw-builder/raw-builder.d.ts +2 -0
  115. package/dist/cjs/raw-builder/raw-builder.js +7 -1
  116. package/dist/cjs/schema/alter-table-builder.d.ts +230 -2
  117. package/dist/cjs/schema/alter-table-builder.js +12 -0
  118. package/dist/cjs/schema/column-definition-builder.d.ts +147 -20
  119. package/dist/cjs/schema/column-definition-builder.js +4 -1
  120. package/dist/cjs/schema/create-index-builder.d.ts +2 -1
  121. package/dist/cjs/schema/create-index-builder.js +2 -1
  122. package/dist/cjs/schema/create-table-builder.d.ts +26 -9
  123. package/dist/cjs/schema/create-table-builder.js +42 -9
  124. package/dist/cjs/schema/create-view-builder.d.ts +17 -3
  125. package/dist/cjs/schema/create-view-builder.js +25 -16
  126. package/dist/cjs/schema/schema.d.ts +18 -11
  127. package/dist/cjs/schema/schema.js +18 -11
  128. package/dist/cjs/util/log.d.ts +3 -2
  129. package/dist/cjs/util/log.js +8 -15
  130. package/dist/cjs/util/type-utils.d.ts +7 -7
  131. package/dist/esm/dialect/dialect-adapter-base.d.ts +36 -0
  132. package/dist/esm/dialect/mysql/mysql-adapter.d.ts +38 -2
  133. package/dist/esm/dialect/mysql/mysql-adapter.js +2 -1
  134. package/dist/esm/dialect/mysql/mysql-dialect.d.ts +16 -0
  135. package/dist/esm/dialect/mysql/mysql-driver.d.ts +29 -0
  136. package/dist/esm/dialect/mysql/mysql-introspector.d.ts +3 -0
  137. package/dist/esm/dialect/postgres/postgres-adapter.d.ts +38 -2
  138. package/dist/esm/dialect/postgres/postgres-adapter.js +2 -1
  139. package/dist/esm/dialect/postgres/postgres-dialect.d.ts +16 -0
  140. package/dist/esm/dialect/postgres/postgres-driver.d.ts +29 -0
  141. package/dist/esm/dialect/postgres/postgres-introspector.d.ts +3 -0
  142. package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +38 -2
  143. package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +16 -0
  144. package/dist/esm/dialect/sqlite/sqlite-driver.d.ts +29 -0
  145. package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +3 -0
  146. package/dist/esm/driver/default-connection-provider.d.ts +4 -0
  147. package/dist/esm/driver/runtime-driver.d.ts +29 -0
  148. package/dist/esm/driver/single-connection-provider.d.ts +4 -0
  149. package/dist/esm/dynamic/dynamic-reference-builder.d.ts +1 -0
  150. package/dist/esm/dynamic/dynamic-reference-builder.js +7 -0
  151. package/dist/esm/dynamic/dynamic.d.ts +6 -7
  152. package/dist/esm/dynamic/dynamic.js +6 -7
  153. package/dist/esm/index.d.ts +15 -4
  154. package/dist/esm/index.js +12 -1
  155. package/dist/esm/kysely.d.ts +170 -11
  156. package/dist/esm/kysely.js +69 -9
  157. package/dist/esm/migration/migration.d.ts +156 -13
  158. package/dist/esm/migration/migration.js +255 -134
  159. package/dist/esm/operation-node/column-definition-node.d.ts +6 -5
  160. package/dist/esm/operation-node/column-definition-node.js +0 -4
  161. package/dist/esm/operation-node/common-table-expression-name-node.d.ts +15 -0
  162. package/dist/esm/operation-node/common-table-expression-name-node.js +20 -0
  163. package/dist/esm/operation-node/common-table-expression-node.d.ts +3 -3
  164. package/dist/esm/operation-node/create-table-node.d.ts +6 -2
  165. package/dist/esm/operation-node/create-table-node.js +6 -6
  166. package/dist/esm/operation-node/create-view-node.d.ts +1 -0
  167. package/dist/esm/operation-node/insert-query-node.d.ts +4 -4
  168. package/dist/esm/operation-node/operation-node-transformer.d.ts +4 -0
  169. package/dist/esm/operation-node/operation-node-transformer.js +22 -2
  170. package/dist/esm/operation-node/operation-node-visitor.d.ts +4 -0
  171. package/dist/esm/operation-node/operation-node-visitor.js +2 -0
  172. package/dist/esm/operation-node/operation-node.d.ts +1 -1
  173. package/dist/esm/operation-node/query-node.d.ts +0 -2
  174. package/dist/esm/operation-node/query-node.js +0 -10
  175. package/dist/esm/operation-node/values-node.d.ts +15 -0
  176. package/dist/esm/operation-node/values-node.js +15 -0
  177. package/dist/esm/operation-node/with-node.d.ts +3 -1
  178. package/dist/esm/operation-node/with-node.js +2 -1
  179. package/dist/esm/package.json +1 -3
  180. package/dist/esm/parser/complex-expression-parser.d.ts +9 -0
  181. package/dist/esm/parser/complex-expression-parser.js +20 -0
  182. package/dist/esm/parser/filter-parser.d.ts +13 -4
  183. package/dist/esm/parser/filter-parser.js +21 -24
  184. package/dist/esm/parser/insert-values-parser.d.ts +5 -9
  185. package/dist/esm/parser/insert-values-parser.js +27 -40
  186. package/dist/esm/parser/order-by-parser.d.ts +1 -1
  187. package/dist/esm/parser/parse-context.d.ts +22 -8
  188. package/dist/esm/parser/parse-context.js +10 -10
  189. package/dist/esm/parser/reference-parser.d.ts +8 -7
  190. package/dist/esm/parser/reference-parser.js +9 -18
  191. package/dist/esm/parser/returning-parser.d.ts +1 -5
  192. package/dist/esm/parser/select-parser.d.ts +12 -14
  193. package/dist/esm/parser/select-parser.js +6 -10
  194. package/dist/esm/parser/table-parser.d.ts +9 -11
  195. package/dist/esm/parser/table-parser.js +3 -9
  196. package/dist/esm/parser/union-parser.d.ts +2 -2
  197. package/dist/esm/parser/union-parser.js +1 -6
  198. package/dist/esm/parser/update-set-parser.d.ts +2 -8
  199. package/dist/esm/parser/update-set-parser.js +5 -24
  200. package/dist/esm/parser/value-parser.d.ts +9 -6
  201. package/dist/esm/parser/value-parser.js +8 -31
  202. package/dist/esm/parser/with-parser.d.ts +36 -6
  203. package/dist/esm/parser/with-parser.js +13 -2
  204. package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +36 -2
  205. package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.d.ts +34 -0
  206. package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
  207. package/dist/esm/plugin/with-schema/with-schema-plugin.d.ts +34 -0
  208. package/dist/esm/plugin/with-schema/with-schema-transformer.js +8 -0
  209. package/dist/esm/query-builder/delete-query-builder.d.ts +647 -0
  210. package/dist/esm/query-builder/delete-query-builder.js +181 -0
  211. package/dist/esm/query-builder/expression-builder.d.ts +8 -6
  212. package/dist/esm/query-builder/expression-builder.js +3 -3
  213. package/dist/esm/query-builder/function-builder.d.ts +2 -1
  214. package/dist/esm/query-builder/function-builder.js +2 -1
  215. package/dist/esm/query-builder/having-interface.d.ts +49 -0
  216. package/dist/esm/query-builder/having-interface.js +1 -0
  217. package/dist/esm/query-builder/insert-query-builder.d.ts +504 -0
  218. package/dist/esm/query-builder/insert-query-builder.js +252 -0
  219. package/dist/esm/query-builder/insert-result.d.ts +3 -2
  220. package/dist/esm/query-builder/insert-result.js +3 -2
  221. package/dist/esm/query-builder/join-builder.d.ts +19 -20
  222. package/dist/esm/query-builder/join-builder.js +12 -12
  223. package/dist/esm/query-builder/join-interface.d.ts +130 -0
  224. package/dist/esm/query-builder/join-interface.js +1 -0
  225. package/dist/esm/query-builder/no-result-error.d.ts +9 -0
  226. package/dist/esm/query-builder/no-result-error.js +10 -0
  227. package/dist/esm/query-builder/returning-interface.d.ts +73 -0
  228. package/dist/esm/query-builder/returning-interface.js +1 -0
  229. package/dist/esm/query-builder/{query-builder.d.ts → select-query-builder.d.ts} +145 -651
  230. package/dist/esm/query-builder/select-query-builder.js +566 -0
  231. package/dist/esm/query-builder/update-query-builder.d.ts +735 -0
  232. package/dist/esm/query-builder/update-query-builder.js +275 -0
  233. package/dist/esm/query-builder/where-interface.d.ts +378 -0
  234. package/dist/esm/query-builder/where-interface.js +1 -0
  235. package/dist/esm/query-compiler/default-query-compiler.d.ts +4 -0
  236. package/dist/esm/query-compiler/default-query-compiler.js +37 -6
  237. package/dist/esm/query-creator.d.ts +69 -43
  238. package/dist/esm/query-creator.js +66 -29
  239. package/dist/esm/query-executor/default-query-executor.d.ts +19 -0
  240. package/dist/esm/query-executor/noop-query-executor.d.ts +19 -0
  241. package/dist/esm/query-executor/query-executor.d.ts +1 -1
  242. package/dist/esm/query-executor/query-executor.js +1 -1
  243. package/dist/esm/raw-builder/raw-builder.d.ts +2 -0
  244. package/dist/esm/raw-builder/raw-builder.js +7 -1
  245. package/dist/esm/schema/alter-table-builder.d.ts +230 -2
  246. package/dist/esm/schema/alter-table-builder.js +12 -0
  247. package/dist/esm/schema/column-definition-builder.d.ts +147 -20
  248. package/dist/esm/schema/column-definition-builder.js +4 -1
  249. package/dist/esm/schema/create-index-builder.d.ts +2 -1
  250. package/dist/esm/schema/create-index-builder.js +2 -1
  251. package/dist/esm/schema/create-table-builder.d.ts +26 -9
  252. package/dist/esm/schema/create-table-builder.js +43 -10
  253. package/dist/esm/schema/create-view-builder.d.ts +17 -3
  254. package/dist/esm/schema/create-view-builder.js +25 -16
  255. package/dist/esm/schema/schema.d.ts +18 -11
  256. package/dist/esm/schema/schema.js +18 -11
  257. package/dist/esm/util/log.d.ts +3 -2
  258. package/dist/esm/util/log.js +7 -14
  259. package/dist/esm/util/type-utils.d.ts +7 -7
  260. package/package.json +10 -8
  261. package/dist/cjs/query-builder/query-builder.js +0 -1067
  262. package/dist/esm/query-builder/query-builder.js +0 -1061
@@ -8,10 +8,29 @@ import { KyselyPlugin } from '../plugin/kysely-plugin.js';
8
8
  * other needed things to actually execute queries.
9
9
  */
10
10
  export declare class NoopQueryExecutor extends QueryExecutor {
11
+ /**
12
+ * Compiles the transformed query into SQL. You usually want to pass
13
+ * the output of {@link transformQuery} into this method but you can
14
+ * compile any query using this method.
15
+ */
11
16
  compileQuery(): CompiledQuery;
12
17
  protected executeQueryImpl<R>(): Promise<QueryResult<R>>;
18
+ /**
19
+ * Returns a copy of this executor with a new connection provider.
20
+ */
13
21
  withConnectionProvider(): QueryExecutor;
22
+ /**
23
+ * Returns a copy of this executor with a plugin added as the
24
+ * last plugin.
25
+ */
14
26
  withPlugin(plugin: KyselyPlugin): NoopQueryExecutor;
27
+ /**
28
+ * Returns a copy of this executor with a plugin added as the
29
+ * first plugin.
30
+ */
15
31
  withPluginAtFront(plugin: KyselyPlugin): NoopQueryExecutor;
32
+ /**
33
+ * Returns a copy of this executor without any plugins.
34
+ */
16
35
  withoutPlugins(): QueryExecutor;
17
36
  }
@@ -6,7 +6,7 @@ import { KyselyPlugin } from '../plugin/kysely-plugin.js';
6
6
  import { QueryId } from '../util/query-id.js';
7
7
  /**
8
8
  * This class abstracts away the details of how to compile a query into SQL
9
- * and execute it. Instead of passing around all those details, {@link QueryBuilder}
9
+ * and execute it. Instead of passing around all those details, {@link SelectQueryBuilder}
10
10
  * and other classes that execute queries can just pass around and instance of
11
11
  * `QueryExecutor`.
12
12
  */
@@ -4,7 +4,7 @@ exports.QueryExecutor = void 0;
4
4
  const object_utils_js_1 = require("../util/object-utils.js");
5
5
  /**
6
6
  * This class abstracts away the details of how to compile a query into SQL
7
- * and execute it. Instead of passing around all those details, {@link QueryBuilder}
7
+ * and execute it. Instead of passing around all those details, {@link SelectQueryBuilder}
8
8
  * and other classes that execute queries can just pass around and instance of
9
9
  * `QueryExecutor`.
10
10
  */
@@ -5,6 +5,7 @@ import { RawNode } from '../operation-node/raw-node.js';
5
5
  import { CompiledQuery } from '../query-compiler/compiled-query.js';
6
6
  import { QueryExecutor } from '../query-executor/query-executor.js';
7
7
  import { QueryId } from '../util/query-id.js';
8
+ import { KyselyPlugin } from '../plugin/kysely-plugin.js';
8
9
  export declare class RawBuilder<O = unknown> implements OperationNodeSource {
9
10
  #private;
10
11
  constructor(props: RawBuilderProps);
@@ -16,6 +17,7 @@ export declare class RawBuilder<O = unknown> implements OperationNodeSource {
16
17
  * of this `RawBuilder` with a new output type.
17
18
  */
18
19
  castTo<T>(): RawBuilder<T>;
20
+ withPlugin(plugin: KyselyPlugin): RawBuilder<O>;
19
21
  toOperationNode(): RawNode;
20
22
  compile(): CompiledQuery;
21
23
  execute(): Promise<QueryResult<O>>;
@@ -27,6 +27,12 @@ class RawBuilder {
27
27
  ...this.#props,
28
28
  });
29
29
  }
30
+ withPlugin(plugin) {
31
+ return new RawBuilder({
32
+ ...this.#props,
33
+ executor: this.#props.executor.withPlugin(plugin),
34
+ });
35
+ }
30
36
  toOperationNode() {
31
37
  const parameterPlaceholderRegex = /(\?\??)/g;
32
38
  const sql = this.#props.sql;
@@ -44,7 +50,7 @@ class RawBuilder {
44
50
  if (match.index > 0 && sql[match.index - 1] === '\\') {
45
51
  continue;
46
52
  }
47
- sqlFragments.push(sql.slice(sqlIdx, match.index).replaceAll('\\?', '?'));
53
+ sqlFragments.push(sql.slice(sqlIdx, match.index).replace(/\\\?/g, '?'));
48
54
  argNodes.push(parseRawArg(str, parameters[paramIdx]));
49
55
  sqlIdx = match.index + str.length;
50
56
  ++paramIdx;
@@ -60,19 +60,133 @@ export declare class AlterTableExecutor implements OperationNodeSource, Compilab
60
60
  }
61
61
  export interface AlterTableExecutorProps extends AlterTableBuilderProps {
62
62
  }
63
- export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuilderInterface<AlterTableAddColumnBuilder>, OperationNodeSource, Compilable {
63
+ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuilderInterface, OperationNodeSource, Compilable {
64
64
  #private;
65
65
  constructor(props: AlterTableAddColumnBuilderProps);
66
+ /**
67
+ * Adds `auto_increment` or `autoincrement` to the column definition
68
+ * depending on the dialect.
69
+ *
70
+ * Some dialects like PostgreSQL don't support this. On PostgreSQL
71
+ * you can use the `serial` or `bigserial` data type instead.
72
+ */
66
73
  autoIncrement(): AlterTableAddColumnBuilder;
74
+ /**
75
+ * Makes the column the primary key.
76
+ *
77
+ * If you want to specify a composite primary key use the
78
+ * {@link TableBuilder.addPrimaryKeyConstraint} method.
79
+ */
67
80
  primaryKey(): AlterTableAddColumnBuilder;
81
+ /**
82
+ * Adds a foreign key constraint for the column.
83
+ *
84
+ * If your database engine doesn't support foreign key constraints in the
85
+ * column definition (like MySQL 5) you need to call the table level
86
+ * {@link TableBuilder.addForeignKeyConstraint} method instead.
87
+ *
88
+ * ### Examples
89
+ *
90
+ * ```ts
91
+ * col.references('person.id')
92
+ * ```
93
+ */
68
94
  references(ref: string): AlterTableAddColumnBuilder;
95
+ /**
96
+ * Adds an `on delete` constraint for the foreign key column.
97
+ *
98
+ * If your database engine doesn't support foreign key constraints in the
99
+ * column definition (like MySQL 5) you need to call the table level
100
+ * {@link TableBuilder.addForeignKeyConstraint} method instead.
101
+ *
102
+ * ### Examples
103
+ *
104
+ * ```ts
105
+ * col.references('person.id').onDelete('cascade')
106
+ * ```
107
+ */
69
108
  onDelete(onDelete: OnModifyForeignAction): AlterTableAddColumnBuilder;
109
+ /**
110
+ * Adds an `on update` constraint for the foreign key column.
111
+ *
112
+ * ### Examples
113
+ *
114
+ * ```ts
115
+ * col.references('person.id').onUpdate('cascade')
116
+ * ```
117
+ */
70
118
  onUpdate(onDelete: OnModifyForeignAction): AlterTableAddColumnBuilder;
119
+ /**
120
+ * Adds a unique constraint for the column.
121
+ */
71
122
  unique(): AlterTableAddColumnBuilder;
123
+ /**
124
+ * Adds a `not null` constraint for the column.
125
+ */
72
126
  notNull(): AlterTableAddColumnBuilder;
127
+ /**
128
+ * Adds a `unsigned` modifier for the column.
129
+ *
130
+ * This only works on some dialects like MySQL.
131
+ */
132
+ unsigned(): AlterTableAddColumnBuilder;
133
+ /**
134
+ * Adds a default value constraint for the column.
135
+ *
136
+ * ### Examples
137
+ *
138
+ * ```ts
139
+ * db.schema
140
+ * .createTable('pet')
141
+ * .addColumn('number_of_legs', 'integer', (col) => col.defaultTo(4))
142
+ * .execute()
143
+ * ```
144
+ */
73
145
  defaultTo(value: PrimitiveValue | AnyRawBuilder): AlterTableAddColumnBuilder;
146
+ /**
147
+ * Adds a check constraint for the column.
148
+ *
149
+ * ### Examples
150
+ *
151
+ * ```ts
152
+ * db.schema
153
+ * .createTable('pet')
154
+ * .addColumn('number_of_legs', 'integer', (col) => col.check('number_of_legs < 5'))
155
+ * .execute()
156
+ * ```
157
+ */
74
158
  check(sql: string): AlterTableAddColumnBuilder;
159
+ /**
160
+ * Makes the column a generated column using a `generated always as` statement.
161
+ *
162
+ * ### Examples
163
+ *
164
+ * ```ts
165
+ * db.schema
166
+ * .createTable('person')
167
+ * .addColumn('full_name', 'varchar(255)',
168
+ * (col) => col.generatedAlwaysAs("concat(first_name, ' ', last_name)")
169
+ * )
170
+ * .execute()
171
+ * ```
172
+ */
75
173
  generatedAlwaysAs(sql: string): AlterTableAddColumnBuilder;
174
+ /**
175
+ * Makes a generated column stored instead of virtual. This method can only
176
+ * be used with {@link generatedAlwaysAs}
177
+ *
178
+ * ### Examples
179
+ *
180
+ * ```ts
181
+ * db.schema
182
+ * .createTable('person')
183
+ * .addColumn('full_name', 'varchar(255)', (col) => col
184
+ * .generatedAlwaysAs("concat(first_name, ' ', last_name)")
185
+ * .stored()
186
+ * )
187
+ * .execute()
188
+ * ```
189
+ */
76
190
  stored(): AlterTableAddColumnBuilder;
77
191
  toOperationNode(): AlterTableNode;
78
192
  compile(): CompiledQuery;
@@ -81,19 +195,133 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
81
195
  export interface AlterTableAddColumnBuilderProps extends AlterTableBuilderProps {
82
196
  readonly columnBuilder: ColumnDefinitionBuilder;
83
197
  }
84
- export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBuilderInterface<AlterTableModifyColumnBuilder>, OperationNodeSource, Compilable {
198
+ export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBuilderInterface, OperationNodeSource, Compilable {
85
199
  #private;
86
200
  constructor(props: AlterTableModifyColumnBuilderProps);
201
+ /**
202
+ * Adds `auto_increment` or `autoincrement` to the column definition
203
+ * depending on the dialect.
204
+ *
205
+ * Some dialects like PostgreSQL don't support this. On PostgreSQL
206
+ * you can use the `serial` or `bigserial` data type instead.
207
+ */
87
208
  autoIncrement(): AlterTableModifyColumnBuilder;
209
+ /**
210
+ * Makes the column the primary key.
211
+ *
212
+ * If you want to specify a composite primary key use the
213
+ * {@link TableBuilder.addPrimaryKeyConstraint} method.
214
+ */
88
215
  primaryKey(): AlterTableModifyColumnBuilder;
216
+ /**
217
+ * Adds a foreign key constraint for the column.
218
+ *
219
+ * If your database engine doesn't support foreign key constraints in the
220
+ * column definition (like MySQL 5) you need to call the table level
221
+ * {@link TableBuilder.addForeignKeyConstraint} method instead.
222
+ *
223
+ * ### Examples
224
+ *
225
+ * ```ts
226
+ * col.references('person.id')
227
+ * ```
228
+ */
89
229
  references(ref: string): AlterTableModifyColumnBuilder;
230
+ /**
231
+ * Adds an `on delete` constraint for the foreign key column.
232
+ *
233
+ * If your database engine doesn't support foreign key constraints in the
234
+ * column definition (like MySQL 5) you need to call the table level
235
+ * {@link TableBuilder.addForeignKeyConstraint} method instead.
236
+ *
237
+ * ### Examples
238
+ *
239
+ * ```ts
240
+ * col.references('person.id').onDelete('cascade')
241
+ * ```
242
+ */
90
243
  onDelete(onDelete: OnModifyForeignAction): AlterTableModifyColumnBuilder;
244
+ /**
245
+ * Adds an `on update` constraint for the foreign key column.
246
+ *
247
+ * ### Examples
248
+ *
249
+ * ```ts
250
+ * col.references('person.id').onUpdate('cascade')
251
+ * ```
252
+ */
91
253
  onUpdate(onUpdate: OnModifyForeignAction): AlterTableModifyColumnBuilder;
254
+ /**
255
+ * Adds a unique constraint for the column.
256
+ */
92
257
  unique(): AlterTableModifyColumnBuilder;
258
+ /**
259
+ * Adds a `not null` constraint for the column.
260
+ */
93
261
  notNull(): AlterTableModifyColumnBuilder;
262
+ /**
263
+ * Adds a `unsigned` modifier for the column.
264
+ *
265
+ * This only works on some dialects like MySQL.
266
+ */
267
+ unsigned(): AlterTableModifyColumnBuilder;
268
+ /**
269
+ * Adds a default value constraint for the column.
270
+ *
271
+ * ### Examples
272
+ *
273
+ * ```ts
274
+ * db.schema
275
+ * .createTable('pet')
276
+ * .addColumn('number_of_legs', 'integer', (col) => col.defaultTo(4))
277
+ * .execute()
278
+ * ```
279
+ */
94
280
  defaultTo(value: PrimitiveValue | AnyRawBuilder): AlterTableModifyColumnBuilder;
281
+ /**
282
+ * Adds a check constraint for the column.
283
+ *
284
+ * ### Examples
285
+ *
286
+ * ```ts
287
+ * db.schema
288
+ * .createTable('pet')
289
+ * .addColumn('number_of_legs', 'integer', (col) => col.check('number_of_legs < 5'))
290
+ * .execute()
291
+ * ```
292
+ */
95
293
  check(sql: string): AlterTableModifyColumnBuilder;
294
+ /**
295
+ * Makes the column a generated column using a `generated always as` statement.
296
+ *
297
+ * ### Examples
298
+ *
299
+ * ```ts
300
+ * db.schema
301
+ * .createTable('person')
302
+ * .addColumn('full_name', 'varchar(255)',
303
+ * (col) => col.generatedAlwaysAs("concat(first_name, ' ', last_name)")
304
+ * )
305
+ * .execute()
306
+ * ```
307
+ */
96
308
  generatedAlwaysAs(sql: string): AlterTableModifyColumnBuilder;
309
+ /**
310
+ * Makes a generated column stored instead of virtual. This method can only
311
+ * be used with {@link generatedAlwaysAs}
312
+ *
313
+ * ### Examples
314
+ *
315
+ * ```ts
316
+ * db.schema
317
+ * .createTable('person')
318
+ * .addColumn('full_name', 'varchar(255)', (col) => col
319
+ * .generatedAlwaysAs("concat(first_name, ' ', last_name)")
320
+ * .stored()
321
+ * )
322
+ * .execute()
323
+ * ```
324
+ */
97
325
  stored(): AlterTableModifyColumnBuilder;
98
326
  toOperationNode(): AlterTableNode;
99
327
  compile(): CompiledQuery;
@@ -232,6 +232,12 @@ class AlterTableAddColumnBuilder {
232
232
  columnBuilder: this.#props.columnBuilder.notNull(),
233
233
  });
234
234
  }
235
+ unsigned() {
236
+ return new AlterTableAddColumnBuilder({
237
+ ...this.#props,
238
+ columnBuilder: this.#props.columnBuilder.unsigned(),
239
+ });
240
+ }
235
241
  defaultTo(value) {
236
242
  return new AlterTableAddColumnBuilder({
237
243
  ...this.#props,
@@ -316,6 +322,12 @@ class AlterTableModifyColumnBuilder {
316
322
  columnBuilder: this.#props.columnBuilder.notNull(),
317
323
  });
318
324
  }
325
+ unsigned() {
326
+ return new AlterTableModifyColumnBuilder({
327
+ ...this.#props,
328
+ columnBuilder: this.#props.columnBuilder.unsigned(),
329
+ });
330
+ }
319
331
  defaultTo(value) {
320
332
  return new AlterTableModifyColumnBuilder({
321
333
  ...this.#props,
@@ -4,7 +4,7 @@ import { PrimitiveValue } from '../util/object-utils.js';
4
4
  import { ColumnDefinitionNode } from '../operation-node/column-definition-node.js';
5
5
  import { AnyRawBuilder } from '../util/type-utils.js';
6
6
  import { DefaultValueExpression } from '../parser/default-value-parser.js';
7
- export interface ColumnDefinitionBuilderInterface<R> {
7
+ export interface ColumnDefinitionBuilderInterface {
8
8
  /**
9
9
  * Adds `auto_increment` or `autoincrement` to the column definition
10
10
  * depending on the dialect.
@@ -12,14 +12,14 @@ export interface ColumnDefinitionBuilderInterface<R> {
12
12
  * Some dialects like PostgreSQL don't support this. On PostgreSQL
13
13
  * you can use the `serial` or `bigserial` data type instead.
14
14
  */
15
- autoIncrement(): R;
15
+ autoIncrement(): ColumnDefinitionBuilderInterface;
16
16
  /**
17
17
  * Makes the column the primary key.
18
18
  *
19
19
  * If you want to specify a composite primary key use the
20
20
  * {@link TableBuilder.addPrimaryKeyConstraint} method.
21
21
  */
22
- primaryKey(): R;
22
+ primaryKey(): ColumnDefinitionBuilderInterface;
23
23
  /**
24
24
  * Adds a foreign key constraint for the column.
25
25
  *
@@ -27,12 +27,13 @@ export interface ColumnDefinitionBuilderInterface<R> {
27
27
  * column definition (like MySQL 5) you need to call the table level
28
28
  * {@link TableBuilder.addForeignKeyConstraint} method instead.
29
29
  *
30
- * @example
30
+ * ### Examples
31
+ *
31
32
  * ```ts
32
33
  * col.references('person.id')
33
34
  * ```
34
35
  */
35
- references(ref: string): R;
36
+ references(ref: string): ColumnDefinitionBuilderInterface;
36
37
  /**
37
38
  * Adds an `on delete` constraint for the foreign key column.
38
39
  *
@@ -40,33 +41,42 @@ export interface ColumnDefinitionBuilderInterface<R> {
40
41
  * column definition (like MySQL 5) you need to call the table level
41
42
  * {@link TableBuilder.addForeignKeyConstraint} method instead.
42
43
  *
43
- * @example
44
+ * ### Examples
45
+ *
44
46
  * ```ts
45
47
  * col.references('person.id').onDelete('cascade')
46
48
  * ```
47
49
  */
48
- onDelete(onDelete: OnModifyForeignAction): R;
50
+ onDelete(onDelete: OnModifyForeignAction): ColumnDefinitionBuilderInterface;
49
51
  /**
50
52
  * Adds an `on update` constraint for the foreign key column.
51
53
  *
52
- * @example
54
+ * ### Examples
55
+ *
53
56
  * ```ts
54
57
  * col.references('person.id').onUpdate('cascade')
55
58
  * ```
56
59
  */
57
- onUpdate(onUpdate: OnModifyForeignAction): R;
60
+ onUpdate(onUpdate: OnModifyForeignAction): ColumnDefinitionBuilderInterface;
58
61
  /**
59
62
  * Adds a unique constraint for the column.
60
63
  */
61
- unique(): R;
64
+ unique(): ColumnDefinitionBuilderInterface;
62
65
  /**
63
66
  * Adds a `not null` constraint for the column.
64
67
  */
65
- notNull(): R;
68
+ notNull(): ColumnDefinitionBuilderInterface;
69
+ /**
70
+ * Adds a `unsigned` modifier for the column.
71
+ *
72
+ * This only works on some dialects like MySQL.
73
+ */
74
+ unsigned(): ColumnDefinitionBuilderInterface;
66
75
  /**
67
76
  * Adds a default value constraint for the column.
68
77
  *
69
- * @example
78
+ * ### Examples
79
+ *
70
80
  * ```ts
71
81
  * db.schema
72
82
  * .createTable('pet')
@@ -74,11 +84,12 @@ export interface ColumnDefinitionBuilderInterface<R> {
74
84
  * .execute()
75
85
  * ```
76
86
  */
77
- defaultTo(value: PrimitiveValue | AnyRawBuilder): R;
87
+ defaultTo(value: PrimitiveValue | AnyRawBuilder): ColumnDefinitionBuilderInterface;
78
88
  /**
79
89
  * Adds a check constraint for the column.
80
90
  *
81
- * @example
91
+ * ### Examples
92
+ *
82
93
  * ```ts
83
94
  * db.schema
84
95
  * .createTable('pet')
@@ -86,11 +97,12 @@ export interface ColumnDefinitionBuilderInterface<R> {
86
97
  * .execute()
87
98
  * ```
88
99
  */
89
- check(sql: string): R;
100
+ check(sql: string): ColumnDefinitionBuilderInterface;
90
101
  /**
91
102
  * Makes the column a generated column using a `generated always as` statement.
92
103
  *
93
- * @example
104
+ * ### Examples
105
+ *
94
106
  * ```ts
95
107
  * db.schema
96
108
  * .createTable('person')
@@ -100,12 +112,13 @@ export interface ColumnDefinitionBuilderInterface<R> {
100
112
  * .execute()
101
113
  * ```
102
114
  */
103
- generatedAlwaysAs(sql: string): R;
115
+ generatedAlwaysAs(sql: string): ColumnDefinitionBuilderInterface;
104
116
  /**
105
117
  * Makes a generated column stored instead of virtual. This method can only
106
118
  * be used with {@link generatedAlwaysAs}
107
119
  *
108
- * @example
120
+ * ### Examples
121
+ *
109
122
  * ```ts
110
123
  * db.schema
111
124
  * .createTable('person')
@@ -116,21 +129,135 @@ export interface ColumnDefinitionBuilderInterface<R> {
116
129
  * .execute()
117
130
  * ```
118
131
  */
119
- stored(): R;
132
+ stored(): ColumnDefinitionBuilderInterface;
120
133
  }
121
- export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderInterface<ColumnDefinitionBuilder>, OperationNodeSource {
134
+ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderInterface, OperationNodeSource {
122
135
  #private;
123
136
  constructor(node: ColumnDefinitionNode);
137
+ /**
138
+ * Adds `auto_increment` or `autoincrement` to the column definition
139
+ * depending on the dialect.
140
+ *
141
+ * Some dialects like PostgreSQL don't support this. On PostgreSQL
142
+ * you can use the `serial` or `bigserial` data type instead.
143
+ */
124
144
  autoIncrement(): ColumnDefinitionBuilder;
145
+ /**
146
+ * Makes the column the primary key.
147
+ *
148
+ * If you want to specify a composite primary key use the
149
+ * {@link TableBuilder.addPrimaryKeyConstraint} method.
150
+ */
125
151
  primaryKey(): ColumnDefinitionBuilder;
152
+ /**
153
+ * Adds a foreign key constraint for the column.
154
+ *
155
+ * If your database engine doesn't support foreign key constraints in the
156
+ * column definition (like MySQL 5) you need to call the table level
157
+ * {@link TableBuilder.addForeignKeyConstraint} method instead.
158
+ *
159
+ * ### Examples
160
+ *
161
+ * ```ts
162
+ * col.references('person.id')
163
+ * ```
164
+ */
126
165
  references(ref: string): ColumnDefinitionBuilder;
166
+ /**
167
+ * Adds an `on delete` constraint for the foreign key column.
168
+ *
169
+ * If your database engine doesn't support foreign key constraints in the
170
+ * column definition (like MySQL 5) you need to call the table level
171
+ * {@link TableBuilder.addForeignKeyConstraint} method instead.
172
+ *
173
+ * ### Examples
174
+ *
175
+ * ```ts
176
+ * col.references('person.id').onDelete('cascade')
177
+ * ```
178
+ */
127
179
  onDelete(onDelete: OnModifyForeignAction): ColumnDefinitionBuilder;
180
+ /**
181
+ * Adds an `on update` constraint for the foreign key column.
182
+ *
183
+ * ### Examples
184
+ *
185
+ * ```ts
186
+ * col.references('person.id').onUpdate('cascade')
187
+ * ```
188
+ */
128
189
  onUpdate(onUpdate: OnModifyForeignAction): ColumnDefinitionBuilder;
190
+ /**
191
+ * Adds a unique constraint for the column.
192
+ */
129
193
  unique(): ColumnDefinitionBuilder;
194
+ /**
195
+ * Adds a `not null` constraint for the column.
196
+ */
130
197
  notNull(): ColumnDefinitionBuilder;
198
+ /**
199
+ * Adds a `unsigned` modifier for the column.
200
+ *
201
+ * This only works on some dialects like MySQL.
202
+ */
203
+ unsigned(): ColumnDefinitionBuilder;
204
+ /**
205
+ * Adds a default value constraint for the column.
206
+ *
207
+ * ### Examples
208
+ *
209
+ * ```ts
210
+ * db.schema
211
+ * .createTable('pet')
212
+ * .addColumn('number_of_legs', 'integer', (col) => col.defaultTo(4))
213
+ * .execute()
214
+ * ```
215
+ */
131
216
  defaultTo(value: DefaultValueExpression): ColumnDefinitionBuilder;
217
+ /**
218
+ * Adds a check constraint for the column.
219
+ *
220
+ * ### Examples
221
+ *
222
+ * ```ts
223
+ * db.schema
224
+ * .createTable('pet')
225
+ * .addColumn('number_of_legs', 'integer', (col) => col.check('number_of_legs < 5'))
226
+ * .execute()
227
+ * ```
228
+ */
132
229
  check(sql: string): ColumnDefinitionBuilder;
230
+ /**
231
+ * Makes the column a generated column using a `generated always as` statement.
232
+ *
233
+ * ### Examples
234
+ *
235
+ * ```ts
236
+ * db.schema
237
+ * .createTable('person')
238
+ * .addColumn('full_name', 'varchar(255)',
239
+ * (col) => col.generatedAlwaysAs("concat(first_name, ' ', last_name)")
240
+ * )
241
+ * .execute()
242
+ * ```
243
+ */
133
244
  generatedAlwaysAs(sql: string): ColumnDefinitionBuilder;
245
+ /**
246
+ * Makes a generated column stored instead of virtual. This method can only
247
+ * be used with {@link generatedAlwaysAs}
248
+ *
249
+ * ### Examples
250
+ *
251
+ * ```ts
252
+ * db.schema
253
+ * .createTable('person')
254
+ * .addColumn('full_name', 'varchar(255)', (col) => col
255
+ * .generatedAlwaysAs("concat(first_name, ' ', last_name)")
256
+ * .stored()
257
+ * )
258
+ * .execute()
259
+ * ```
260
+ */
134
261
  stored(): ColumnDefinitionBuilder;
135
262
  toOperationNode(): ColumnDefinitionNode;
136
263
  }
@@ -53,7 +53,10 @@ class ColumnDefinitionBuilder {
53
53
  return new ColumnDefinitionBuilder(column_definition_node_js_1.ColumnDefinitionNode.cloneWith(this.#node, { unique: true }));
54
54
  }
55
55
  notNull() {
56
- return new ColumnDefinitionBuilder(column_definition_node_js_1.ColumnDefinitionNode.cloneWith(this.#node, { nullable: false }));
56
+ return new ColumnDefinitionBuilder(column_definition_node_js_1.ColumnDefinitionNode.cloneWith(this.#node, { notNull: true }));
57
+ }
58
+ unsigned() {
59
+ return new ColumnDefinitionBuilder(column_definition_node_js_1.ColumnDefinitionNode.cloneWith(this.#node, { unsigned: true }));
57
60
  }
58
61
  defaultTo(value) {
59
62
  return new ColumnDefinitionBuilder(column_definition_node_js_1.ColumnDefinitionNode.cloneWith(this.#node, {
@@ -30,7 +30,8 @@ export declare class CreateIndexBuilder implements OperationNodeSource, Compilab
30
30
  /**
31
31
  * Specifies an arbitrary expression for the index.
32
32
  *
33
- * @example
33
+ * ### Examples
34
+ *
34
35
  * ```ts
35
36
  * await db.schema
36
37
  * .createIndex('person_first_name_index')
@@ -64,7 +64,8 @@ class CreateIndexBuilder {
64
64
  /**
65
65
  * Specifies an arbitrary expression for the index.
66
66
  *
67
- * @example
67
+ * ### Examples
68
+ *
68
69
  * ```ts
69
70
  * await db.schema
70
71
  * .createIndex('person_first_name_index')