kysely 0.12.2 → 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 (36) hide show
  1. package/README.md +34 -10
  2. package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +2 -2
  3. package/dist/cjs/dialect/mysql/mysql-adapter.js +2 -1
  4. package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +2 -2
  5. package/dist/cjs/dialect/postgres/postgres-adapter.js +2 -1
  6. package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +2 -2
  7. package/dist/cjs/index.d.ts +1 -1
  8. package/dist/cjs/migration/migration.d.ts +154 -11
  9. package/dist/cjs/migration/migration.js +256 -135
  10. package/dist/cjs/operation-node/column-definition-node.d.ts +6 -5
  11. package/dist/cjs/operation-node/column-definition-node.js +0 -4
  12. package/dist/cjs/operation-node/operation-node-transformer.js +2 -1
  13. package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +2 -2
  14. package/dist/cjs/query-compiler/default-query-compiler.js +4 -1
  15. package/dist/cjs/schema/alter-table-builder.d.ts +12 -0
  16. package/dist/cjs/schema/alter-table-builder.js +12 -0
  17. package/dist/cjs/schema/column-definition-builder.d.ts +12 -0
  18. package/dist/cjs/schema/column-definition-builder.js +4 -1
  19. package/dist/esm/dialect/mysql/mysql-adapter.d.ts +2 -2
  20. package/dist/esm/dialect/mysql/mysql-adapter.js +2 -1
  21. package/dist/esm/dialect/postgres/postgres-adapter.d.ts +2 -2
  22. package/dist/esm/dialect/postgres/postgres-adapter.js +2 -1
  23. package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +2 -2
  24. package/dist/esm/index.d.ts +1 -1
  25. package/dist/esm/migration/migration.d.ts +154 -11
  26. package/dist/esm/migration/migration.js +255 -134
  27. package/dist/esm/operation-node/column-definition-node.d.ts +6 -5
  28. package/dist/esm/operation-node/column-definition-node.js +0 -4
  29. package/dist/esm/operation-node/operation-node-transformer.js +2 -1
  30. package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +2 -2
  31. package/dist/esm/query-compiler/default-query-compiler.js +4 -1
  32. package/dist/esm/schema/alter-table-builder.d.ts +12 -0
  33. package/dist/esm/schema/alter-table-builder.js +12 -0
  34. package/dist/esm/schema/column-definition-builder.d.ts +12 -0
  35. package/dist/esm/schema/column-definition-builder.js +4 -1
  36. package/package.json +1 -1
@@ -6,20 +6,21 @@ import { GeneratedAlwaysAsNode } from './generated-always-as-node.js';
6
6
  import { OperationNode } from './operation-node.js';
7
7
  import { RawNode } from './raw-node.js';
8
8
  import { ReferencesNode } from './references-node.js';
9
- export declare type ColumnDefinitionNodeProps = Omit<Partial<ColumnDefinitionNode>, 'kind'>;
9
+ export declare type ColumnDefinitionNodeProps = Omit<Partial<ColumnDefinitionNode>, 'kind' | 'dataType'>;
10
10
  export declare type ColumnDataTypeNode = DataTypeNode | RawNode;
11
11
  export interface ColumnDefinitionNode extends OperationNode {
12
12
  readonly kind: 'ColumnDefinitionNode';
13
13
  readonly column: ColumnNode;
14
14
  readonly dataType: ColumnDataTypeNode;
15
15
  readonly references?: ReferencesNode;
16
- readonly primaryKey: boolean;
17
- readonly autoIncrement: boolean;
18
- readonly unique: boolean;
19
- readonly nullable: boolean;
16
+ readonly primaryKey?: boolean;
17
+ readonly autoIncrement?: boolean;
18
+ readonly unique?: boolean;
19
+ readonly notNull?: boolean;
20
20
  readonly defaultTo?: DefaultValueNode;
21
21
  readonly check?: CheckConstraintNode;
22
22
  readonly generatedAlwaysAs?: GeneratedAlwaysAsNode;
23
+ readonly unsigned?: boolean;
23
24
  }
24
25
  /**
25
26
  * @internal
@@ -12,10 +12,6 @@ export const ColumnDefinitionNode = freeze({
12
12
  kind: 'ColumnDefinitionNode',
13
13
  column: ColumnNode.create(column),
14
14
  dataType,
15
- primaryKey: false,
16
- autoIncrement: false,
17
- unique: false,
18
- nullable: true,
19
15
  });
20
16
  },
21
17
  cloneWith(node, props) {
@@ -281,7 +281,8 @@ export class OperationNodeTransformer {
281
281
  primaryKey: node.primaryKey,
282
282
  autoIncrement: node.autoIncrement,
283
283
  unique: node.unique,
284
- nullable: node.nullable,
284
+ notNull: node.notNull,
285
+ unsigned: node.unsigned,
285
286
  defaultTo: this.transformNode(node.defaultTo),
286
287
  check: this.transformNode(node.check),
287
288
  generatedAlwaysAs: this.transformNode(node.generatedAlwaysAs),
@@ -12,8 +12,8 @@ export interface CamelCasePluginOptions {
12
12
  upperCase?: boolean;
13
13
  /**
14
14
  * If true, an underscore is added before each digit when converting
15
- * camelCase to snake_case. For example `foo1Bar => foo_1_bar` and
16
- * `foo_1_bar => foo1Bar`
15
+ * camelCase to snake_case. For example `foo12Bar => foo_12_bar` and
16
+ * `foo_12_bar => foo12Bar`
17
17
  *
18
18
  * Defaults to false.
19
19
  */
@@ -321,6 +321,9 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
321
321
  this.visitNode(node.column);
322
322
  this.append(' ');
323
323
  this.visitNode(node.dataType);
324
+ if (node.unsigned) {
325
+ this.append(' unsigned');
326
+ }
324
327
  if (node.generatedAlwaysAs) {
325
328
  this.append(' ');
326
329
  this.visitNode(node.generatedAlwaysAs);
@@ -329,7 +332,7 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
329
332
  this.append(' ');
330
333
  this.visitNode(node.defaultTo);
331
334
  }
332
- if (!node.nullable) {
335
+ if (node.notNull) {
333
336
  this.append(' not null');
334
337
  }
335
338
  if (node.unique) {
@@ -124,6 +124,12 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
124
124
  * Adds a `not null` constraint for the column.
125
125
  */
126
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;
127
133
  /**
128
134
  * Adds a default value constraint for the column.
129
135
  *
@@ -253,6 +259,12 @@ export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBu
253
259
  * Adds a `not null` constraint for the column.
254
260
  */
255
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;
256
268
  /**
257
269
  * Adds a default value constraint for the column.
258
270
  *
@@ -226,6 +226,12 @@ export class AlterTableAddColumnBuilder {
226
226
  columnBuilder: this.#props.columnBuilder.notNull(),
227
227
  });
228
228
  }
229
+ unsigned() {
230
+ return new AlterTableAddColumnBuilder({
231
+ ...this.#props,
232
+ columnBuilder: this.#props.columnBuilder.unsigned(),
233
+ });
234
+ }
229
235
  defaultTo(value) {
230
236
  return new AlterTableAddColumnBuilder({
231
237
  ...this.#props,
@@ -309,6 +315,12 @@ export class AlterTableModifyColumnBuilder {
309
315
  columnBuilder: this.#props.columnBuilder.notNull(),
310
316
  });
311
317
  }
318
+ unsigned() {
319
+ return new AlterTableModifyColumnBuilder({
320
+ ...this.#props,
321
+ columnBuilder: this.#props.columnBuilder.unsigned(),
322
+ });
323
+ }
312
324
  defaultTo(value) {
313
325
  return new AlterTableModifyColumnBuilder({
314
326
  ...this.#props,
@@ -66,6 +66,12 @@ export interface ColumnDefinitionBuilderInterface {
66
66
  * Adds a `not null` constraint for the column.
67
67
  */
68
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;
69
75
  /**
70
76
  * Adds a default value constraint for the column.
71
77
  *
@@ -189,6 +195,12 @@ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderI
189
195
  * Adds a `not null` constraint for the column.
190
196
  */
191
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;
192
204
  /**
193
205
  * Adds a default value constraint for the column.
194
206
  *
@@ -50,7 +50,10 @@ export class ColumnDefinitionBuilder {
50
50
  return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { unique: true }));
51
51
  }
52
52
  notNull() {
53
- return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { nullable: false }));
53
+ return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { notNull: true }));
54
+ }
55
+ unsigned() {
56
+ return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { unsigned: true }));
54
57
  }
55
58
  defaultTo(value) {
56
59
  return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kysely",
3
- "version": "0.12.2",
3
+ "version": "0.13.0",
4
4
  "description": "Type safe SQL query builder",
5
5
  "repository": {
6
6
  "type": "git",