Skip to content

Commit 8473a84

Browse files
committed
Merge branch 'master' into date_now
2 parents 8c5aa9e + 184f463 commit 8473a84

File tree

380 files changed

+2788
-687
lines changed

Some content is hidden

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

380 files changed

+2788
-687
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish Package to npmjs
2+
on:
3+
release:
4+
types: [published]
5+
workflow_dispatch:
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
id-token: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
# Setup .npmrc file to publish to npm
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: '20.x'
18+
registry-url: 'https://registry.npmjs.org'
19+
- run: npm ci
20+
- run: npm run package
21+
- run: |
22+
cd build/package
23+
npm publish --provenance --access public
24+
env:
25+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
## [0.3.22](https://github.com/typeorm/typeorm/compare/0.3.21...0.3.22) (2025-04-03)
2+
3+
4+
### Bug Fixes
5+
6+
* bulk insert NULL values in Oracle ([#11363](https://github.com/typeorm/typeorm/issues/11363)) ([bcaa0bf](https://github.com/typeorm/typeorm/commit/bcaa0bf0714c271a35e02cd4a512618a5eedccce))
7+
* ensure correct MSSQL parameter conversion in where conditions ([ecae9f5](https://github.com/typeorm/typeorm/commit/ecae9f599066947ad1515bf6e55c2fdfbd3bf3f9)), closes [#11285](https://github.com/typeorm/typeorm/issues/11285)
8+
* export QueryEvent before/after types ([#10688](https://github.com/typeorm/typeorm/issues/10688)) ([03dbc7a](https://github.com/typeorm/typeorm/commit/03dbc7a697f6fae2be77585030245a5877b8b33e))
9+
* FindOptionsSelect to use correct type when property is an object ([#11355](https://github.com/typeorm/typeorm/issues/11355)) ([834e856](https://github.com/typeorm/typeorm/commit/834e85692f8bb0d6edc2bfed601717e57ac7dcb7))
10+
* incorrect table alias in insert orUpdate with Postgres driver ([#11082](https://github.com/typeorm/typeorm/issues/11082)) ([72c6991](https://github.com/typeorm/typeorm/commit/72c6991680b39a39799c005914e16b127c8ab805)), closes [#11077](https://github.com/typeorm/typeorm/issues/11077)
11+
* inverse relation metadata not cyclic ([50a660a](https://github.com/typeorm/typeorm/commit/50a660aecc9d34c3985d4460f05b8ffe52450549))
12+
* remove unnecessary import from JS migration ([#11327](https://github.com/typeorm/typeorm/issues/11327)) ([72145b8](https://github.com/typeorm/typeorm/commit/72145b859d52094f77a043b80f9235955bf6ff01))
13+
* remove unnecessary spaces in message when running non-fake migrations ([#10809](https://github.com/typeorm/typeorm/issues/10809)) ([c3bebdc](https://github.com/typeorm/typeorm/commit/c3bebdcb4e9bd2a501bebec39ec22465ae7a3305))
14+
* **sap:** incorrect handling of simple array/json data type ([#11322](https://github.com/typeorm/typeorm/issues/11322)) ([27b4207](https://github.com/typeorm/typeorm/commit/27b4207c48a391c7bf7013b251f756f48861c496))
15+
* **sap:** normalize deprecated/removed data types in SAP HANA Cloud ([#11356](https://github.com/typeorm/typeorm/issues/11356)) ([460ef02](https://github.com/typeorm/typeorm/commit/460ef023bad9b5333c8ea01d3143a4f1e9128d9e))
16+
* **sap:** pass the configured schema to the db client ([#11321](https://github.com/typeorm/typeorm/issues/11321)) ([04ca83a](https://github.com/typeorm/typeorm/commit/04ca83a72f03f7afcad0e7b7f8c9bf60291a87a9))
17+
* sql escape issues identified by CodeQL ([#11338](https://github.com/typeorm/typeorm/issues/11338)) ([863caf1](https://github.com/typeorm/typeorm/commit/863caf1471e87f18f170492ab8642e51845912ce))
18+
* update mongodb connection options ([#11310](https://github.com/typeorm/typeorm/issues/11310)) ([81bb9d5](https://github.com/typeorm/typeorm/commit/81bb9d53e898f977ccf1ed16f09d1c860303a8f5))
19+
* version detection for Postgres derived variants ([#11375](https://github.com/typeorm/typeorm/issues/11375)) ([3d79786](https://github.com/typeorm/typeorm/commit/3d79786a926f12416755bff1eb340d68577c40ed))
20+
21+
22+
### Features
23+
24+
* **postgres:** support macaddr8 column type ([b0ea913](https://github.com/typeorm/typeorm/commit/b0ea913f4ef903590221dee3699dbd39b6fc9986))
25+
* Send DriverInfo to MongoDB client ([#11214](https://github.com/typeorm/typeorm/issues/11214)) ([a29e047](https://github.com/typeorm/typeorm/commit/a29e04750dffffe76c1646d3b3050499576b5dc3))
26+
* Support Expo SQLite Next ([7b242e1](https://github.com/typeorm/typeorm/commit/7b242e1698e1188c6a0899667c71f16fffe9ddb7))
27+
28+
29+
### Reverts
30+
31+
* Revert "fix: nested transactions issues (#10210)" ([7aa4f3c](https://github.com/typeorm/typeorm/commit/7aa4f3c3e05f5b2ec262b31af32864dc16ef7c82)), closes [#10210](https://github.com/typeorm/typeorm/issues/10210)
32+
33+
34+
135
## [0.3.21](https://github.com/typeorm/typeorm/compare/v0.3.20...v0.3.21) (2025-03-03)
236

337

docs/data-source-options.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ Different RDBMS-es have their own specific options.
162162
- `ssl` - object with SSL parameters or a string containing the name of the SSL profile.
163163
See [SSL options](https://github.com/mysqljs/mysql#ssl-options).
164164

165+
- `enableQueryTimeout` - If a value is specified for maxQueryExecutionTime, in addition to generating a warning log when a
166+
query exceeds this time limit,
167+
the specified maxQueryExecutionTime value is also used as the timeout for the query.
168+
For more information, check https://github.com/mysqljs/mysql?tab=readme-ov-file#timeouts
169+
165170
## `postgres` / `cockroachdb` data source options
166171

167172
- `url` - Connection url where the connection is performed. Please note that other data source options will override parameters set from url.
@@ -242,6 +247,7 @@ Different RDBMS-es have their own specific options.
242247
- `database` - Database name
243248

244249
## `mssql` data source options
250+
245251
Based on [tedious](https://tediousjs.github.io/node-mssql/) MSSQL implementation. See [SqlServerConnectionOptions.ts](..\src\driver\sqlserver\SqlServerConnectionOptions.ts) for details on exposed attributes.
246252

247253
- `url` - Connection url where the connection is performed. Please note that other data source options will override parameters set from url.
@@ -547,10 +553,10 @@ The following TNS connection string will be used in the next explanations:
547553
(SERVER=shared)))
548554
)
549555
```
556+
550557
- `sid` - The System Identifier (SID) identifies a specific database instance. For example, "sales".
551558
- `serviceName` - The Service Name is an identifier of a database service. For example, `sales.us.example.com`.
552559

553-
554560
## Data Source Options example
555561

556562
Here is a small example of data source options for mysql:

docs/decorator-reference.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- [`@Unique`](#unique)
4242
- [`@Check`](#check)
4343
- [`@Exclusion`](#exclusion)
44+
- [`@ForeignKey`](#foreignkey)
4445

4546
## Entity decorators
4647

@@ -963,3 +964,88 @@ export class RoomBooking {
963964
```
964965

965966
> Note: Only PostgreSQL supports exclusion constraints.
967+
968+
#### `@ForeignKey`
969+
970+
This decorator allows you to create a database foreign key for a specific column or columns.
971+
This decorator can be applied to columns or an entity itself.
972+
Use it on a column when an foreign key on a single column is needed
973+
and use it on the entity when a single foreign key on multiple columns is required.
974+
975+
> Note: **Do not use this decorator with relations.** Foreign keys are created automatically for relations
976+
> which you define using [Relation decorators](#relation-decorators) (`@ManyToOne`, `@OneToOne`, etc).
977+
> The `@ForeignKey` decorator should only be used to create foreign keys in the database when you
978+
> don't want to define an equivalent entity relationship.
979+
980+
Examples:
981+
982+
```typescript
983+
@Entity("orders")
984+
@ForeignKey(() => City, ["cityId", "countryCode"], ["id", "countryCode"])
985+
export class Order {
986+
@PrimaryColumn()
987+
id: number
988+
989+
@Column("uuid", { name: "user_uuid" })
990+
@ForeignKey<User>("User", "uuid", { name: "FK_user_uuid" })
991+
userUuid: string
992+
993+
@Column({ length: 2 })
994+
@ForeignKey(() => Country, "code")
995+
countryCode: string
996+
997+
@Column()
998+
@ForeignKey("cities")
999+
cityId: number
1000+
1001+
@Column()
1002+
dispatchCountryCode: string
1003+
1004+
@ManyToOne(() => Country)
1005+
dispatchCountry: Country
1006+
1007+
@Column()
1008+
dispatchCityId: number
1009+
1010+
@ManyToOne(() => City)
1011+
dispatchCity: City
1012+
}
1013+
```
1014+
1015+
```typescript
1016+
@Entity("cities")
1017+
@Unique(["id", "countryCode"])
1018+
export class City {
1019+
@PrimaryColumn()
1020+
id: number
1021+
1022+
@Column({ length: 2 })
1023+
@ForeignKey("countries", { onDelete: "CASCADE", onUpdate: "CASCADE" })
1024+
countryCode: string
1025+
1026+
@Column()
1027+
name: string
1028+
}
1029+
```
1030+
1031+
```typescript
1032+
@Entity("countries")
1033+
export class Country {
1034+
@PrimaryColumn({ length: 2 })
1035+
code: string
1036+
1037+
@Column()
1038+
name: string
1039+
}
1040+
```
1041+
1042+
```typescript
1043+
@Entity("users")
1044+
export class User {
1045+
@PrimaryColumn({ name: "ref" })
1046+
id: number
1047+
1048+
@Column("uuid", { unique: true })
1049+
uuid: string
1050+
}
1051+
```

docs/listeners-and-subscribers.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,15 @@ Excluding `listenTo`, all `EntitySubscriberInterface` methods are passed an even
396396

397397
See each [Event's interface](https://github.com/typeorm/typeorm/tree/master/src/subscriber/event) for additional properties.
398398

399+
Note that `event.entity` may not necessarily contain primary key(s) when `Repository.update()` is used. Only the values provided as the entity partial will be available. In order to make primary keys available in the subscribers, you can explicitly pass primary key value(s) in the partial entity object literal or use `Repository.save()`, which performs re-fetching.
400+
401+
```typescript
402+
await postRepository.update(post.id, { description: "Bacon ipsum dolor amet cow" })
403+
404+
// post.subscriber.ts
405+
afterUpdate(event: UpdateEvent<Post>) {
406+
console.log(event.entity) // outputs { description: 'Bacon ipsum dolor amet cow' }
407+
}
408+
```
409+
399410
**Note:** All database operations in the subscribed event listeners should be performed using the event object's `queryRunner` or `manager` instance.

docs/migrations.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ export class PostRefactoringTIMESTAMP implements MigrationInterface {
260260
Alternatively you can also output your migrations as Javascript files using the `o` (alias for `--outputJs`) flag. This is useful for Javascript only projects in which TypeScript additional packages are not installed. This command, will generate a new migration file `{TIMESTAMP}-PostRefactoring.js` with the following content:
261261

262262
```javascript
263+
/**
264+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
265+
*/
266+
267+
/**
268+
* @class
269+
* @implements {MigrationInterface}
270+
*/
263271
module.exports = class PostRefactoringTIMESTAMP {
264272
async up(queryRunner) {
265273
await queryRunner.query(
@@ -273,6 +281,33 @@ module.exports = class PostRefactoringTIMESTAMP {
273281
)
274282
}
275283
}
284+
285+
```
286+
By default, it generates CommonJS JavaScript code with the `o` (alias for `--outputJs`) flag, but you can also generate ESM code with the `esm` flag. This is useful for Javascript projects that use ESM:
287+
288+
```javascript
289+
/**
290+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
291+
*/
292+
293+
294+
/**
295+
* @class
296+
* @implements {MigrationInterface}
297+
*/
298+
export class PostRefactoringTIMESTAMP {
299+
async up(queryRunner) {
300+
await queryRunner.query(
301+
`ALTER TABLE "post" ALTER COLUMN "title" RENAME TO "name"`,
302+
)
303+
}
304+
305+
async down(queryRunner) {
306+
await queryRunner.query(
307+
`ALTER TABLE "post" ALTER COLUMN "name" RENAME TO "title"`,
308+
)
309+
}
310+
}
276311
```
277312

278313
See, you don't need to write the queries on your own.

docs/separating-entity-definition.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ export const PersonSchema = new EntitySchema({
8585
type: Number,
8686
nullable: false,
8787
},
88+
countryCode: {
89+
type: String,
90+
length: 2,
91+
foreignKey: {
92+
target: "countries", // CountryEntity
93+
inverseSide: "code",
94+
},
95+
},
96+
cityId: {
97+
type: Number,
98+
foreignKey: {
99+
target: "cities", // CityEntity
100+
},
101+
},
88102
},
89103
checks: [
90104
{ expression: `"firstName" <> 'John' AND "lastName" <> 'Doe'` },
@@ -103,6 +117,13 @@ export const PersonSchema = new EntitySchema({
103117
columns: ["firstName", "lastName"],
104118
},
105119
],
120+
foreignKeys: [
121+
{
122+
target: "cities", // CityEntity
123+
columnNames: ["cityId", "countryCode"],
124+
referencedColumnNames: ["id", "countryCode"],
125+
},
126+
],
106127
})
107128
```
108129

extra/typeorm-model-shim.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ exports.Tree = Tree;
267267
}
268268
exports.Index = Index;
269269

270+
/* export */ function ForeignKey() {
271+
return noop
272+
}
273+
exports.ForeignKey = ForeignKey;
274+
270275
/* export */ function Unique() {
271276
return noop
272277
}
@@ -295,4 +300,4 @@ exports.EntityRepository = EntityRepository;
295300
/* export */ function VirtualColumn() {
296301
return noop
297302
}
298-
exports.VirtualColumn = VirtualColumn;
303+
exports.VirtualColumn = VirtualColumn;

0 commit comments

Comments
 (0)