Skip to content

Commit 4f9e3a9

Browse files
authored
Merge branch 'master' into fix/postgres-upsert
2 parents 4b42614 + 514e3d8 commit 4f9e3a9

13 files changed

Lines changed: 142 additions & 58 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
name: Tests
22
on:
33
push:
4-
branches:
5-
- master
6-
- next
74
pull_request:
85

96
jobs:
107
detect-changes:
118
runs-on: ubuntu-latest
9+
if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.fork) }}
1210
outputs:
1311
changes: ${{ steps.detect-changes.outputs.changes }}
1412
steps:
@@ -34,12 +32,12 @@ jobs:
3432
3533
src-or-tests: &src-or-tests
3634
- *src
37-
- test/**/*.ts
35+
- test/**/*
36+
- .c8rc.json
3837
- .github/workflows/test/**/*
3938
- .github/workflows/test*.yml
4039
- .mocharc.json
4140
- .nvmrc
42-
- .nycrc.json
4341
4442
lint: &lint
4543
- *src-or-tests

‎eslint.config.mjs‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import js from "@eslint/js"
2-
import { defineConfig } from "eslint/config"
2+
import pluginChaiFriendly from "eslint-plugin-chai-friendly"
33
import { jsdoc } from "eslint-plugin-jsdoc"
4+
import { defineConfig, globalIgnores } from "eslint/config"
45
import globals from "globals"
56
import ts from "typescript-eslint"
67

78
export default defineConfig([
8-
{
9-
ignores: [
10-
"build/**",
11-
"docs/**",
12-
"node_modules/**",
13-
"sample/playground/**",
14-
"temp/**",
15-
],
16-
},
17-
9+
globalIgnores([
10+
"build/**",
11+
"docs/**",
12+
"node_modules/**",
13+
"sample/playground/**",
14+
"temp/**",
15+
]),
1816
{
1917
files: ["**/*.ts"],
2018
languageOptions: {
@@ -31,10 +29,7 @@ export default defineConfig([
3129
js,
3230
ts,
3331
},
34-
extends: [
35-
js.configs.recommended,
36-
...ts.configs.recommendedTypeChecked,
37-
],
32+
extends: [js.configs.recommended, ...ts.configs.recommendedTypeChecked],
3833
rules: {
3934
// exceptions from typescript-eslint/recommended
4035
"@typescript-eslint/ban-ts-comment": "warn",
@@ -45,12 +40,11 @@ export default defineConfig([
4540
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
4641
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
4742
"@typescript-eslint/no-unsafe-function-type": "warn",
48-
"@typescript-eslint/no-unused-expressions": "warn",
4943
"@typescript-eslint/no-unused-vars": [
5044
"warn",
5145
{
5246
argsIgnorePattern: "^_",
53-
destructuredArrayIgnorePattern: "^_"
47+
destructuredArrayIgnorePattern: "^_",
5448
},
5549
],
5650
"@typescript-eslint/no-wrapper-object-types": "off",
@@ -90,14 +84,17 @@ export default defineConfig([
9084
"no-regex-spaces": "warn",
9185
},
9286
},
93-
9487
jsdoc({
95-
config: "flat/recommended-typescript",
9688
files: ["src/**/*.ts"],
89+
config: "flat/recommended-typescript",
9790
// Temporarily enable individual rules when they are fixed, until all current warnings are gone,
9891
// and then remove manual config in favor of `config: "flat/recommended-typescript-error"`
9992
rules: {
100-
"jsdoc/valid-types": "error"
101-
}
93+
"jsdoc/valid-types": "error",
94+
},
10295
}),
96+
{
97+
files: ["test/**/*.ts"],
98+
...pluginChaiFriendly.configs.recommendedFlat,
99+
},
103100
])

‎package-lock.json‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"chai-as-promised": "^7.1.2",
135135
"class-transformer": "^0.5.1",
136136
"eslint": "^9.39.1",
137+
"eslint-plugin-chai-friendly": "^1.1.0",
137138
"eslint-plugin-jsdoc": "^61.4.1",
138139
"globals": "^16.5.0",
139140
"gulp": "^4.0.2",

‎src/driver/aurora-mysql/AuroraMysqlDriver.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,14 +806,20 @@ export class AuroraMysqlDriver implements Driver {
806806
this.poolCluster.getConnection(
807807
"MASTER",
808808
(err: any, dbConnection: any) => {
809-
err
810-
? fail(err)
811-
: ok(this.prepareDbConnection(dbConnection))
809+
if (err) {
810+
fail(err)
811+
} else {
812+
ok(this.prepareDbConnection(dbConnection))
813+
}
812814
},
813815
)
814816
} else if (this.pool) {
815817
this.pool.getConnection((err: any, dbConnection: any) => {
816-
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
818+
if (err) {
819+
fail(err)
820+
} else {
821+
ok(this.prepareDbConnection(dbConnection))
822+
}
817823
})
818824
} else {
819825
fail(
@@ -837,7 +843,11 @@ export class AuroraMysqlDriver implements Driver {
837843
this.poolCluster.getConnection(
838844
"SLAVE*",
839845
(err: any, dbConnection: any) => {
840-
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
846+
if (err) {
847+
fail(err)
848+
} else {
849+
ok(this.prepareDbConnection(dbConnection))
850+
}
841851
},
842852
)
843853
})

‎src/driver/cockroachdb/CockroachDriver.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,11 @@ export class CockroachDriver implements Driver {
826826

827827
return new Promise((ok, fail) => {
828828
this.master.connect((err: any, connection: any, release: any) => {
829-
err ? fail(err) : ok([connection, release])
829+
if (err) {
830+
fail(err)
831+
} else {
832+
ok([connection, release])
833+
}
830834
})
831835
})
832836
}
@@ -844,7 +848,11 @@ export class CockroachDriver implements Driver {
844848
return new Promise((ok, fail) => {
845849
this.slaves[random].connect(
846850
(err: any, connection: any, release: any) => {
847-
err ? fail(err) : ok([connection, release])
851+
if (err) {
852+
fail(err)
853+
} else {
854+
ok([connection, release])
855+
}
848856
},
849857
)
850858
})

‎src/driver/mysql/MysqlDriver.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -920,14 +920,20 @@ export class MysqlDriver implements Driver {
920920
this.poolCluster.getConnection(
921921
"MASTER",
922922
(err: any, dbConnection: any) => {
923-
err
924-
? fail(err)
925-
: ok(this.prepareDbConnection(dbConnection))
923+
if (err) {
924+
fail(err)
925+
} else {
926+
ok(this.prepareDbConnection(dbConnection))
927+
}
926928
},
927929
)
928930
} else if (this.pool) {
929931
this.pool.getConnection((err: any, dbConnection: any) => {
930-
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
932+
if (err) {
933+
fail(err)
934+
} else {
935+
ok(this.prepareDbConnection(dbConnection))
936+
}
931937
})
932938
} else {
933939
fail(
@@ -951,7 +957,11 @@ export class MysqlDriver implements Driver {
951957
this.poolCluster.getConnection(
952958
"SLAVE*",
953959
(err: any, dbConnection: any) => {
954-
err ? fail(err) : ok(this.prepareDbConnection(dbConnection))
960+
if (err) {
961+
fail(err)
962+
} else {
963+
ok(this.prepareDbConnection(dbConnection))
964+
}
955965
},
956966
)
957967
})

‎src/driver/oracle/OracleDriver.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -988,14 +988,16 @@ export class OracleDriver implements Driver {
988988
try {
989989
const oracle = this.options.driver || PlatformTools.load("oracledb")
990990
this.oracle = oracle
991-
} catch (e) {
991+
} catch {
992992
throw new DriverPackageNotInstalledError("Oracle", "oracledb")
993993
}
994994
const thickMode = this.options.thickMode
995995
if (thickMode) {
996-
typeof thickMode === "object"
997-
? this.oracle.initOracleClient(thickMode)
998-
: this.oracle.initOracleClient()
996+
if (typeof thickMode === "object") {
997+
this.oracle.initOracleClient(thickMode)
998+
} else {
999+
this.oracle.initOracleClient()
1000+
}
9991001
}
10001002
}
10011003

‎src/driver/postgres/PostgresDriver.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,11 @@ export class PostgresDriver implements Driver {
12181218

12191219
return new Promise((ok, fail) => {
12201220
this.master.connect((err: any, connection: any, release: any) => {
1221-
err ? fail(err) : ok([connection, release])
1221+
if (err) {
1222+
fail(err)
1223+
} else {
1224+
ok([connection, release])
1225+
}
12221226
})
12231227
})
12241228
}
@@ -1238,7 +1242,11 @@ export class PostgresDriver implements Driver {
12381242
return new Promise((ok, fail) => {
12391243
this.slaves[random].connect(
12401244
(err: any, connection: any, release: any) => {
1241-
err ? fail(err) : ok([connection, release])
1245+
if (err) {
1246+
fail(err)
1247+
} else {
1248+
ok([connection, release])
1249+
}
12421250
},
12431251
)
12441252
})
@@ -1569,14 +1577,17 @@ export class PostgresDriver implements Driver {
15691577

15701578
if (options.logNotifications) {
15711579
connection.on("notice", (msg: any) => {
1572-
msg && this.connection.logger.log("info", msg.message)
1580+
if (msg) {
1581+
this.connection.logger.log("info", msg.message)
1582+
}
15731583
})
15741584
connection.on("notification", (msg: any) => {
1575-
msg &&
1585+
if (msg) {
15761586
this.connection.logger.log(
15771587
"info",
15781588
`Received NOTIFY on channel ${msg.channel}: ${msg.payload}.`,
15791589
)
1590+
}
15801591
})
15811592
}
15821593
release()

‎src/entity-manager/EntityManager.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ export class EntityManager {
971971
/**
972972
* Checks whether any entity exists with the given options.
973973
*/
974-
exists<Entity extends ObjectLiteral>(
974+
async exists<Entity extends ObjectLiteral>(
975975
entityClass: EntityTarget<Entity>,
976976
options?: FindManyOptions<Entity>,
977977
): Promise<boolean> {
@@ -1002,7 +1002,7 @@ export class EntityManager {
10021002
* Counts entities that match given options.
10031003
* Useful for pagination.
10041004
*/
1005-
count<Entity extends ObjectLiteral>(
1005+
async count<Entity extends ObjectLiteral>(
10061006
entityClass: EntityTarget<Entity>,
10071007
options?: FindManyOptions<Entity>,
10081008
): Promise<number> {
@@ -1020,7 +1020,7 @@ export class EntityManager {
10201020
* Counts entities that match given conditions.
10211021
* Useful for pagination.
10221022
*/
1023-
countBy<Entity extends ObjectLiteral>(
1023+
async countBy<Entity extends ObjectLiteral>(
10241024
entityClass: EntityTarget<Entity>,
10251025
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
10261026
): Promise<number> {
@@ -1144,7 +1144,7 @@ export class EntityManager {
11441144
* Also counts all entities that match given conditions,
11451145
* but ignores pagination settings (from and take options).
11461146
*/
1147-
findAndCount<Entity extends ObjectLiteral>(
1147+
async findAndCount<Entity extends ObjectLiteral>(
11481148
entityClass: EntityTarget<Entity>,
11491149
options?: FindManyOptions<Entity>,
11501150
): Promise<[Entity[], number]> {
@@ -1163,7 +1163,7 @@ export class EntityManager {
11631163
* Also counts all entities that match given conditions,
11641164
* but ignores pagination settings (from and take options).
11651165
*/
1166-
findAndCountBy<Entity extends ObjectLiteral>(
1166+
async findAndCountBy<Entity extends ObjectLiteral>(
11671167
entityClass: EntityTarget<Entity>,
11681168
where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[],
11691169
): Promise<[Entity[], number]> {

0 commit comments

Comments
 (0)