Skip to content

Commit 38db77b

Browse files
Merge branch 'master' into patch-1
2 parents fd17325 + 7bea198 commit 38db77b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1908
-350
lines changed

.github/workflows/coverage.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: coverage
2+
3+
on:
4+
workflow_call
5+
6+
jobs:
7+
coverage:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Coveralls Finished
11+
uses: coverallsapp/github-action@v2
12+
with:
13+
parallel-finished: true

.github/workflows/database-compose-tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99

1010
jobs:
1111
oracle:
12+
# For some reason nyc is stuck at the end of the test execution even if all tests pass
13+
# Probably that's why the job failed on CircleCI
14+
if: ${{inputs.node-version != '16.x'}}
1215
runs-on: ubuntu-latest
1316
strategy:
1417
fail-fast: false
@@ -21,4 +24,9 @@ jobs:
2124
- run: docker compose -f .github/workflows/test/oracle.docker-compose up -d
2225
- run: npm i
2326
- run: cp .github/workflows/test/oracle.ormconfig.json ormconfig.json
24-
- run: npm test
27+
- run: npx nyc npm run test
28+
- name: Coveralls Parallel
29+
uses: coverallsapp/github-action@v2
30+
with:
31+
flag-name: oracle-${{ inputs.node-version }}
32+
parallel: true

.github/workflows/database-tests.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ jobs:
2525
- run: npm i
2626
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
2727
- run: cp .github/workflows/test/cockroachdb.ormconfig.json ormconfig.json
28-
- run: npm test
28+
- run: npx nyc npm run test
29+
- name: Coveralls Parallel
30+
uses: coverallsapp/github-action@v2
31+
with:
32+
flag-name: crdb-${{ inputs.node-container }}
33+
parallel: true
2934

3035
mongodb:
3136
runs-on: ubuntu-latest
@@ -42,7 +47,12 @@ jobs:
4247
- run: npm i
4348
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
4449
- run: cp .github/workflows/test/mongodb.ormconfig.json ormconfig.json
45-
- run: npm test
50+
- run: npx nyc npm run test
51+
- name: Coveralls Parallel
52+
uses: coverallsapp/github-action@v2
53+
with:
54+
flag-name: mongodb-${{ inputs.node-container }}
55+
parallel: true
4656

4757

4858
mssql:
@@ -67,6 +77,12 @@ jobs:
6777
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
6878
- run: cp .github/workflows/test/mssql.ormconfig.json ormconfig.json
6979
- run: npm test
80+
- run: npx nyc npm run test
81+
- name: Coveralls Parallel
82+
uses: coverallsapp/github-action@v2
83+
with:
84+
flag-name: mssql-${{ inputs.node-container }}
85+
parallel: true
7086

7187

7288
mysql_mariadb:
@@ -96,7 +112,12 @@ jobs:
96112
- run: npm i
97113
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
98114
- run: cp .github/workflows/test/mysql-mariadb.ormconfig.json ormconfig.json
99-
- run: npm test
115+
- run: npx nyc npm run test
116+
- name: Coveralls Parallel
117+
uses: coverallsapp/github-action@v2
118+
with:
119+
flag-name: mysql+mariadb-${{ inputs.node-container }}
120+
parallel: true
100121

101122

102123
better-sqlite3:
@@ -112,7 +133,12 @@ jobs:
112133
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
113134
- run: chown -R 1001:127 ./temp #This fix is needed for fixing permission error on Node 16
114135
- run: cp .github/workflows/test/better-sqlite3.ormconfig.json ormconfig.json
115-
- run: npm test
136+
- run: npx nyc npm run test
137+
- name: Coveralls Parallel
138+
uses: coverallsapp/github-action@v2
139+
with:
140+
flag-name: better-sqlite3-${{ inputs.node-container }}
141+
parallel: true
116142

117143

118144
sqlite:
@@ -128,7 +154,12 @@ jobs:
128154
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
129155
- run: chown -R 1001:127 ./temp #This fix is needed for fixing permission error on Node 16
130156
- run: cp .github/workflows/test/sqlite.ormconfig.json ormconfig.json
131-
- run: npm test
157+
- run: npx nyc npm run test
158+
- name: Coveralls Parallel
159+
uses: coverallsapp/github-action@v2
160+
with:
161+
flag-name: sqlite-${{ inputs.node-container }}
162+
parallel: true
132163

133164

134165
sqljs:
@@ -143,7 +174,12 @@ jobs:
143174
- run: npm i
144175
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
145176
- run: cp .github/workflows/test/sqljs.ormconfig.json ormconfig.json
146-
- run: npm test
177+
- run: npx nyc npm run test
178+
- name: Coveralls Parallel
179+
uses: coverallsapp/github-action@v2
180+
with:
181+
flag-name: sqljs-${{ inputs.node-container }}
182+
parallel: true
147183

148184

149185
postgres:
@@ -170,4 +206,9 @@ jobs:
170206
- run: npm i
171207
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
172208
- run: cp .github/workflows/test/postgres.ormconfig.json ormconfig.json
173-
- run: npm test
209+
- run: npx nyc npm run test
210+
- name: Coveralls Parallel
211+
uses: coverallsapp/github-action@v2
212+
with:
213+
flag-name: postgres-${{ inputs.node-container }}
214+
parallel: true

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ jobs:
4747
uses: ./.github/workflows/database-compose-tests.yml
4848
with:
4949
node-version: ${{matrix.node-version}}
50+
51+
# Run with most databases possible to provide the coverage of the tests
52+
coverage:
53+
if: ${{ always() }}
54+
needs: [database-tests, database-compose-tests]
55+
uses: ./.github/workflows/coverage.yml

.nycrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"all": true,
3+
"cache": false,
4+
"exclude": [
5+
"**/*.d.ts"
6+
],
7+
"extension": [
8+
".ts"
9+
],
10+
"include": [
11+
"build/compiled/src/**",
12+
"src/**"
13+
],
14+
"reporter": "lcov"
15+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2015-2024 TypeORM. http://typeorm.github.io
3+
Copyright (c) 2015-2025 TypeORM. http://typeorm.github.io
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<a href="https://badge.fury.io/js/typeorm">
1111
<img src="https://badge.fury.io/js/typeorm.svg">
1212
</a>
13-
<a href="https://codecov.io/gh/typeorm/typeorm">
14-
<img alt="Codecov" src="https://img.shields.io/codecov/c/github/typeorm/typeorm.svg">
13+
<a href='https://coveralls.io/github/typeorm/typeorm?branch=master'>
14+
<img src='https://coveralls.io/repos/github/typeorm/typeorm/badge.svg?branch=master' alt='Coverage Status' />
1515
</a>
1616
<br>
1717
<br>
@@ -790,13 +790,7 @@ export class PhotoMetadata {
790790
}
791791
```
792792

793-
Here, we are using a new decorator called `@OneToOne`. It allows us to create a one-to-one relationship between two entities.
794-
`type => Photo` is a function that returns the class of the entity with which we want to make our relationship.
795-
We are forced to use a function that returns a class, instead of using the class directly, because of the language specifics.
796-
We can also write it as `() => Photo`, but we use `type => Photo` as a convention to increase code readability.
797-
The type variable itself does not contain anything.
798-
799-
We also add a `@JoinColumn` decorator, which indicates that this side of the relationship will own the relationship.
793+
Here, we are using a new decorator called `@OneToOne`. It allows us to create a one-to-one relationship between two entities. We also add a `@JoinColumn` decorator, which indicates that this side of the relationship will own the relationship.
800794
Relations can be unidirectional or bidirectional.
801795
Only one side of relational can be owning.
802796
Using `@JoinColumn` decorator is required on the owner side of the relationship.

docs/data-source-api.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,41 @@ await dataSource.transaction(async (manager) => {
141141

142142
```typescript
143143
const rawData = await dataSource.query(`SELECT * FROM USERS`)
144+
145+
// You can also use parameters to avoid SQL injection
146+
// The syntax differs between the drivers
147+
148+
// aurora-mysql, better-sqlite3, capacitor, cordova,
149+
// expo, mariadb, mysql, nativescript, react-native,
150+
// sap, sqlite, sqljs
151+
const rawData = await dataSource.query(
152+
'SELECT * FROM USERS WHERE name = ? and age = ?',
153+
[ 'John', 24 ]
154+
)
155+
156+
// aurora-postgres, cockroachdb, postgres
157+
const rawData = await dataSource.query(
158+
'SELECT * FROM USERS WHERE name = $1 and age = $2',
159+
['John', 24]
160+
)
161+
162+
// oracle
163+
const rawData = await dataSource.query(
164+
'SELECT * FROM USERS WHERE name = :1 and age = :2',
165+
['John', 24]
166+
)
167+
168+
// spanner
169+
const rawData = await dataSource.query(
170+
'SELECT * FROM USERS WHERE name = @param0 and age = @param1',
171+
[ 'John', 24 ]
172+
)
173+
174+
// mssql
175+
const rawData = await dataSource.query(
176+
'SELECT * FROM USERS WHERE name = @0 and age = @1',
177+
[ 'John', 24 ]
178+
)
144179
```
145180

146181
- `createQueryBuilder` - Creates a query builder, which can be used to build queries.

docs/data-source-options.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Different RDBMS-es have their own specific options.
103103

104104
## `mysql` / `mariadb` data source options
105105

106-
- `url` - Connection url where perform connection to. Please note that other data source options will override parameters set from url.
106+
- `url` - Connection url where the connection is performed. Please note that other data source options will override parameters set from url.
107107

108108
- `host` - Database host.
109109

@@ -164,7 +164,7 @@ Different RDBMS-es have their own specific options.
164164

165165
## `postgres` / `cockroachdb` data source options
166166

167-
- `url` - Connection url where perform connection to. Please note that other data source options will override parameters set from url.
167+
- `url` - Connection url where the connection is performed. Please note that other data source options will override parameters set from url.
168168

169169
- `host` - Database host.
170170

@@ -244,7 +244,7 @@ Different RDBMS-es have their own specific options.
244244
## `mssql` data source options
245245
Based on [tedious](https://tediousjs.github.io/node-mssql/) MSSQL implementation. See [SqlServerConnectionOptions.ts](..\src\driver\sqlserver\SqlServerConnectionOptions.ts) for details on exposed attributes.
246246

247-
- `url` - Connection url where perform connection to. Please note that other data source options will override parameters set from url.
247+
- `url` - Connection url where the connection is performed. Please note that other data source options will override parameters set from url.
248248

249249
- `host` - Database host.
250250

@@ -398,7 +398,7 @@ Based on [tedious](https://tediousjs.github.io/node-mssql/) MSSQL implementation
398398

399399
## `mongodb` data source options
400400

401-
- `url` - Connection url where perform connection to. Please note that other data source options will override parameters set from url.
401+
- `url` - Connection url where the connection is performed. Please note that other data source options will override parameters set from url.
402402

403403
- `host` - Database host.
404404

docs/eager-and-lazy-relations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,6 @@ const categories = await question.categories
142142
```
143143

144144
Note: if you came from other languages (Java, PHP, etc.) and are used to use lazy relations everywhere - be careful.
145-
Those languages aren't asynchronous and lazy loading is achieved different way, that's why you don't work with promises there.
145+
Those languages aren't asynchronous and lazy loading is achieved in a different way, that's why you don't work with promises there.
146146
In JavaScript and Node.JS you have to use promises if you want to have lazy-loaded relations.
147147
This is non-standard technique and considered experimental in TypeORM.

0 commit comments

Comments
 (0)