kysely 0.16.2 → 0.16.6

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 (265) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +205 -0
  3. package/dist/cjs/dialect/mysql/mysql-dialect-config.js +2 -0
  4. package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +1 -205
  5. package/dist/cjs/dialect/mysql/mysql-driver.d.ts +1 -1
  6. package/dist/cjs/dialect/mysql/mysql-driver.js +10 -2
  7. package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +103 -0
  8. package/dist/cjs/dialect/postgres/postgres-dialect-config.js +2 -0
  9. package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +1 -103
  10. package/dist/cjs/dialect/postgres/postgres-driver.d.ts +1 -1
  11. package/dist/cjs/dialect/postgres/postgres-driver.js +11 -2
  12. package/dist/cjs/dialect/sqlite/sqlite-dialect-config.d.ts +43 -0
  13. package/dist/cjs/dialect/sqlite/sqlite-dialect-config.js +2 -0
  14. package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +1 -43
  15. package/dist/cjs/dialect/sqlite/sqlite-driver.d.ts +1 -1
  16. package/dist/cjs/dialect/sqlite/sqlite-driver.js +10 -2
  17. package/dist/cjs/driver/dummy-driver.d.ts +40 -0
  18. package/dist/cjs/driver/dummy-driver.js +34 -0
  19. package/dist/cjs/driver/runtime-driver.d.ts +1 -1
  20. package/dist/cjs/driver/runtime-driver.js +30 -33
  21. package/dist/cjs/index-nodeless.d.ts +1 -0
  22. package/dist/cjs/index-nodeless.js +1 -0
  23. package/dist/cjs/index.d.ts +3 -0
  24. package/dist/cjs/index.js +3 -0
  25. package/dist/cjs/migration/migrator.d.ts +2 -2
  26. package/dist/cjs/operation-node/primitive-value-list-node.d.ts +2 -3
  27. package/dist/cjs/operation-node/value-node.d.ts +3 -4
  28. package/dist/cjs/parser/complex-expression-parser.d.ts +1 -0
  29. package/dist/cjs/parser/complex-expression-parser.js +5 -1
  30. package/dist/cjs/parser/default-value-parser.d.ts +2 -3
  31. package/dist/cjs/parser/default-value-parser.js +2 -2
  32. package/dist/cjs/parser/insert-values-parser.js +4 -3
  33. package/dist/cjs/parser/reference-parser.d.ts +2 -3
  34. package/dist/cjs/parser/value-parser.d.ts +2 -3
  35. package/dist/cjs/parser/value-parser.js +6 -7
  36. package/dist/cjs/query-builder/expression-builder.d.ts +42 -0
  37. package/dist/cjs/query-builder/expression-builder.js +48 -0
  38. package/dist/cjs/query-builder/insert-query-builder.d.ts +16 -0
  39. package/dist/cjs/query-builder/insert-query-builder.js +16 -0
  40. package/dist/cjs/query-builder/on-conflict-builder.d.ts +5 -3
  41. package/dist/cjs/query-compiler/default-query-compiler.d.ts +1 -2
  42. package/dist/cjs/query-creator.d.ts +1 -1
  43. package/dist/cjs/schema/alter-table-builder.d.ts +30 -4
  44. package/dist/cjs/schema/alter-table-builder.js +2 -5
  45. package/dist/cjs/schema/column-definition-builder.d.ts +27 -2
  46. package/dist/cjs/util/log.d.ts +1 -0
  47. package/dist/cjs/util/log.js +3 -0
  48. package/dist/cjs/util/object-utils.d.ts +4 -5
  49. package/dist/cjs/util/object-utils.js +3 -11
  50. package/dist/esm/dialect/database-introspector.js +1 -0
  51. package/dist/esm/dialect/dialect-adapter-base.js +1 -0
  52. package/dist/esm/dialect/dialect-adapter.js +1 -0
  53. package/dist/esm/dialect/dialect.js +1 -0
  54. package/dist/esm/dialect/mysql/mysql-adapter.js +1 -0
  55. package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +205 -0
  56. package/dist/esm/dialect/mysql/mysql-dialect-config.js +2 -0
  57. package/dist/esm/dialect/mysql/mysql-dialect.d.ts +1 -205
  58. package/dist/esm/dialect/mysql/mysql-dialect.js +1 -0
  59. package/dist/esm/dialect/mysql/mysql-driver.d.ts +1 -1
  60. package/dist/esm/dialect/mysql/mysql-driver.js +12 -3
  61. package/dist/esm/dialect/mysql/mysql-introspector.js +1 -0
  62. package/dist/esm/dialect/mysql/mysql-query-compiler.js +1 -0
  63. package/dist/esm/dialect/postgres/postgres-adapter.js +1 -0
  64. package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +103 -0
  65. package/dist/esm/dialect/postgres/postgres-dialect-config.js +2 -0
  66. package/dist/esm/dialect/postgres/postgres-dialect.d.ts +1 -103
  67. package/dist/esm/dialect/postgres/postgres-dialect.js +1 -0
  68. package/dist/esm/dialect/postgres/postgres-driver.d.ts +1 -1
  69. package/dist/esm/dialect/postgres/postgres-driver.js +12 -2
  70. package/dist/esm/dialect/postgres/postgres-introspector.js +1 -0
  71. package/dist/esm/dialect/postgres/postgres-query-compiler.js +1 -0
  72. package/dist/esm/dialect/sqlite/sqlite-adapter.js +1 -0
  73. package/dist/esm/dialect/sqlite/sqlite-dialect-config.d.ts +43 -0
  74. package/dist/esm/dialect/sqlite/sqlite-dialect-config.js +2 -0
  75. package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +1 -43
  76. package/dist/esm/dialect/sqlite/sqlite-dialect.js +1 -0
  77. package/dist/esm/dialect/sqlite/sqlite-driver.d.ts +1 -1
  78. package/dist/esm/dialect/sqlite/sqlite-driver.js +11 -2
  79. package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -0
  80. package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +1 -0
  81. package/dist/esm/driver/connection-provider.js +1 -0
  82. package/dist/esm/driver/database-connection.js +1 -0
  83. package/dist/esm/driver/default-connection-provider.js +1 -0
  84. package/dist/esm/driver/driver.js +1 -0
  85. package/dist/esm/driver/dummy-driver.d.ts +40 -0
  86. package/dist/esm/driver/dummy-driver.js +31 -0
  87. package/dist/esm/driver/runtime-driver.d.ts +1 -1
  88. package/dist/esm/driver/runtime-driver.js +30 -32
  89. package/dist/esm/driver/single-connection-provider.js +1 -0
  90. package/dist/esm/dynamic/dynamic-reference-builder.js +1 -0
  91. package/dist/esm/dynamic/dynamic.js +1 -0
  92. package/dist/esm/index-nodeless.d.ts +1 -0
  93. package/dist/esm/index-nodeless.js +2 -0
  94. package/dist/esm/index.d.ts +3 -0
  95. package/dist/esm/index.js +4 -0
  96. package/dist/esm/kysely.js +1 -0
  97. package/dist/esm/migration/file-migration-provider.js +1 -0
  98. package/dist/esm/migration/migrator.d.ts +2 -2
  99. package/dist/esm/migration/migrator.js +1 -0
  100. package/dist/esm/operation-node/add-column-node.js +1 -0
  101. package/dist/esm/operation-node/add-constraint-node.js +1 -0
  102. package/dist/esm/operation-node/alias-node.js +1 -0
  103. package/dist/esm/operation-node/alter-column-node.js +1 -0
  104. package/dist/esm/operation-node/alter-table-node.js +1 -0
  105. package/dist/esm/operation-node/and-node.js +1 -0
  106. package/dist/esm/operation-node/check-constraint-node.js +1 -0
  107. package/dist/esm/operation-node/column-definition-node.js +1 -0
  108. package/dist/esm/operation-node/column-node.js +1 -0
  109. package/dist/esm/operation-node/column-update-node.js +1 -0
  110. package/dist/esm/operation-node/common-table-expression-name-node.js +1 -0
  111. package/dist/esm/operation-node/common-table-expression-node.js +1 -0
  112. package/dist/esm/operation-node/constraint-node.js +1 -0
  113. package/dist/esm/operation-node/create-index-node.js +1 -0
  114. package/dist/esm/operation-node/create-schema-node.js +1 -0
  115. package/dist/esm/operation-node/create-table-node.js +1 -0
  116. package/dist/esm/operation-node/create-view-node.js +1 -0
  117. package/dist/esm/operation-node/data-type-node.js +1 -0
  118. package/dist/esm/operation-node/default-value-node.js +1 -0
  119. package/dist/esm/operation-node/delete-query-node.js +1 -0
  120. package/dist/esm/operation-node/drop-column-node.js +1 -0
  121. package/dist/esm/operation-node/drop-constraint-node.js +1 -0
  122. package/dist/esm/operation-node/drop-index-node.js +1 -0
  123. package/dist/esm/operation-node/drop-schema-node.js +1 -0
  124. package/dist/esm/operation-node/drop-table-node.js +1 -0
  125. package/dist/esm/operation-node/drop-view-node.js +1 -0
  126. package/dist/esm/operation-node/filter-node.js +1 -0
  127. package/dist/esm/operation-node/foreign-key-constraint-node.js +1 -0
  128. package/dist/esm/operation-node/from-node.js +1 -0
  129. package/dist/esm/operation-node/generated-node.js +1 -0
  130. package/dist/esm/operation-node/group-by-item-node.js +1 -0
  131. package/dist/esm/operation-node/group-by-node.js +1 -0
  132. package/dist/esm/operation-node/having-node.js +1 -0
  133. package/dist/esm/operation-node/identifier-node.js +1 -0
  134. package/dist/esm/operation-node/insert-query-node.js +1 -0
  135. package/dist/esm/operation-node/join-node.js +1 -0
  136. package/dist/esm/operation-node/limit-node.js +1 -0
  137. package/dist/esm/operation-node/list-node.js +1 -0
  138. package/dist/esm/operation-node/modify-column-node.js +1 -0
  139. package/dist/esm/operation-node/offset-node.js +1 -0
  140. package/dist/esm/operation-node/on-conflict-node.js +1 -0
  141. package/dist/esm/operation-node/on-duplicate-key-node.js +1 -0
  142. package/dist/esm/operation-node/on-node.js +1 -0
  143. package/dist/esm/operation-node/operation-node-source.js +1 -0
  144. package/dist/esm/operation-node/operation-node-transformer.js +1 -0
  145. package/dist/esm/operation-node/operation-node-utils.js +1 -0
  146. package/dist/esm/operation-node/operation-node-visitor.js +1 -0
  147. package/dist/esm/operation-node/operation-node.js +1 -0
  148. package/dist/esm/operation-node/operator-node.js +1 -0
  149. package/dist/esm/operation-node/or-node.js +1 -0
  150. package/dist/esm/operation-node/order-by-item-node.js +1 -0
  151. package/dist/esm/operation-node/order-by-node.js +1 -0
  152. package/dist/esm/operation-node/parens-node.js +1 -0
  153. package/dist/esm/operation-node/primary-constraint-node.js +1 -0
  154. package/dist/esm/operation-node/primitive-value-list-node.d.ts +2 -3
  155. package/dist/esm/operation-node/primitive-value-list-node.js +1 -0
  156. package/dist/esm/operation-node/query-node.js +1 -0
  157. package/dist/esm/operation-node/raw-node.js +1 -0
  158. package/dist/esm/operation-node/reference-node.js +1 -0
  159. package/dist/esm/operation-node/references-node.js +1 -0
  160. package/dist/esm/operation-node/rename-column-node.js +1 -0
  161. package/dist/esm/operation-node/returning-node.js +1 -0
  162. package/dist/esm/operation-node/select-all-node.js +1 -0
  163. package/dist/esm/operation-node/select-query-node.js +1 -0
  164. package/dist/esm/operation-node/selection-node.js +1 -0
  165. package/dist/esm/operation-node/table-node.js +1 -0
  166. package/dist/esm/operation-node/union-node.js +1 -0
  167. package/dist/esm/operation-node/unique-constraint-node.js +1 -0
  168. package/dist/esm/operation-node/update-query-node.js +1 -0
  169. package/dist/esm/operation-node/value-list-node.js +1 -0
  170. package/dist/esm/operation-node/value-node.d.ts +3 -4
  171. package/dist/esm/operation-node/value-node.js +1 -0
  172. package/dist/esm/operation-node/values-node.js +1 -0
  173. package/dist/esm/operation-node/where-node.js +1 -0
  174. package/dist/esm/operation-node/with-node.js +1 -0
  175. package/dist/esm/parser/complex-expression-parser.d.ts +1 -0
  176. package/dist/esm/parser/complex-expression-parser.js +4 -0
  177. package/dist/esm/parser/data-type-parser.js +1 -0
  178. package/dist/esm/parser/default-value-parser.d.ts +2 -3
  179. package/dist/esm/parser/default-value-parser.js +3 -2
  180. package/dist/esm/parser/filter-parser.js +1 -0
  181. package/dist/esm/parser/group-by-parser.js +1 -0
  182. package/dist/esm/parser/insert-values-parser.js +6 -4
  183. package/dist/esm/parser/join-parser.js +1 -0
  184. package/dist/esm/parser/order-by-parser.js +1 -0
  185. package/dist/esm/parser/parse-context.js +1 -0
  186. package/dist/esm/parser/reference-parser.d.ts +2 -3
  187. package/dist/esm/parser/reference-parser.js +2 -1
  188. package/dist/esm/parser/returning-parser.js +1 -0
  189. package/dist/esm/parser/select-parser.js +1 -0
  190. package/dist/esm/parser/table-parser.js +1 -0
  191. package/dist/esm/parser/union-parser.js +1 -0
  192. package/dist/esm/parser/update-set-parser.js +1 -0
  193. package/dist/esm/parser/value-parser.d.ts +2 -3
  194. package/dist/esm/parser/value-parser.js +9 -9
  195. package/dist/esm/parser/with-parser.js +1 -0
  196. package/dist/esm/plugin/camel-case/camel-case-plugin.js +1 -0
  197. package/dist/esm/plugin/camel-case/camel-case-transformer.js +1 -0
  198. package/dist/esm/plugin/camel-case/camel-case.js +1 -0
  199. package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +1 -0
  200. package/dist/esm/plugin/immediate-value.ts/immediate-value-transformer.js +1 -0
  201. package/dist/esm/plugin/kysely-plugin.js +1 -0
  202. package/dist/esm/plugin/with-schema/with-schema-plugin.js +1 -0
  203. package/dist/esm/plugin/with-schema/with-schema-transformer.js +1 -0
  204. package/dist/esm/query-builder/delete-query-builder.js +1 -0
  205. package/dist/esm/query-builder/delete-result.js +1 -0
  206. package/dist/esm/query-builder/expression-builder.d.ts +42 -0
  207. package/dist/esm/query-builder/expression-builder.js +49 -0
  208. package/dist/esm/query-builder/function-builder.js +1 -0
  209. package/dist/esm/query-builder/having-interface.js +1 -0
  210. package/dist/esm/query-builder/insert-query-builder.d.ts +16 -0
  211. package/dist/esm/query-builder/insert-query-builder.js +17 -0
  212. package/dist/esm/query-builder/insert-result.js +1 -0
  213. package/dist/esm/query-builder/join-builder.js +1 -0
  214. package/dist/esm/query-builder/join-interface.js +1 -0
  215. package/dist/esm/query-builder/no-result-error.js +1 -0
  216. package/dist/esm/query-builder/on-conflict-builder.d.ts +5 -3
  217. package/dist/esm/query-builder/on-conflict-builder.js +1 -0
  218. package/dist/esm/query-builder/returning-interface.js +1 -0
  219. package/dist/esm/query-builder/select-query-builder.js +1 -0
  220. package/dist/esm/query-builder/update-query-builder.js +1 -0
  221. package/dist/esm/query-builder/update-result.js +1 -0
  222. package/dist/esm/query-builder/where-interface.js +1 -0
  223. package/dist/esm/query-compiler/compiled-query.js +1 -0
  224. package/dist/esm/query-compiler/default-query-compiler.d.ts +1 -2
  225. package/dist/esm/query-compiler/default-query-compiler.js +1 -0
  226. package/dist/esm/query-compiler/query-compiler.js +1 -0
  227. package/dist/esm/query-creator.d.ts +1 -1
  228. package/dist/esm/query-creator.js +1 -0
  229. package/dist/esm/query-executor/default-query-executor.js +1 -0
  230. package/dist/esm/query-executor/noop-query-executor.js +1 -0
  231. package/dist/esm/query-executor/query-executor.js +1 -0
  232. package/dist/esm/raw-builder/raw-builder.js +1 -0
  233. package/dist/esm/schema/alter-table-builder.d.ts +30 -4
  234. package/dist/esm/schema/alter-table-builder.js +3 -5
  235. package/dist/esm/schema/column-definition-builder.d.ts +27 -2
  236. package/dist/esm/schema/column-definition-builder.js +1 -0
  237. package/dist/esm/schema/create-index-builder.js +1 -0
  238. package/dist/esm/schema/create-schema-builder.js +1 -0
  239. package/dist/esm/schema/create-table-builder.js +1 -0
  240. package/dist/esm/schema/create-view-builder.js +1 -0
  241. package/dist/esm/schema/drop-index-builder.js +1 -0
  242. package/dist/esm/schema/drop-schema-builder.js +1 -0
  243. package/dist/esm/schema/drop-table-builder.js +1 -0
  244. package/dist/esm/schema/drop-view-builder.js +1 -0
  245. package/dist/esm/schema/foreign-key-constraint-builder.js +1 -0
  246. package/dist/esm/schema/schema.js +1 -0
  247. package/dist/esm/util/assert.js +1 -0
  248. package/dist/esm/util/column-type.js +1 -0
  249. package/dist/esm/util/compilable.js +1 -0
  250. package/dist/esm/util/log.d.ts +1 -0
  251. package/dist/esm/util/log.js +4 -0
  252. package/dist/esm/util/object-utils.d.ts +4 -5
  253. package/dist/esm/util/object-utils.js +3 -9
  254. package/dist/esm/util/performance-now.js +1 -0
  255. package/dist/esm/util/prevent-await.js +1 -0
  256. package/dist/esm/util/private-symbols.js +1 -0
  257. package/dist/esm/util/query-id.js +1 -0
  258. package/dist/esm/util/random-string.js +1 -0
  259. package/dist/esm/util/type-utils.js +1 -0
  260. package/package.json +11 -6
  261. package/.prettierignore +0 -1
  262. package/dist/cjs/util/dynamic-import.d.ts +0 -2
  263. package/dist/cjs/util/dynamic-import.js +0 -32
  264. package/dist/esm/util/dynamic-import.d.ts +0 -2
  265. package/dist/esm/util/dynamic-import.js +0 -27
package/README.md CHANGED
@@ -162,19 +162,19 @@ type UpdateablePerson = Updateable<PersonTable>
162
162
  ## Select queries
163
163
 
164
164
  You can find examples of select queries in the documentation of the
165
- [select method](https://koskimas.github.io/kysely/classes/QueryBuilder.html#select) and
166
- the [where method](https://koskimas.github.io/kysely/classes/QueryBuilder.html#where)
165
+ [select method](https://koskimas.github.io/kysely/classes/SelectQueryBuilder.html#select) and
166
+ the [where method](https://koskimas.github.io/kysely/classes/SelectQueryBuilder.html#where)
167
167
  among other places.
168
168
 
169
169
  ## Update queries
170
170
 
171
- See the [set method](https://koskimas.github.io/kysely/classes/QueryBuilder.html#set) and the
171
+ See the [set method](https://koskimas.github.io/kysely/classes/UpdateQueryBuilder.html#set) and the
172
172
  [updateTable method](https://koskimas.github.io/kysely/classes/Kysely.html#updateTable)
173
173
  documentation.
174
174
 
175
175
  ## Insert queries
176
176
 
177
- See the [values method](https://koskimas.github.io/kysely/classes/QueryBuilder.html#values) and the
177
+ See the [values method](https://koskimas.github.io/kysely/classes/InsertQueryBuilder.html#values) and the
178
178
  [insertInto method](https://koskimas.github.io/kysely/classes/Kysely.html#insertInto)
179
179
  documentation.
180
180
 
@@ -0,0 +1,205 @@
1
+ import { DatabaseConnection } from '../../driver/database-connection.js';
2
+ /**
3
+ * Config for the MySQL dialect.
4
+ *
5
+ * This interface is equal to `mysql2` library's pool config.
6
+ *
7
+ * https://github.com/sidorares/node-mysql2#using-connection-pools
8
+ */
9
+ export interface MysqlDialectConfig {
10
+ /**
11
+ * The MySQL user to authenticate as
12
+ */
13
+ user?: string;
14
+ /**
15
+ * The password of that MySQL user
16
+ */
17
+ password?: string;
18
+ /**
19
+ * Name of the database to use for this connection
20
+ */
21
+ database?: string;
22
+ /**
23
+ * The charset for the connection. This is called 'collation' in the SQL-level of MySQL (like utf8_general_ci).
24
+ * If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used.
25
+ * (Default: 'UTF8_GENERAL_CI')
26
+ */
27
+ charset?: string;
28
+ /**
29
+ * The hostname of the database you are connecting to. (Default: localhost)
30
+ */
31
+ host?: string;
32
+ /**
33
+ * The port number to connect to. (Default: 3306)
34
+ */
35
+ port?: number;
36
+ /**
37
+ * The source IP address to use for TCP connection
38
+ */
39
+ localAddress?: string;
40
+ /**
41
+ * The path to a unix domain socket to connect to. When used host and port are ignored
42
+ */
43
+ socketPath?: string;
44
+ /**
45
+ * The timezone used to store local dates. (Default: 'local')
46
+ */
47
+ timezone?: string | 'local';
48
+ /**
49
+ * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
50
+ */
51
+ connectTimeout?: number;
52
+ /**
53
+ * Stringify objects instead of converting to values. (Default: 'false')
54
+ */
55
+ stringifyObjects?: boolean;
56
+ /**
57
+ * Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
58
+ */
59
+ insecureAuth?: boolean;
60
+ /**
61
+ * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
62
+ * to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
63
+ *
64
+ * You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
65
+ *
66
+ * WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
67
+ *
68
+ * field.string()
69
+ * field.buffer()
70
+ * field.geometry()
71
+ *
72
+ * are aliases for
73
+ *
74
+ * parser.parseLengthCodedString()
75
+ * parser.parseLengthCodedBuffer()
76
+ * parser.parseGeometryValue()
77
+ *
78
+ * You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
79
+ */
80
+ typeCast?: boolean | ((field: any, next: () => void) => any);
81
+ /**
82
+ * A custom query format function
83
+ */
84
+ queryFormat?: (query: string, values: any) => void;
85
+ /**
86
+ * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
87
+ * (Default: false)
88
+ */
89
+ supportBigNumbers?: boolean;
90
+ /**
91
+ * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
92
+ * always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
93
+ * bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
94
+ * represented with [JavaScript Number objects] (http://ecma262-5.com/ELS5_HTML.htm#Section_8.5)
95
+ * (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects.
96
+ * This option is ignored if supportBigNumbers is disabled.
97
+ */
98
+ bigNumberStrings?: boolean;
99
+ /**
100
+ * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
101
+ * objects. Can be true/false or an array of type names to keep as strings.
102
+ *
103
+ * (Default: false)
104
+ */
105
+ dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
106
+ /**
107
+ * This will print all incoming and outgoing packets on stdout.
108
+ * You can also restrict debugging to packet types by passing an array of types (strings) to debug;
109
+ *
110
+ * (Default: false)
111
+ */
112
+ debug?: any;
113
+ /**
114
+ * Generates stack traces on Error to include call site of library entrance ('long stack traces'). Slight
115
+ * performance penalty for most calls. (Default: true)
116
+ */
117
+ trace?: boolean;
118
+ /**
119
+ * Allow multiple MySQL statements per query. Be careful with this, it exposes you to SQL injection attacks. (Default: false)
120
+ */
121
+ multipleStatements?: boolean;
122
+ /**
123
+ * List of connection flags to use other than the default ones. It is also possible to blacklist default ones
124
+ */
125
+ flags?: Array<string>;
126
+ /**
127
+ * object with ssl parameters or a string containing name of ssl profile
128
+ */
129
+ ssl?: string | MysqlSslOptions;
130
+ /**
131
+ * Return each row as an array, not as an object.
132
+ * This is useful when you have duplicate column names.
133
+ * This can also be set in the `QueryOption` object to be applied per-query.
134
+ */
135
+ rowsAsArray?: boolean;
136
+ /**
137
+ * The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout,
138
+ * because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds)
139
+ */
140
+ acquireTimeout?: number;
141
+ /**
142
+ * Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue
143
+ * the connection request and call it when one becomes available. If false, the pool will immediately call back with an error.
144
+ * (Default: true)
145
+ */
146
+ waitForConnections?: boolean;
147
+ /**
148
+ * The maximum number of connections to create at once. (Default: 10)
149
+ */
150
+ connectionLimit?: number;
151
+ /**
152
+ * The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there
153
+ * is no limit to the number of queued connection requests. (Default: 0)
154
+ */
155
+ queueLimit?: number;
156
+ /**
157
+ * Enable keep-alive on the socket. It's disabled by default, but the
158
+ * user can enable it and supply an initial delay.
159
+ */
160
+ enableKeepAlive?: true;
161
+ /**
162
+ * If keep-alive is enabled users can supply an initial delay.
163
+ */
164
+ keepAliveInitialDelay?: number;
165
+ /**
166
+ * Called once for each created connection.
167
+ *
168
+ * This is a Kysely specific feature and does not come from the `mysql2` module.
169
+ */
170
+ onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
171
+ }
172
+ export interface MysqlSslOptions {
173
+ /**
174
+ * A string or buffer holding the PFX or PKCS12 encoded private key, certificate and CA certificates
175
+ */
176
+ pfx?: string;
177
+ /**
178
+ * A string holding the PEM encoded private key
179
+ */
180
+ key?: string;
181
+ /**
182
+ * A string of passphrase for the private key or pfx
183
+ */
184
+ passphrase?: string;
185
+ /**
186
+ * A string holding the PEM encoded certificate
187
+ */
188
+ cert?: string;
189
+ /**
190
+ * Either a string or list of strings of PEM encoded CA certificates to trust.
191
+ */
192
+ ca?: string | string[];
193
+ /**
194
+ * Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List)
195
+ */
196
+ crl?: string | string[];
197
+ /**
198
+ * A string describing the ciphers to use or exclude
199
+ */
200
+ ciphers?: string;
201
+ /**
202
+ * You can also connect to a MySQL server without properly providing the appropriate CA to trust. You should not do this.
203
+ */
204
+ rejectUnauthorized?: boolean;
205
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,7 +4,7 @@ import { QueryCompiler } from '../../query-compiler/query-compiler.js';
4
4
  import { Dialect } from '../dialect.js';
5
5
  import { DatabaseIntrospector } from '../database-introspector.js';
6
6
  import { DialectAdapter } from '../dialect-adapter.js';
7
- import { DatabaseConnection } from '../../driver/database-connection.js';
7
+ import { MysqlDialectConfig } from './mysql-dialect-config.js';
8
8
  /**
9
9
  * MySQL dialect that uses the [mysql2](https://github.com/sidorares/node-mysql2#readme) library.
10
10
  *
@@ -36,207 +36,3 @@ export declare class MysqlDialect implements Dialect {
36
36
  */
37
37
  createIntrospector(db: Kysely<any>): DatabaseIntrospector;
38
38
  }
39
- /**
40
- * Config for the MySQL dialect.
41
- *
42
- * This interface is equal to `mysql2` library's pool config.
43
- *
44
- * https://github.com/sidorares/node-mysql2#using-connection-pools
45
- */
46
- export interface MysqlDialectConfig {
47
- /**
48
- * The MySQL user to authenticate as
49
- */
50
- user?: string;
51
- /**
52
- * The password of that MySQL user
53
- */
54
- password?: string;
55
- /**
56
- * Name of the database to use for this connection
57
- */
58
- database?: string;
59
- /**
60
- * The charset for the connection. This is called 'collation' in the SQL-level of MySQL (like utf8_general_ci).
61
- * If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used.
62
- * (Default: 'UTF8_GENERAL_CI')
63
- */
64
- charset?: string;
65
- /**
66
- * The hostname of the database you are connecting to. (Default: localhost)
67
- */
68
- host?: string;
69
- /**
70
- * The port number to connect to. (Default: 3306)
71
- */
72
- port?: number;
73
- /**
74
- * The source IP address to use for TCP connection
75
- */
76
- localAddress?: string;
77
- /**
78
- * The path to a unix domain socket to connect to. When used host and port are ignored
79
- */
80
- socketPath?: string;
81
- /**
82
- * The timezone used to store local dates. (Default: 'local')
83
- */
84
- timezone?: string | 'local';
85
- /**
86
- * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
87
- */
88
- connectTimeout?: number;
89
- /**
90
- * Stringify objects instead of converting to values. (Default: 'false')
91
- */
92
- stringifyObjects?: boolean;
93
- /**
94
- * Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
95
- */
96
- insecureAuth?: boolean;
97
- /**
98
- * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
99
- * to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
100
- *
101
- * You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
102
- *
103
- * WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
104
- *
105
- * field.string()
106
- * field.buffer()
107
- * field.geometry()
108
- *
109
- * are aliases for
110
- *
111
- * parser.parseLengthCodedString()
112
- * parser.parseLengthCodedBuffer()
113
- * parser.parseGeometryValue()
114
- *
115
- * You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
116
- */
117
- typeCast?: boolean | ((field: any, next: () => void) => any);
118
- /**
119
- * A custom query format function
120
- */
121
- queryFormat?: (query: string, values: any) => void;
122
- /**
123
- * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
124
- * (Default: false)
125
- */
126
- supportBigNumbers?: boolean;
127
- /**
128
- * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
129
- * always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
130
- * bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
131
- * represented with [JavaScript Number objects] (http://ecma262-5.com/ELS5_HTML.htm#Section_8.5)
132
- * (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects.
133
- * This option is ignored if supportBigNumbers is disabled.
134
- */
135
- bigNumberStrings?: boolean;
136
- /**
137
- * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
138
- * objects. Can be true/false or an array of type names to keep as strings.
139
- *
140
- * (Default: false)
141
- */
142
- dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
143
- /**
144
- * This will print all incoming and outgoing packets on stdout.
145
- * You can also restrict debugging to packet types by passing an array of types (strings) to debug;
146
- *
147
- * (Default: false)
148
- */
149
- debug?: any;
150
- /**
151
- * Generates stack traces on Error to include call site of library entrance ('long stack traces'). Slight
152
- * performance penalty for most calls. (Default: true)
153
- */
154
- trace?: boolean;
155
- /**
156
- * Allow multiple MySQL statements per query. Be careful with this, it exposes you to SQL injection attacks. (Default: false)
157
- */
158
- multipleStatements?: boolean;
159
- /**
160
- * List of connection flags to use other than the default ones. It is also possible to blacklist default ones
161
- */
162
- flags?: Array<string>;
163
- /**
164
- * object with ssl parameters or a string containing name of ssl profile
165
- */
166
- ssl?: string | MysqlSslOptions;
167
- /**
168
- * Return each row as an array, not as an object.
169
- * This is useful when you have duplicate column names.
170
- * This can also be set in the `QueryOption` object to be applied per-query.
171
- */
172
- rowsAsArray?: boolean;
173
- /**
174
- * The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout,
175
- * because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds)
176
- */
177
- acquireTimeout?: number;
178
- /**
179
- * Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue
180
- * the connection request and call it when one becomes available. If false, the pool will immediately call back with an error.
181
- * (Default: true)
182
- */
183
- waitForConnections?: boolean;
184
- /**
185
- * The maximum number of connections to create at once. (Default: 10)
186
- */
187
- connectionLimit?: number;
188
- /**
189
- * The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there
190
- * is no limit to the number of queued connection requests. (Default: 0)
191
- */
192
- queueLimit?: number;
193
- /**
194
- * Enable keep-alive on the socket. It's disabled by default, but the
195
- * user can enable it and supply an initial delay.
196
- */
197
- enableKeepAlive?: true;
198
- /**
199
- * If keep-alive is enabled users can supply an initial delay.
200
- */
201
- keepAliveInitialDelay?: number;
202
- /**
203
- * Called once for each created connection.
204
- *
205
- * This is a Kysely specific feature and does not come from the `mysql2` module.
206
- */
207
- onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
208
- }
209
- export interface MysqlSslOptions {
210
- /**
211
- * A string or buffer holding the PFX or PKCS12 encoded private key, certificate and CA certificates
212
- */
213
- pfx?: string;
214
- /**
215
- * A string holding the PEM encoded private key
216
- */
217
- key?: string;
218
- /**
219
- * A string of passphrase for the private key or pfx
220
- */
221
- passphrase?: string;
222
- /**
223
- * A string holding the PEM encoded certificate
224
- */
225
- cert?: string;
226
- /**
227
- * Either a string or list of strings of PEM encoded CA certificates to trust.
228
- */
229
- ca?: string | string[];
230
- /**
231
- * Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List)
232
- */
233
- crl?: string | string[];
234
- /**
235
- * A string describing the ciphers to use or exclude
236
- */
237
- ciphers?: string;
238
- /**
239
- * You can also connect to a MySQL server without properly providing the appropriate CA to trust. You should not do this.
240
- */
241
- rejectUnauthorized?: boolean;
242
- }
@@ -1,6 +1,6 @@
1
1
  import { DatabaseConnection } from '../../driver/database-connection.js';
2
2
  import { Driver, TransactionSettings } from '../../driver/driver.js';
3
- import { MysqlDialectConfig } from './mysql-dialect.js';
3
+ import { MysqlDialectConfig } from './mysql-dialect-config.js';
4
4
  export declare class MysqlDriver implements Driver {
5
5
  #private;
6
6
  constructor(config: MysqlDialectConfig);
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MysqlDriver = void 0;
4
4
  const compiled_query_js_1 = require("../../query-compiler/compiled-query.js");
5
- const dynamic_import_js_1 = require("../../util/dynamic-import.js");
6
5
  const object_utils_js_1 = require("../../util/object-utils.js");
7
6
  const PRIVATE_RELEASE_METHOD = Symbol();
8
7
  class MysqlDriver {
@@ -83,7 +82,16 @@ class MysqlDriver {
83
82
  exports.MysqlDriver = MysqlDriver;
84
83
  async function importMysqlPoolFactory() {
85
84
  try {
86
- return await (0, dynamic_import_js_1.importNamedFunction)('mysql2', 'createPool');
85
+ // The imported module name must be a string literal to make
86
+ // some bundlers work. So don't move this code behind a helper
87
+ // for example.
88
+ const mysqlModule = await Promise.resolve().then(() => require('mysql2'));
89
+ if ((0, object_utils_js_1.isFunction)(mysqlModule.createPool)) {
90
+ return mysqlModule.createPool;
91
+ }
92
+ else {
93
+ return mysqlModule.default.createPool;
94
+ }
87
95
  }
88
96
  catch (error) {
89
97
  throw new Error('MySQL client not installed. Please run `npm install mysql2`');
@@ -0,0 +1,103 @@
1
+ /// <reference types="node" />
2
+ import * as stream from 'stream';
3
+ import { ConnectionOptions } from 'tls';
4
+ import { DatabaseConnection } from '../../driver/database-connection.js';
5
+ /**
6
+ * Config for the PostgreSQL dialect.
7
+ *
8
+ * This interface is equal to `pg` library's `Pool` config:
9
+ *
10
+ * https://node-postgres.com/api/pool
11
+ * https://node-postgres.com/api/client
12
+ */
13
+ export interface PostgresDialectConfig {
14
+ /**
15
+ * defaults process.env.PGUSER || process.env.USER.
16
+ */
17
+ user?: string;
18
+ /**
19
+ * default process.env.PGDATABASE || process.env.USER
20
+ */
21
+ database?: string;
22
+ /**
23
+ * default process.env.PGPASSWORD
24
+ */
25
+ password?: string | (() => string | Promise<string>);
26
+ /**
27
+ * default process.env.PGPORT
28
+ */
29
+ port?: number;
30
+ /**
31
+ * default process.env.PGHOST
32
+ */
33
+ host?: string;
34
+ /**
35
+ * e.g. postgres:*user:password@host:5432/database
36
+ */
37
+ connectionString?: string;
38
+ /**
39
+ * passed directly to node.TLSSocket, supports all tls.connect options
40
+ */
41
+ ssl?: boolean | ConnectionOptions;
42
+ /**
43
+ * Number of milliseconds to wait before timing out when connecting a new client
44
+ * by default this is 0 which means no timeout.
45
+ */
46
+ connectionTimeoutMillis?: number;
47
+ /**
48
+ * Maximum number of clients the pool should contain. by default this is set to 10.
49
+ */
50
+ max?: number;
51
+ /**
52
+ * Minimum number of clients the pool should contain
53
+ */
54
+ min?: number;
55
+ /**
56
+ * Number of milliseconds a client must sit idle in the pool and not be checked out
57
+ * before it is disconnected from the backend and discarded.
58
+ *
59
+ * default is 10000 (10 seconds) - set to 0 to disable auto-disconnection of idle clients.
60
+ */
61
+ idleTimeoutMillis?: number;
62
+ /**
63
+ * Default behavior is the pool will keep clients open & connected to the backend
64
+ * until idleTimeoutMillis expire for each client and node will maintain a ref
65
+ * to the socket on the client, keeping the event loop alive until all clients are closed
66
+ * after being idle or the pool is manually shutdown with `pool.end()`.
67
+ *
68
+ * Setting `allowExitOnIdle: true` in the config will allow the node event loop to exit
69
+ * as soon as all clients in the pool are idle, even if their socket is still open
70
+ * to the PostgreSQL server. This can be handy in scripts & tests
71
+ * where you don't want to wait for your clients to go idle before your process exits.
72
+ */
73
+ allowExitOnIdle?: boolean;
74
+ log?: (...messages: any[]) => void;
75
+ /**
76
+ * Number of milliseconds before a statement in query will time out, default is no timeout.
77
+ */
78
+ statement_timeout?: false | number;
79
+ /**
80
+ * Number of milliseconds before terminating any session with an open idle transaction.
81
+ * Default is no timeout.
82
+ */
83
+ idle_in_transaction_session_timeout?: number;
84
+ /**
85
+ * Number of milliseconds before a query call will timeout, default is no timeout.
86
+ */
87
+ query_timeout?: number;
88
+ /**
89
+ * The name of the application that created this Client instance.
90
+ */
91
+ application_name?: string;
92
+ /**
93
+ * Called once for each created connection.
94
+ *
95
+ * This is a Kysely specific feature and does not come from the `pg` module.
96
+ */
97
+ onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
98
+ keepAlive?: boolean;
99
+ keepAliveInitialDelayMillis?: number;
100
+ types?: any;
101
+ stream?: stream.Duplex;
102
+ parseInputDatesAsUTC?: boolean;
103
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });