kysely 0.30.0-beta.0 → 0.30.0-beta.2
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.
- package/README.md +1 -1
- package/dist/dialect/database-introspector.d.ts +38 -4
- package/dist/dialect/mssql/mssql-introspector.d.ts +2 -2
- package/dist/dialect/mssql/mssql-introspector.js +32 -2
- package/dist/dialect/mysql/mysql-dialect-config.d.ts +31 -6
- package/dist/dialect/mysql/mysql-dialect.d.ts +2 -2
- package/dist/dialect/mysql/mysql-dialect.js +2 -2
- package/dist/dialect/mysql/mysql-driver.js +28 -2
- package/dist/dialect/mysql/mysql-introspector.d.ts +2 -2
- package/dist/dialect/mysql/mysql-introspector.js +34 -11
- package/dist/dialect/postgres/postgres-introspector.d.ts +2 -2
- package/dist/dialect/postgres/postgres-introspector.js +18 -7
- package/dist/dialect/sqlite/sqlite-driver.js +7 -8
- package/dist/dialect/sqlite/sqlite-introspector.js +7 -3
- package/dist/driver/dummy-driver.d.ts +2 -2
- package/dist/driver/dummy-driver.js +2 -2
- package/dist/kysely.d.ts +27 -7
- package/dist/kysely.js +0 -14
- package/dist/migration/file-migration-provider.d.ts +1 -1
- package/dist/migration/file-migration-provider.js +1 -1
- package/dist/migration/migrator.d.ts +48 -9
- package/dist/migration/migrator.js +62 -19
- package/dist/query-builder/delete-query-builder.d.ts +2 -2
- package/dist/query-builder/function-module.d.ts +8 -2
- package/dist/query-builder/join-builder.d.ts +2 -2
- package/dist/query-builder/merge-query-builder.d.ts +9 -1
- package/dist/query-builder/select-query-builder.d.ts +28 -6
- package/dist/query-builder/update-query-builder.d.ts +1 -1
- package/dist/query-creator.d.ts +9 -0
- package/dist/raw-builder/raw-builder.d.ts +5 -0
- package/dist/raw-builder/raw-builder.js +12 -0
- package/dist/readonly/readonly-kysely.d.ts +64 -10
- package/dist/readonly/readonly-query-creator.d.ts +9 -1
- package/dist/schema/create-type-builder.d.ts +1 -1
- package/dist/schema/create-type-builder.js +1 -1
- package/dist/util/abort.js +2 -0
- package/package.json +18 -16
package/dist/kysely.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import type { CompiledQuery } from './query-compiler/compiled-query.js';
|
|
|
14
14
|
import { type Compilable } from './util/compilable.js';
|
|
15
15
|
import { CaseBuilder } from './query-builder/case-builder.js';
|
|
16
16
|
import type { Expression } from './expression/expression.js';
|
|
17
|
-
import type { DrainOuterGeneric } from './util/type-utils.js';
|
|
18
17
|
import type { ReleaseSavepoint, RollbackToSavepoint } from './parser/savepoint-parser.js';
|
|
19
18
|
import { type ControlledConnection } from './util/provide-controlled-connection.js';
|
|
20
19
|
import type { AbortableOperationOptions, AbortableQueryOptions } from './util/abort.js';
|
|
@@ -60,6 +59,7 @@ declare global {
|
|
|
60
59
|
*/
|
|
61
60
|
export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecutorProvider, AsyncDisposable {
|
|
62
61
|
#private;
|
|
62
|
+
protected readonly '~DB': QueryCreator<DB>['~DB'];
|
|
63
63
|
constructor(args: KyselyConfig);
|
|
64
64
|
constructor(args: KyselyProps);
|
|
65
65
|
/**
|
|
@@ -380,7 +380,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
380
380
|
* .execute()
|
|
381
381
|
* ```
|
|
382
382
|
*/
|
|
383
|
-
$extendTables<T extends Record<string, Record<string, any>>>(): Kysely<
|
|
383
|
+
$extendTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
|
|
384
384
|
/**
|
|
385
385
|
* Returns a copy of this Kysely instance without the given tables (provided as
|
|
386
386
|
* a union type of table names).
|
|
@@ -446,7 +446,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
446
446
|
/**
|
|
447
447
|
* @deprecated use {@link $extendTables} instead.
|
|
448
448
|
*/
|
|
449
|
-
withTables<T extends Record<string, Record<string, any>>>(): Kysely<
|
|
449
|
+
withTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
|
|
450
450
|
/**
|
|
451
451
|
* Releases all resources and disconnects from the database.
|
|
452
452
|
*
|
|
@@ -514,19 +514,30 @@ export declare class Transaction<DB> extends Kysely<DB> {
|
|
|
514
514
|
*
|
|
515
515
|
* @deprecated use {@link $extendTables} instead.
|
|
516
516
|
*/
|
|
517
|
-
withTables<T extends Record<string, Record<string, any>>>(): Transaction<
|
|
517
|
+
withTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
|
|
518
|
+
/**
|
|
519
|
+
* @deprecated use {@link $extendTables} instead.
|
|
520
|
+
*/
|
|
521
|
+
withTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
|
|
522
|
+
withTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
|
|
518
523
|
/**
|
|
519
524
|
* Similar to {@link Kysely.$extendTables} but returns the transaction.
|
|
520
525
|
*/
|
|
521
|
-
$extendTables<T extends Record<string, Record<string, any>>>(): Transaction<
|
|
526
|
+
$extendTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
|
|
527
|
+
$extendTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
|
|
528
|
+
$extendTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
|
|
522
529
|
/**
|
|
523
530
|
* Similar to {@link Kysely.$omitTables} but returns the transaction.
|
|
524
531
|
*/
|
|
525
532
|
$omitTables<T extends keyof DB>(): Transaction<DB extends object ? Omit<DB, T> : DB>;
|
|
533
|
+
$omitTables<T extends keyof DB>(): Kysely<DB extends object ? Omit<DB, T> : DB>;
|
|
534
|
+
$omitTables<T extends keyof DB>(): Transaction<DB extends object ? Omit<DB, T> : DB>;
|
|
526
535
|
/**
|
|
527
536
|
* Similar to {@link Kysely.$pickTables} but returns the transaction.
|
|
528
537
|
*/
|
|
529
538
|
$pickTables<T extends keyof DB>(): Transaction<DB extends object ? Pick<DB, T> : DB>;
|
|
539
|
+
$pickTables<T extends keyof DB>(): Kysely<DB extends object ? Pick<DB, T> : DB>;
|
|
540
|
+
$pickTables<T extends keyof DB>(): Transaction<DB extends object ? Pick<DB, T> : DB>;
|
|
530
541
|
}
|
|
531
542
|
export interface KyselyProps {
|
|
532
543
|
readonly config: KyselyConfig;
|
|
@@ -777,10 +788,19 @@ export declare class ControlledTransaction<DB, S extends string[] = []> extends
|
|
|
777
788
|
*
|
|
778
789
|
* @deprecated use {@link $extendTables} instead.
|
|
779
790
|
*/
|
|
780
|
-
withTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<
|
|
781
|
-
|
|
791
|
+
withTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
|
|
792
|
+
withTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
|
|
793
|
+
withTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
|
|
794
|
+
$extendTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
|
|
795
|
+
$extendTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
|
|
796
|
+
$extendTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
|
|
797
|
+
$omitTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Omit<DB, T> : DB, S>;
|
|
798
|
+
$omitTables<T extends keyof DB>(): Kysely<DB extends object ? Omit<DB, T> : DB>;
|
|
799
|
+
$omitTables<T extends keyof DB>(): Transaction<DB extends object ? Omit<DB, T> : DB>;
|
|
782
800
|
$omitTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Omit<DB, T> : DB, S>;
|
|
783
801
|
$pickTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Pick<DB, T> : DB, S>;
|
|
802
|
+
$pickTables<T extends keyof DB>(): Kysely<DB extends object ? Pick<DB, T> : DB>;
|
|
803
|
+
$pickTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Pick<DB, T> : DB, S>;
|
|
784
804
|
}
|
|
785
805
|
interface ControlledTransactionProps extends KyselyProps {
|
|
786
806
|
readonly connection: ControlledConnection;
|
package/dist/kysely.js
CHANGED
|
@@ -601,29 +601,15 @@ export class Transaction extends Kysely {
|
|
|
601
601
|
executor: this.#props.executor.withPluginAtFront(new WithSchemaPlugin(schema)),
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
|
-
/**
|
|
605
|
-
* Similar to {@link Kysely.withTables} but returns the transaction.
|
|
606
|
-
*
|
|
607
|
-
* @deprecated use {@link $extendTables} instead.
|
|
608
|
-
*/
|
|
609
604
|
withTables() {
|
|
610
605
|
return new Transaction({ ...this.#props });
|
|
611
606
|
}
|
|
612
|
-
/**
|
|
613
|
-
* Similar to {@link Kysely.$extendTables} but returns the transaction.
|
|
614
|
-
*/
|
|
615
607
|
$extendTables() {
|
|
616
608
|
return new Transaction({ ...this.#props });
|
|
617
609
|
}
|
|
618
|
-
/**
|
|
619
|
-
* Similar to {@link Kysely.$omitTables} but returns the transaction.
|
|
620
|
-
*/
|
|
621
610
|
$omitTables() {
|
|
622
611
|
return new Transaction({ ...this.#props });
|
|
623
612
|
}
|
|
624
|
-
/**
|
|
625
|
-
* Similar to {@link Kysely.$pickTables} but returns the transaction.
|
|
626
|
-
*/
|
|
627
613
|
$pickTables() {
|
|
628
614
|
return new Transaction({ ...this.#props });
|
|
629
615
|
}
|
|
@@ -16,7 +16,7 @@ export declare const NO_MIGRATIONS: NoMigrations;
|
|
|
16
16
|
* other way.
|
|
17
17
|
*
|
|
18
18
|
* ```ts
|
|
19
|
-
* import
|
|
19
|
+
* import fs from 'node:fs/promises'
|
|
20
20
|
* import path from 'node:path'
|
|
21
21
|
* import * as Sqlite from 'better-sqlite3'
|
|
22
22
|
* import { Kysely, SqliteDialect } from 'kysely'
|
|
@@ -64,7 +64,7 @@ export declare class Migrator {
|
|
|
64
64
|
* ### Examples
|
|
65
65
|
*
|
|
66
66
|
* ```ts
|
|
67
|
-
* import
|
|
67
|
+
* import fs from 'node:fs/promises'
|
|
68
68
|
* import path from 'node:path'
|
|
69
69
|
* import * as Sqlite from 'better-sqlite3'
|
|
70
70
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
@@ -106,7 +106,7 @@ export declare class Migrator {
|
|
|
106
106
|
* ### Examples
|
|
107
107
|
*
|
|
108
108
|
* ```ts
|
|
109
|
-
* import
|
|
109
|
+
* import fs from 'node:fs/promises'
|
|
110
110
|
* import path from 'node:path'
|
|
111
111
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
112
112
|
*
|
|
@@ -129,7 +129,7 @@ export declare class Migrator {
|
|
|
129
129
|
* you can use a special constant `NO_MIGRATIONS`:
|
|
130
130
|
*
|
|
131
131
|
* ```ts
|
|
132
|
-
* import
|
|
132
|
+
* import fs from 'node:fs/promises'
|
|
133
133
|
* import path from 'node:path'
|
|
134
134
|
* import { FileMigrationProvider, Migrator, NO_MIGRATIONS } from 'kysely/migration'
|
|
135
135
|
*
|
|
@@ -145,8 +145,33 @@ export declare class Migrator {
|
|
|
145
145
|
*
|
|
146
146
|
* await migrator.migrateTo(NO_MIGRATIONS)
|
|
147
147
|
* ```
|
|
148
|
+
*
|
|
149
|
+
* By default, this method migrates up or down depending on which side of the
|
|
150
|
+
* current migration state the target migration is on. Pass
|
|
151
|
+
* {@link MigrateToOptions.direction} to enforce a direction — if reaching the
|
|
152
|
+
* target would require migrating the other way, nothing is executed and
|
|
153
|
+
* {@link MigrationResultSet.error} holds an error:
|
|
154
|
+
*
|
|
155
|
+
* ```ts
|
|
156
|
+
* import fs from 'node:fs/promises'
|
|
157
|
+
* import path from 'node:path'
|
|
158
|
+
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
159
|
+
*
|
|
160
|
+
* const migrator = new Migrator({
|
|
161
|
+
* db,
|
|
162
|
+
* provider: new FileMigrationProvider({
|
|
163
|
+
* fs,
|
|
164
|
+
* // Path to the folder that contains all your migrations.
|
|
165
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
166
|
+
* path,
|
|
167
|
+
* })
|
|
168
|
+
* })
|
|
169
|
+
*
|
|
170
|
+
* // Errors if `some_migration` is already executed.
|
|
171
|
+
* await migrator.migrateTo('some_migration', { direction: 'Up' })
|
|
172
|
+
* ```
|
|
148
173
|
*/
|
|
149
|
-
migrateTo(targetMigrationName: string | NoMigrations, options?:
|
|
174
|
+
migrateTo(targetMigrationName: string | NoMigrations, options?: MigrateToOptions): Promise<MigrationResultSet>;
|
|
150
175
|
/**
|
|
151
176
|
* Migrate one step up.
|
|
152
177
|
*
|
|
@@ -158,7 +183,7 @@ export declare class Migrator {
|
|
|
158
183
|
* ### Examples
|
|
159
184
|
*
|
|
160
185
|
* ```ts
|
|
161
|
-
* import
|
|
186
|
+
* import fs from 'node:fs/promises'
|
|
162
187
|
* import path from 'node:path'
|
|
163
188
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
164
189
|
*
|
|
@@ -187,7 +212,7 @@ export declare class Migrator {
|
|
|
187
212
|
* ### Examples
|
|
188
213
|
*
|
|
189
214
|
* ```ts
|
|
190
|
-
* import
|
|
215
|
+
* import fs from 'node:fs/promises'
|
|
191
216
|
* import path from 'node:path'
|
|
192
217
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
193
218
|
*
|
|
@@ -257,6 +282,21 @@ export interface MigrateOptions {
|
|
|
257
282
|
readonly transactionMode?: MigratorTransactionMode;
|
|
258
283
|
}
|
|
259
284
|
export type MigratorTransactionMode = 'per-run' | 'per-migration' | 'none';
|
|
285
|
+
export interface MigrateToOptions extends MigrateOptions {
|
|
286
|
+
/**
|
|
287
|
+
* Enforces a migration direction.
|
|
288
|
+
*
|
|
289
|
+
* When provided and reaching the target migration would require migrating
|
|
290
|
+
* the other way, nothing is executed and {@link MigrationResultSet.error}
|
|
291
|
+
* holds an error. For example, `direction: 'Up'` errors when the target
|
|
292
|
+
* migration is already executed.
|
|
293
|
+
*
|
|
294
|
+
* By default, {@link Migrator.migrateTo | migrateTo} migrates up or down
|
|
295
|
+
* depending on which side of the current migration state the target
|
|
296
|
+
* migration is on.
|
|
297
|
+
*/
|
|
298
|
+
readonly direction?: MigrationDirection;
|
|
299
|
+
}
|
|
260
300
|
export interface MigratorProps extends MigrateOptions {
|
|
261
301
|
readonly db: Kysely<any>;
|
|
262
302
|
readonly provider: MigrationProvider;
|
|
@@ -359,7 +399,7 @@ export interface MigrationResultSet {
|
|
|
359
399
|
*/
|
|
360
400
|
readonly results?: MigrationResult[];
|
|
361
401
|
}
|
|
362
|
-
type MigrationDirection = 'Up' | 'Down';
|
|
402
|
+
export type MigrationDirection = 'Up' | 'Down';
|
|
363
403
|
export interface MigrationResult {
|
|
364
404
|
readonly migrationName: string;
|
|
365
405
|
/**
|
|
@@ -422,4 +462,3 @@ export interface MigrationInfo {
|
|
|
422
462
|
*/
|
|
423
463
|
executedAt?: Date;
|
|
424
464
|
}
|
|
425
|
-
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="./migrator.d.ts" />
|
|
2
2
|
import { NoopPlugin } from '../plugin/noop-plugin.js';
|
|
3
3
|
import { WithSchemaPlugin } from '../plugin/with-schema/with-schema-plugin.js';
|
|
4
|
+
import { sql } from '../raw-builder/sql.js';
|
|
4
5
|
import { logOnce } from '../util/log-once.js';
|
|
5
6
|
import { freeze, isObject } from '../util/object-utils.js';
|
|
6
7
|
export const DEFAULT_MIGRATION_TABLE = 'kysely_migration';
|
|
@@ -19,7 +20,7 @@ export const NO_MIGRATIONS = freeze({ __noMigrations__: true });
|
|
|
19
20
|
* other way.
|
|
20
21
|
*
|
|
21
22
|
* ```ts
|
|
22
|
-
* import
|
|
23
|
+
* import fs from 'node:fs/promises'
|
|
23
24
|
* import path from 'node:path'
|
|
24
25
|
* import * as Sqlite from 'better-sqlite3'
|
|
25
26
|
* import { Kysely, SqliteDialect } from 'kysely'
|
|
@@ -53,7 +54,7 @@ export class Migrator {
|
|
|
53
54
|
* The returned array is sorted by migration name.
|
|
54
55
|
*/
|
|
55
56
|
async getMigrations() {
|
|
56
|
-
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
57
|
+
const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationTable);
|
|
57
58
|
const executedMigrations = tableExists
|
|
58
59
|
? await this.#props.db
|
|
59
60
|
.withPlugin(this.#schemaPlugin)
|
|
@@ -88,7 +89,7 @@ export class Migrator {
|
|
|
88
89
|
* ### Examples
|
|
89
90
|
*
|
|
90
91
|
* ```ts
|
|
91
|
-
* import
|
|
92
|
+
* import fs from 'node:fs/promises'
|
|
92
93
|
* import path from 'node:path'
|
|
93
94
|
* import * as Sqlite from 'better-sqlite3'
|
|
94
95
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
@@ -132,7 +133,7 @@ export class Migrator {
|
|
|
132
133
|
* ### Examples
|
|
133
134
|
*
|
|
134
135
|
* ```ts
|
|
135
|
-
* import
|
|
136
|
+
* import fs from 'node:fs/promises'
|
|
136
137
|
* import path from 'node:path'
|
|
137
138
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
138
139
|
*
|
|
@@ -155,7 +156,7 @@ export class Migrator {
|
|
|
155
156
|
* you can use a special constant `NO_MIGRATIONS`:
|
|
156
157
|
*
|
|
157
158
|
* ```ts
|
|
158
|
-
* import
|
|
159
|
+
* import fs from 'node:fs/promises'
|
|
159
160
|
* import path from 'node:path'
|
|
160
161
|
* import { FileMigrationProvider, Migrator, NO_MIGRATIONS } from 'kysely/migration'
|
|
161
162
|
*
|
|
@@ -171,11 +172,39 @@ export class Migrator {
|
|
|
171
172
|
*
|
|
172
173
|
* await migrator.migrateTo(NO_MIGRATIONS)
|
|
173
174
|
* ```
|
|
175
|
+
*
|
|
176
|
+
* By default, this method migrates up or down depending on which side of the
|
|
177
|
+
* current migration state the target migration is on. Pass
|
|
178
|
+
* {@link MigrateToOptions.direction} to enforce a direction — if reaching the
|
|
179
|
+
* target would require migrating the other way, nothing is executed and
|
|
180
|
+
* {@link MigrationResultSet.error} holds an error:
|
|
181
|
+
*
|
|
182
|
+
* ```ts
|
|
183
|
+
* import fs from 'node:fs/promises'
|
|
184
|
+
* import path from 'node:path'
|
|
185
|
+
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
186
|
+
*
|
|
187
|
+
* const migrator = new Migrator({
|
|
188
|
+
* db,
|
|
189
|
+
* provider: new FileMigrationProvider({
|
|
190
|
+
* fs,
|
|
191
|
+
* // Path to the folder that contains all your migrations.
|
|
192
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
193
|
+
* path,
|
|
194
|
+
* })
|
|
195
|
+
* })
|
|
196
|
+
*
|
|
197
|
+
* // Errors if `some_migration` is already executed.
|
|
198
|
+
* await migrator.migrateTo('some_migration', { direction: 'Up' })
|
|
199
|
+
* ```
|
|
174
200
|
*/
|
|
175
201
|
async migrateTo(targetMigrationName, options) {
|
|
176
202
|
return this.#migrate(({ migrations, executedMigrations, pendingMigrations, }) => {
|
|
177
203
|
if (isObject(targetMigrationName) &&
|
|
178
204
|
targetMigrationName.__noMigrations__ === true) {
|
|
205
|
+
if (options?.direction === 'Up') {
|
|
206
|
+
throw new Error(`can't migrate up to NO_MIGRATIONS`);
|
|
207
|
+
}
|
|
179
208
|
return { direction: 'Down', step: Infinity };
|
|
180
209
|
}
|
|
181
210
|
if (!migrations.find((m) => m.name === targetMigrationName)) {
|
|
@@ -184,12 +213,18 @@ export class Migrator {
|
|
|
184
213
|
const executedIndex = executedMigrations.indexOf(targetMigrationName);
|
|
185
214
|
const pendingIndex = pendingMigrations.findIndex((m) => m.name === targetMigrationName);
|
|
186
215
|
if (executedIndex !== -1) {
|
|
216
|
+
if (options?.direction === 'Up') {
|
|
217
|
+
throw new Error(`migration "${targetMigrationName}" is already executed; can't migrate up to it`);
|
|
218
|
+
}
|
|
187
219
|
return {
|
|
188
220
|
direction: 'Down',
|
|
189
221
|
step: executedMigrations.length - executedIndex - 1,
|
|
190
222
|
};
|
|
191
223
|
}
|
|
192
224
|
if (pendingIndex !== -1) {
|
|
225
|
+
if (options?.direction === 'Down') {
|
|
226
|
+
throw new Error(`migration "${targetMigrationName}" isn't executed; can't migrate down to it`);
|
|
227
|
+
}
|
|
193
228
|
return { direction: 'Up', step: pendingIndex + 1 };
|
|
194
229
|
}
|
|
195
230
|
throw new Error(`migration "${targetMigrationName}" isn't executed or pending`);
|
|
@@ -206,7 +241,7 @@ export class Migrator {
|
|
|
206
241
|
* ### Examples
|
|
207
242
|
*
|
|
208
243
|
* ```ts
|
|
209
|
-
* import
|
|
244
|
+
* import fs from 'node:fs/promises'
|
|
210
245
|
* import path from 'node:path'
|
|
211
246
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
212
247
|
*
|
|
@@ -237,7 +272,7 @@ export class Migrator {
|
|
|
237
272
|
* ### Examples
|
|
238
273
|
*
|
|
239
274
|
* ```ts
|
|
240
|
-
* import
|
|
275
|
+
* import fs from 'node:fs/promises'
|
|
241
276
|
* import path from 'node:path'
|
|
242
277
|
* import { FileMigrationProvider, Migrator } from 'kysely/migration'
|
|
243
278
|
*
|
|
@@ -295,7 +330,7 @@ export class Migrator {
|
|
|
295
330
|
// Use default schema. Nothing to do.
|
|
296
331
|
return;
|
|
297
332
|
}
|
|
298
|
-
const schemaExists = await this.#doesSchemaExist();
|
|
333
|
+
const schemaExists = await this.#doesSchemaExist(this.#migrationTableSchema);
|
|
299
334
|
if (schemaExists) {
|
|
300
335
|
return;
|
|
301
336
|
}
|
|
@@ -303,7 +338,7 @@ export class Migrator {
|
|
|
303
338
|
await this.#createIfNotExists(this.#props.db.schema.createSchema(this.#migrationTableSchema));
|
|
304
339
|
}
|
|
305
340
|
catch (error) {
|
|
306
|
-
const schemaExists = await this.#doesSchemaExist();
|
|
341
|
+
const schemaExists = await this.#doesSchemaExist(this.#migrationTableSchema);
|
|
307
342
|
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create schema`
|
|
308
343
|
// query doesn't throw if the schema already exits. That's why we check if
|
|
309
344
|
// the schema exist here and ignore the error if it does.
|
|
@@ -313,7 +348,7 @@ export class Migrator {
|
|
|
313
348
|
}
|
|
314
349
|
}
|
|
315
350
|
async #ensureMigrationTableExists() {
|
|
316
|
-
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
351
|
+
const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationTable);
|
|
317
352
|
if (tableExists) {
|
|
318
353
|
return;
|
|
319
354
|
}
|
|
@@ -327,7 +362,7 @@ export class Migrator {
|
|
|
327
362
|
.addColumn('timestamp', 'varchar(255)', (col) => col.notNull()));
|
|
328
363
|
}
|
|
329
364
|
catch (error) {
|
|
330
|
-
const tableExists = await this.#doesTableExist(this.#migrationTable);
|
|
365
|
+
const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationTable);
|
|
331
366
|
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
|
|
332
367
|
// query doesn't throw if the table already exits. That's why we check if
|
|
333
368
|
// the table exist here and ignore the error if it does.
|
|
@@ -337,7 +372,7 @@ export class Migrator {
|
|
|
337
372
|
}
|
|
338
373
|
}
|
|
339
374
|
async #ensureMigrationLockTableExists() {
|
|
340
|
-
const tableExists = await this.#doesTableExist(this.#migrationLockTable);
|
|
375
|
+
const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationLockTable);
|
|
341
376
|
if (tableExists) {
|
|
342
377
|
return;
|
|
343
378
|
}
|
|
@@ -349,7 +384,7 @@ export class Migrator {
|
|
|
349
384
|
.addColumn('is_locked', 'integer', (col) => col.notNull().defaultTo(0)));
|
|
350
385
|
}
|
|
351
386
|
catch (error) {
|
|
352
|
-
const tableExists = await this.#doesTableExist(this.#migrationLockTable);
|
|
387
|
+
const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationLockTable);
|
|
353
388
|
// At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
|
|
354
389
|
// query doesn't throw if the table already exits. That's why we check if
|
|
355
390
|
// the table exist here and ignore the error if it does.
|
|
@@ -377,16 +412,24 @@ export class Migrator {
|
|
|
377
412
|
}
|
|
378
413
|
}
|
|
379
414
|
}
|
|
380
|
-
async #doesSchemaExist() {
|
|
381
|
-
const schemas = await this.#props.db.introspection.getSchemas(
|
|
382
|
-
|
|
415
|
+
async #doesSchemaExist(schemaName) {
|
|
416
|
+
const schemas = await this.#props.db.introspection.getSchemas({
|
|
417
|
+
where: ({ schema }) => sql `${schema} = ${schemaName}`,
|
|
418
|
+
});
|
|
419
|
+
// we still keep this in case the introspector doesn't implement support for
|
|
420
|
+
// `where`.
|
|
421
|
+
return schemas.some((it) => it.name === schemaName);
|
|
383
422
|
}
|
|
384
|
-
async #doesTableExist(tableName) {
|
|
385
|
-
const schema = this.#migrationTableSchema;
|
|
423
|
+
async #doesTableExist(schemaName, tableName) {
|
|
386
424
|
const tables = await this.#props.db.introspection.getTables({
|
|
425
|
+
where: ({ schema, table }) => schemaName != null && schema
|
|
426
|
+
? sql `${schema} = ${schemaName} and ${table} = ${tableName}`
|
|
427
|
+
: sql `${table} = ${tableName}`,
|
|
387
428
|
withInternalKyselyTables: true,
|
|
388
429
|
});
|
|
389
|
-
|
|
430
|
+
// we still keep this in case the introspector doesn't implement support for
|
|
431
|
+
// `where`.
|
|
432
|
+
return tables.some((it) => it.name === tableName && (!schemaName || it.schema === schemaName));
|
|
390
433
|
}
|
|
391
434
|
async #doesLockRowExists() {
|
|
392
435
|
const lockRow = await this.#props.db
|
|
@@ -1039,7 +1039,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
1039
1039
|
* delete from `pet` order by `created_at` limit ?
|
|
1040
1040
|
* ```
|
|
1041
1041
|
*/
|
|
1042
|
-
limit
|
|
1042
|
+
limit<VE extends ValueExpression<DB, TB, number>>(limit: VE): DeleteQueryBuilder<DB, TB, O>;
|
|
1043
1043
|
/**
|
|
1044
1044
|
* This can be used to add any additional SQL to the end of the query.
|
|
1045
1045
|
*
|
|
@@ -1122,7 +1122,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
1122
1122
|
* }>
|
|
1123
1123
|
* ```
|
|
1124
1124
|
*/
|
|
1125
|
-
$if<O2>(condition: boolean, func: (qb: this) => DeleteQueryBuilder<any, any, O2>): O2 extends DeleteResult ? DeleteQueryBuilder<DB, TB, DeleteResult> : O2 extends O & infer E ? DeleteQueryBuilder<DB, TB, O & Partial<E>> : DeleteQueryBuilder<DB, TB, Partial<O2>>;
|
|
1125
|
+
$if<O2>(condition: boolean, func: (qb: this) => DeleteQueryBuilder<any, any, O2>): unknown extends O2 ? DeleteQueryBuilder<any, any, O2> : O2 extends DeleteResult ? DeleteQueryBuilder<DB, TB, DeleteResult> : O2 extends O & infer E ? DeleteQueryBuilder<DB, TB, O & Partial<E>> : DeleteQueryBuilder<DB, TB, Partial<O2>>;
|
|
1126
1126
|
/**
|
|
1127
1127
|
* Change the output type of the query.
|
|
1128
1128
|
*
|
|
@@ -3,10 +3,16 @@ import type { Expression } from '../expression/expression.js';
|
|
|
3
3
|
import type { ExtractTypeFromCoalesce1, ExtractTypeFromCoalesce3, ExtractTypeFromCoalesce2, ExtractTypeFromCoalesce4, ExtractTypeFromCoalesce5 } from '../parser/coalesce-parser.js';
|
|
4
4
|
import { type ExtractTypeFromReferenceExpression, type ReferenceExpression, type StringReference, type ExtractTypeFromStringReference } from '../parser/reference-parser.js';
|
|
5
5
|
import type { KyselyTypeError } from '../util/type-error.js';
|
|
6
|
-
import type { IsNever, ShallowDehydrateObject, ShallowDehydrateValue, Simplify } from '../util/type-utils.js';
|
|
6
|
+
import type { IsAny, IsNever, ShallowDehydrateObject, ShallowDehydrateValue, Simplify } from '../util/type-utils.js';
|
|
7
7
|
import { AggregateFunctionBuilder } from './aggregate-function-builder.js';
|
|
8
8
|
import type { SelectQueryBuilderExpression } from '../query-builder/select-query-builder-expression.js';
|
|
9
9
|
import type { Selectable, SelectType } from '../util/column-type.js';
|
|
10
|
+
declare class FunctionModule<DB, TB extends keyof DB> {
|
|
11
|
+
protected readonly '~DB'?: IsAny<DB> extends true ? any : {
|
|
12
|
+
[T in TB]: Selectable<DB[T]>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type { FunctionModule };
|
|
10
16
|
/**
|
|
11
17
|
* Helpers for type safe SQL function calls.
|
|
12
18
|
*
|
|
@@ -79,7 +85,7 @@ import type { Selectable, SelectType } from '../util/column-type.js';
|
|
|
79
85
|
* having count("pet"."id") > $3
|
|
80
86
|
* ```
|
|
81
87
|
*/
|
|
82
|
-
|
|
88
|
+
interface FunctionModule<DB, TB extends keyof DB> {
|
|
83
89
|
/**
|
|
84
90
|
* Creates a function call.
|
|
85
91
|
*
|
|
@@ -14,14 +14,14 @@ export declare class JoinBuilder<DB, TB extends keyof DB> implements OperationNo
|
|
|
14
14
|
* See {@link WhereInterface.where} for documentation and examples.
|
|
15
15
|
*/
|
|
16
16
|
on<RE extends ReferenceExpression<DB, TB>>(lhs: RE, op: ComparisonOperatorExpression, rhs: OperandValueExpressionOrList<DB, TB, RE>): JoinBuilder<DB, TB>;
|
|
17
|
-
on
|
|
17
|
+
on<E extends ExpressionOrFactory<DB, TB, SqlBool>>(expression: E): JoinBuilder<DB, TB>;
|
|
18
18
|
/**
|
|
19
19
|
* Just like {@link WhereInterface.whereRef} but adds an item to the join's
|
|
20
20
|
* `on` clause instead.
|
|
21
21
|
*
|
|
22
22
|
* See {@link WhereInterface.whereRef} for documentation and examples.
|
|
23
23
|
*/
|
|
24
|
-
onRef
|
|
24
|
+
onRef<LRE extends ReferenceExpression<DB, TB>, RRE extends ReferenceExpression<DB, TB>>(lhs: LRE, op: ComparisonOperatorExpression, rhs: RRE): JoinBuilder<DB, TB>;
|
|
25
25
|
/**
|
|
26
26
|
* Adds `on true`.
|
|
27
27
|
*/
|
|
@@ -14,16 +14,24 @@ import type { ValueExpression } from '../parser/value-parser.js';
|
|
|
14
14
|
import type { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
15
15
|
import type { QueryExecutor } from '../query-executor/query-executor.js';
|
|
16
16
|
import type { AbortableQueryOptions } from '../util/abort.js';
|
|
17
|
+
import type { Insertable, Selectable, Updateable } from '../util/column-type.js';
|
|
17
18
|
import type { Compilable } from '../util/compilable.js';
|
|
18
19
|
import type { Executable, ExecuteTakeFirstOrThrowOptions } from '../util/executable.js';
|
|
19
20
|
import type { QueryId } from '../util/query-id.js';
|
|
20
|
-
import type { ShallowRecord, SimplifyResult, SimplifySingleResult, SqlBool } from '../util/type-utils.js';
|
|
21
|
+
import type { IsAny, ShallowRecord, SimplifyResult, SimplifySingleResult, SqlBool } from '../util/type-utils.js';
|
|
21
22
|
import { MergeResult } from './merge-result.js';
|
|
22
23
|
import type { OutputCallback, OutputExpression, OutputInterface, OutputPrefix, SelectExpressionFromOutputCallback, SelectExpressionFromOutputExpression } from './output-interface.js';
|
|
23
24
|
import type { MultiTableReturningInterface } from './returning-interface.js';
|
|
24
25
|
import { UpdateQueryBuilder } from './update-query-builder.js';
|
|
25
26
|
export declare class MergeQueryBuilder<DB, TT extends keyof DB, O> implements MultiTableReturningInterface<DB, TT, O>, OutputInterface<DB, TT, O> {
|
|
26
27
|
#private;
|
|
28
|
+
protected readonly '~DB': IsAny<DB> extends true ? any : {
|
|
29
|
+
[T in keyof DB]: {
|
|
30
|
+
select: () => Selectable<DB[T]>;
|
|
31
|
+
insert: (row: Insertable<DB[T]>) => void;
|
|
32
|
+
update: (row: Updateable<DB[T]>) => void;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
27
35
|
constructor(props: MergeQueryBuilderProps);
|
|
28
36
|
/**
|
|
29
37
|
* This can be used to add any additional SQL to the end of the query.
|
|
@@ -1377,7 +1377,7 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
|
|
|
1377
1377
|
* select "first_name" from "person" limit $1 offset $2
|
|
1378
1378
|
* ```
|
|
1379
1379
|
*/
|
|
1380
|
-
limit
|
|
1380
|
+
limit<VE extends ValueExpression<DB, TB, number | bigint | null>>(limit: VE): SelectQueryBuilder<DB, TB, O>;
|
|
1381
1381
|
/**
|
|
1382
1382
|
* Adds an `offset` clause to the query.
|
|
1383
1383
|
*
|
|
@@ -1400,7 +1400,7 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
|
|
|
1400
1400
|
* select "first_name" from "person" limit $1 offset $2
|
|
1401
1401
|
* ```
|
|
1402
1402
|
*/
|
|
1403
|
-
offset
|
|
1403
|
+
offset<VE extends ValueExpression<DB, TB, number | bigint>>(offset: VE): SelectQueryBuilder<DB, TB, O>;
|
|
1404
1404
|
/**
|
|
1405
1405
|
* Adds a `fetch` clause to the query.
|
|
1406
1406
|
*
|
|
@@ -2367,22 +2367,44 @@ export interface SelectQueryBuilderProps {
|
|
|
2367
2367
|
export interface AliasedSelectQueryBuilder<out O = undefined, out A extends string = never> extends AliasedExpression<O, A> {
|
|
2368
2368
|
get isAliasedSelectQueryBuilder(): true;
|
|
2369
2369
|
}
|
|
2370
|
-
|
|
2370
|
+
/**
|
|
2371
|
+
* Guards a join's result type against being computed for an unknown table
|
|
2372
|
+
* expression.
|
|
2373
|
+
*
|
|
2374
|
+
* `TableExpression<DB, TB> extends TE` only holds when `TE` is as wide as its
|
|
2375
|
+
* own constraint, which never happens at a call site - there `TE` is a specific
|
|
2376
|
+
* table name, alias or subquery. It does happen when the compiler asks what a
|
|
2377
|
+
* join returns for an arbitrary table expression, which is what it has to do
|
|
2378
|
+
* whenever it compares two `SelectQueryBuilder` types structurally.
|
|
2379
|
+
*
|
|
2380
|
+
* Without this guard that comparison never terminates on its own: computing the
|
|
2381
|
+
* join result yields a `SelectQueryBuilder` over a wider `DB`, whose own join
|
|
2382
|
+
* methods yield a wider one still, so the compiler only stops when it hits its
|
|
2383
|
+
* internal recursion limit. That limit differs between TypeScript versions - 7.0
|
|
2384
|
+
* searches a level deeper than 5.9 and 6.0 - which made comparing two select
|
|
2385
|
+
* query builders over 6x more expensive there.
|
|
2386
|
+
*
|
|
2387
|
+
* Collapsing to a fixed type makes the recursion converge instead: joining an
|
|
2388
|
+
* unknown table expression again produces the same type, so the compiler
|
|
2389
|
+
* recognises the pair it is already comparing and stops immediately.
|
|
2390
|
+
*/
|
|
2391
|
+
type JoinResultForUnknownTable<O> = SelectQueryBuilder<any, any, O>;
|
|
2392
|
+
export type SelectQueryBuilderWithInnerJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? InnerJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? SelectQueryBuilder<DB, TB | TE, O> : TE extends AliasedExpression<infer QO, infer QA> ? InnerJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? InnerJoinedBuilder<DB, TB, O, QA, QO> : never;
|
|
2371
2393
|
type InnerJoinedBuilder<DB, TB extends keyof DB, O, A extends string, R> = A extends keyof DB ? SelectQueryBuilder<InnerJoinedDB<DB, A, R>, TB | A, O> : SelectQueryBuilder<DB & ShallowRecord<A, R>, TB | A, O>;
|
|
2372
2394
|
type InnerJoinedDB<DB, A extends string, R> = DrainOuterGeneric<{
|
|
2373
2395
|
[C in keyof DB | A]: C extends A ? R : C extends keyof DB ? DB[C] : never;
|
|
2374
2396
|
}>;
|
|
2375
|
-
export type SelectQueryBuilderWithLeftJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? LeftJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? LeftJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : never;
|
|
2397
|
+
export type SelectQueryBuilderWithLeftJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? LeftJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? LeftJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : never;
|
|
2376
2398
|
type LeftJoinedBuilder<DB, TB extends keyof DB, O, A extends keyof any, R> = A extends keyof DB ? SelectQueryBuilder<LeftJoinedDB<DB, A, R>, TB | A, O> : SelectQueryBuilder<DB & ShallowRecord<A, Nullable<R>>, TB | A, O>;
|
|
2377
2399
|
type LeftJoinedDB<DB, A extends keyof any, R> = DrainOuterGeneric<{
|
|
2378
2400
|
[C in keyof DB | A]: C extends A ? Nullable<R> : C extends keyof DB ? DB[C] : never;
|
|
2379
2401
|
}>;
|
|
2380
|
-
export type SelectQueryBuilderWithRightJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? RightJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? RightJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : never;
|
|
2402
|
+
export type SelectQueryBuilderWithRightJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? RightJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? RightJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : never;
|
|
2381
2403
|
type RightJoinedBuilder<DB, TB extends keyof DB, O, A extends keyof any, R> = SelectQueryBuilder<RightJoinedDB<DB, TB, A, R>, TB | A, O>;
|
|
2382
2404
|
type RightJoinedDB<DB, TB extends keyof DB, A extends keyof any, R> = DrainOuterGeneric<{
|
|
2383
2405
|
[C in keyof DB | A]: C extends A ? R : C extends TB ? Nullable<DB[C]> : C extends keyof DB ? DB[C] : never;
|
|
2384
2406
|
}>;
|
|
2385
|
-
export type SelectQueryBuilderWithFullJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? OuterJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? OuterJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : never;
|
|
2407
|
+
export type SelectQueryBuilderWithFullJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? OuterJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? OuterJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : never;
|
|
2386
2408
|
type OuterJoinedBuilder<DB, TB extends keyof DB, O, A extends keyof any, R> = SelectQueryBuilder<OuterJoinedBuilderDB<DB, TB, A, R>, TB | A, O>;
|
|
2387
2409
|
type OuterJoinedBuilderDB<DB, TB extends keyof DB, A extends keyof any, R> = DrainOuterGeneric<{
|
|
2388
2410
|
[C in keyof DB | A]: C extends A ? Nullable<R> : C extends TB ? Nullable<DB[C]> : C extends keyof DB ? DB[C] : never;
|
|
@@ -1148,7 +1148,7 @@ export declare class UpdateQueryBuilder<DB, UT extends keyof DB, TB extends keyo
|
|
|
1148
1148
|
* }>
|
|
1149
1149
|
* ```
|
|
1150
1150
|
*/
|
|
1151
|
-
$if<O2>(condition: boolean, func: (qb: this) => UpdateQueryBuilder<any, any, any, O2>): O2 extends UpdateResult ? UpdateQueryBuilder<DB, UT, TB, UpdateResult> : O2 extends O & infer E ? UpdateQueryBuilder<DB, UT, TB, O & Partial<E>> : UpdateQueryBuilder<DB, UT, TB, Partial<O2>>;
|
|
1151
|
+
$if<O2>(condition: boolean, func: (qb: this) => UpdateQueryBuilder<any, any, any, O2>): unknown extends O2 ? UpdateQueryBuilder<any, any, any, O2> : O2 extends UpdateResult ? UpdateQueryBuilder<DB, UT, TB, UpdateResult> : O2 extends O & infer E ? UpdateQueryBuilder<DB, UT, TB, O & Partial<E>> : UpdateQueryBuilder<DB, UT, TB, Partial<O2>>;
|
|
1152
1152
|
/**
|
|
1153
1153
|
* Change the output type of the query.
|
|
1154
1154
|
*
|