Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
koskimas committed Jan 20, 2024
1 parent 9fb78ad commit 9363005
Show file tree
Hide file tree
Showing 221 changed files with 2,164 additions and 2,120 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"test:esmimports": "node scripts/check-esm-imports.js",
"test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
"prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run script:module-fixup && npm run script:copy-interface-doc",
"build": "npm run clean && (npm run build:esm & npm run build:cjs) && npm run script:module-fixup && npm run script:copy-interface-doc",
"build:esm": "tsc -p tsconfig.json && npm run script:add-deno-type-references",
"build:cjs": "tsc -p tsconfig-cjs.json",
"script:module-fixup": "node scripts/module-fixup.js",
Expand Down
4 changes: 2 additions & 2 deletions src/dialect/dialect-adapter-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export abstract class DialectAdapterBase implements DialectAdapter {

abstract acquireMigrationLock(
db: Kysely<any>,
options: MigrationLockOptions
options: MigrationLockOptions,
): Promise<void>

abstract releaseMigrationLock(
db: Kysely<any>,
options: MigrationLockOptions
options: MigrationLockOptions,
): Promise<void>
}
4 changes: 2 additions & 2 deletions src/dialect/dialect-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface DialectAdapter {
*/
acquireMigrationLock(
db: Kysely<any>,
options: MigrationLockOptions
options: MigrationLockOptions,
): Promise<void>

/**
Expand All @@ -91,7 +91,7 @@ export interface DialectAdapter {
*/
releaseMigrationLock(
db: Kysely<any>,
options: MigrationLockOptions
options: MigrationLockOptions,
): Promise<void>
}

Expand Down
4 changes: 2 additions & 2 deletions src/dialect/mssql/mssql-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class MssqlAdapter extends DialectAdapterBase {
// Acquire a transaction-level exclusive lock on the migrations table.
// https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-getapplock-transact-sql?view=sql-server-ver16
await sql`exec sp_getapplock @DbPrincipal = ${sql.lit(
'dbo'
'dbo',
)}, @Resource = ${sql.lit(DEFAULT_MIGRATION_TABLE)}, @LockMode = ${sql.lit(
'Exclusive'
'Exclusive',
)}`.execute(db)
}

Expand Down
6 changes: 3 additions & 3 deletions src/dialect/mssql/mssql-dialect-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface TediousConnection {
beginTransaction(
callback: (error?: Error) => void,
transactionId?: string | undefined,
isolationLevel?: number | undefined
isolationLevel?: number | undefined,
): void
cancel(): void
close(): void
Expand All @@ -127,7 +127,7 @@ export interface TediousConnection {
export declare class TediousRequest {
constructor(
sql: string,
callback: (error: Error, rowCount: number, rows: any[]) => void
callback: (error: Error, rowCount: number, rows: any[]) => void,
)
addParameter(
name: string,
Expand All @@ -137,7 +137,7 @@ export declare class TediousRequest {
length?: number | 'max' | undefined
precision?: number | undefined
scale?: number | undefined
}
},
): void
off(event: 'row', listener: (...args: any[]) => void): void
on(event: 'row', listener: (columns: TediousColumnValue[]) => void): void
Expand Down
24 changes: 12 additions & 12 deletions src/dialect/mssql/mssql-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class MssqlDriver implements Driver {
connection.connect((error) => {
if (error) reject(error)
else resolve(undefined)
})
}),
)

return new MssqlConnection(connection, this.#config.tedious)
Expand All @@ -74,7 +74,7 @@ export class MssqlDriver implements Driver {

async beginTransaction(
connection: MssqlConnection,
settings: TransactionSettings
settings: TransactionSettings,
): Promise<void> {
await connection.beginTransaction(settings)
}
Expand Down Expand Up @@ -118,8 +118,8 @@ class MssqlConnection implements DatabaseConnection {
isolationLevel ? randomString(8) : undefined,
isolationLevel
? this.#getTediousIsolationLevel(isolationLevel)
: undefined
)
: undefined,
),
)
}

Expand All @@ -128,7 +128,7 @@ class MssqlConnection implements DatabaseConnection {
this.#connection.commitTransaction((error) => {
if (error) reject(error)
else resolve(undefined)
})
}),
)
}

Expand All @@ -139,7 +139,7 @@ class MssqlConnection implements DatabaseConnection {
const request = new MssqlRequest<O>(
this.#tedious,
compiledQuery,
deferred
deferred,
)

this.#connection.execSql(request.request)
Expand All @@ -160,13 +160,13 @@ class MssqlConnection implements DatabaseConnection {
this.#connection.rollbackTransaction((error) => {
if (error) reject(error)
else resolve(undefined)
})
}),
)
}

async *streamQuery<O>(
compiledQuery: CompiledQuery,
chunkSize: number
chunkSize: number,
): AsyncIterableIterator<QueryResult<O>> {
if (!Number.isInteger(chunkSize) || chunkSize <= 0) {
throw new Error('chunkSize must be a positive integer')
Expand Down Expand Up @@ -202,7 +202,7 @@ class MssqlConnection implements DatabaseConnection {
const request = new MssqlRequest<unknown>(
this.#tedious,
CompiledQuery.raw('select 1'),
deferred
deferred,
)

this.#connection.execSql(request.request)
Expand Down Expand Up @@ -279,7 +279,7 @@ class MssqlRequest<O> {
constructor(
tedious: Tedious,
compiledQuery: CompiledQuery,
onDone?: Deferred<OnDone<O>> | PlainDeferred<OnDone<O>>
onDone?: Deferred<OnDone<O>> | PlainDeferred<OnDone<O>>,
) {
this.#completed = false
this.#rows = []
Expand Down Expand Up @@ -325,13 +325,13 @@ class MssqlRequest<O> {
this.#request.addParameter(
String(i + 1),
this.#getTediousDataType(parameter),
parameter
parameter,
)
}
}

#attachListeners(
onDone: Deferred<OnDone<O>> | PlainDeferred<OnDone<O>> | undefined
onDone: Deferred<OnDone<O>> | PlainDeferred<OnDone<O>> | undefined,
): void {
const rowListener = (columns: TediousColumnValue[]) => {
const row: Record<string, unknown> = {}
Expand Down
44 changes: 21 additions & 23 deletions src/dialect/mssql/mssql-introspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,40 @@ export class MssqlIntrospector implements DatabaseIntrospector {
}

async getTables(
options: DatabaseMetadataOptions = { withInternalKyselyTables: false }
options: DatabaseMetadataOptions = { withInternalKyselyTables: false },
): Promise<TableMetadata[]> {
const rawColumns = await this.#db
.selectFrom('sys.tables as tables')
.leftJoin(
'sys.schemas as table_schemas',
'table_schemas.schema_id',
'tables.schema_id'
'tables.schema_id',
)
.innerJoin(
'sys.columns as columns',
'columns.object_id',
'tables.object_id'
'tables.object_id',
)
.innerJoin(
'sys.types as types',
'types.user_type_id',
'columns.user_type_id'
'columns.user_type_id',
)
.leftJoin(
'sys.schemas as type_schemas',
'type_schemas.schema_id',
'types.schema_id'
'types.schema_id',
)
.leftJoin(
'sys.extended_properties as comments',
join => join
.leftJoin('sys.extended_properties as comments', (join) =>
join
.onRef('comments.major_id', '=', 'tables.object_id')
.onRef('comments.minor_id', '=', 'columns.column_id')
.on('comments.name', '=', 'MS_Description')
.on('comments.name', '=', 'MS_Description'),
)
.$if(!options.withInternalKyselyTables, (qb) =>
qb
.where('tables.name', '!=', DEFAULT_MIGRATION_TABLE)
.where('tables.name', '!=', DEFAULT_MIGRATION_LOCK_TABLE)
.where('tables.name', '!=', DEFAULT_MIGRATION_LOCK_TABLE),
)
.select([
'tables.name as table_name',
Expand All @@ -81,37 +80,36 @@ export class MssqlIntrospector implements DatabaseIntrospector {
'types.is_nullable as type_is_nullable',
'types.name as type_name',
'type_schemas.name as type_schema_name',
'comments.value as column_comment'
'comments.value as column_comment',
])
.unionAll(
this.#db
.selectFrom('sys.views as views')
.leftJoin(
'sys.schemas as view_schemas',
'view_schemas.schema_id',
'views.schema_id'
'views.schema_id',
)
.innerJoin(
'sys.columns as columns',
'columns.object_id',
'views.object_id'
'views.object_id',
)
.innerJoin(
'sys.types as types',
'types.user_type_id',
'columns.user_type_id'
'columns.user_type_id',
)
.leftJoin(
'sys.schemas as type_schemas',
'type_schemas.schema_id',
'types.schema_id'
'types.schema_id',
)
.leftJoin(
'sys.extended_properties as comments',
join => join
.leftJoin('sys.extended_properties as comments', (join) =>
join
.onRef('comments.major_id', '=', 'views.object_id')
.onRef('comments.minor_id', '=', 'columns.column_id')
.on('comments.name', '=', 'MS_Description')
.on('comments.name', '=', 'MS_Description'),
)
.select([
'views.name as table_name',
Expand All @@ -127,8 +125,8 @@ export class MssqlIntrospector implements DatabaseIntrospector {
'types.is_nullable as type_is_nullable',
'types.name as type_name',
'type_schemas.name as type_schema_name',
'comments.value as column_comment'
])
'comments.value as column_comment',
]),
)
.orderBy('table_schema_name')
.orderBy('table_name')
Expand Down Expand Up @@ -164,15 +162,15 @@ export class MssqlIntrospector implements DatabaseIntrospector {
rawColumn.column_is_nullable && rawColumn.type_is_nullable,
name: rawColumn.column_name,
comment: rawColumn.column_comment ?? undefined,
})
}),
)
}

return Object.values(tableDictionary)
}

async getMetadata(
options?: DatabaseMetadataOptions
options?: DatabaseMetadataOptions,
): Promise<DatabaseMetadata> {
return {
tables: await this.getTables(options),
Expand Down
2 changes: 1 addition & 1 deletion src/dialect/mssql/mssql-query-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MssqlQueryCompiler extends DefaultQueryCompiler {
// alter table statement, but we compile that anyway for the sake
// of WYSIWYG.
protected override compileColumnAlterations(
columnAlterations: readonly AlterTableColumnAlterationNode[]
columnAlterations: readonly AlterTableColumnAlterationNode[],
): void {
const nodesByKind: Partial<
Record<
Expand Down
6 changes: 3 additions & 3 deletions src/dialect/mysql/mysql-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class MysqlAdapter extends DialectAdapterBase {

async acquireMigrationLock(
db: Kysely<any>,
_opt: MigrationLockOptions
_opt: MigrationLockOptions,
): Promise<void> {
// Kysely uses a single connection to run the migrations. Because of that, we
// can take a lock using `get_lock`. Locks acquired using `get_lock` get
Expand All @@ -26,13 +26,13 @@ export class MysqlAdapter extends DialectAdapterBase {
// released by us after successfull or failed migrations OR it's released by
// MySQL if the process gets killed for some reason.
await sql`select get_lock(${sql.lit(LOCK_ID)}, ${sql.lit(
LOCK_TIMEOUT_SECONDS
LOCK_TIMEOUT_SECONDS,
)})`.execute(db)
}

async releaseMigrationLock(
db: Kysely<any>,
_opt: MigrationLockOptions
_opt: MigrationLockOptions,
): Promise<void> {
await sql`select release_lock(${sql.lit(LOCK_ID)})`.execute(db)
}
Expand Down
6 changes: 3 additions & 3 deletions src/dialect/mysql/mysql-dialect-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ export interface MysqlDialectConfig {
*/
export interface MysqlPool {
getConnection(
callback: (error: unknown, connection: MysqlPoolConnection) => void
callback: (error: unknown, connection: MysqlPoolConnection) => void,
): void
end(callback: (error: unknown) => void): void
}

export interface MysqlPoolConnection {
query(
sql: string,
parameters: ReadonlyArray<unknown>
parameters: ReadonlyArray<unknown>,
): { stream: <T>(options: MysqlStreamOptions) => MysqlStream<T> }
query(
sql: string,
parameters: ReadonlyArray<unknown>,
callback: (error: unknown, result: MysqlQueryResult) => void
callback: (error: unknown, result: MysqlQueryResult) => void,
): void
release(): void
}
Expand Down
10 changes: 5 additions & 5 deletions src/dialect/mysql/mysql-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ export class MysqlDriver implements Driver {

async beginTransaction(
connection: DatabaseConnection,
settings: TransactionSettings
settings: TransactionSettings,
): Promise<void> {
if (settings.isolationLevel) {
// On MySQL this sets the isolation level of the next transaction.
await connection.executeQuery(
CompiledQuery.raw(
`set transaction isolation level ${settings.isolationLevel}`
)
`set transaction isolation level ${settings.isolationLevel}`,
),
)
}

Expand Down Expand Up @@ -169,14 +169,14 @@ class MysqlConnection implements DatabaseConnection {
} else {
resolve(result)
}
}
},
)
})
}

async *streamQuery<O>(
compiledQuery: CompiledQuery,
_chunkSize: number
_chunkSize: number,
): AsyncIterableIterator<QueryResult<O>> {
const stream = this.#rawConnection
.query(compiledQuery.sql, compiledQuery.parameters)
Expand Down
Loading

1 comment on commit 9363005

@vercel
Copy link

@vercel vercel bot commented on 9363005 Jan 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kysely – ./

kysely-kysely-team.vercel.app
kysely-git-master-kysely-team.vercel.app
kysely.dev
www.kysely.dev

Please sign in to comment.