typeorm/typeorm
### [`v0.3.6`](https://togithub.com/typeorm/typeorm/releases/tag/0.3.6)
[Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.5...0.3.6)
##### Features
- add `for_key_share` ("FOR KEY SHARE") lock mode for postgres driver ([#8879](https://togithub.com/typeorm/typeorm/issues/8879)) ([4687be8](https://togithub.com/typeorm/typeorm/commit/4687be8b77b0f807b2fe4b1e2278e05d0dbd4431)), closes [#8878](https://togithub.com/typeorm/typeorm/issues/8878)
- new driver: Cloud Spanner ([#8730](https://togithub.com/typeorm/typeorm/issues/8730)) ([62518ae](https://togithub.com/typeorm/typeorm/commit/62518ae1226f22b2f230afa615532c92f1544f01))
### [`v0.3.5`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#035-httpsgithubcomtypeormtypeormcompare034035-2022-04-05)
[Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.4...0.3.5)
##### Bug Fixes
- `.save` repository method not returning generated uuids for aurora-postgres ([#8825](https://togithub.com/typeorm/typeorm/issues/8825)) ([ed06f4c](https://togithub.com/typeorm/typeorm/commit/ed06f4c1f1056837f03a97a25762742a12620a94))
- allow hstore type to use transformers in driver postgres ([#8823](https://togithub.com/typeorm/typeorm/issues/8823)) ([b1a0107](https://togithub.com/typeorm/typeorm/commit/b1a01074c99b1fee9b2da2c056f5f773367d391b))
- broken shebang parameters of `cli-ts-node-commonjs` and `cli-ts-node-esm` on some linux distros ([#8821](https://togithub.com/typeorm/typeorm/issues/8821)) ([c5dfc11](https://togithub.com/typeorm/typeorm/commit/c5dfc11ea7b8b33aa9e621b64b953c1d62a27989)), closes [#8818](https://togithub.com/typeorm/typeorm/issues/8818)
- find select object api should support false values [#8796](https://togithub.com/typeorm/typeorm/issues/8796) ([#8807](https://togithub.com/typeorm/typeorm/issues/8807)) ([9ac8e9e](https://togithub.com/typeorm/typeorm/commit/9ac8e9ed0da0ac5bba71b76ee99d6f0c4eb0871f))
- resolve missing ConnectionOptions export in index.ts ([#8850](https://togithub.com/typeorm/typeorm/issues/8850)) ([1693a17](https://togithub.com/typeorm/typeorm/commit/1693a17011195c353e5bc1d93d9c26ac48624a0b)), closes [#8837](https://togithub.com/typeorm/typeorm/issues/8837)
- save correct discriminator with STI ([#8819](https://togithub.com/typeorm/typeorm/issues/8819)) ([9d1e246](https://togithub.com/typeorm/typeorm/commit/9d1e2460edae9c01f6a56c727f0321b265f78d89)), closes [#2927](https://togithub.com/typeorm/typeorm/issues/2927)
- Update DeepPartial for usage of generics with Repository class ([#8817](https://togithub.com/typeorm/typeorm/issues/8817)) ([8ba742e](https://togithub.com/typeorm/typeorm/commit/8ba742eb36586a21a918ed178208874a53ace3f9))
- fixed issue with `typeorm init` command ([#8820](https://togithub.com/typeorm/typeorm/issues/8820))
### [`v0.3.4`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#034-httpsgithubcomtypeormtypeormcompare033034-2022-03-26)
[Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.3...0.3.4)
##### Bug Fixes
- BaseEntity.reload method regression and made `findOne` to throw error on missing conditions in runtime ([#8801](https://togithub.com/typeorm/typeorm/issues/8801)) ([ee8c1ec](https://togithub.com/typeorm/typeorm/commit/ee8c1ecbc210adcc685d6156a941004b9d724227))
- improve DeepPartial recursion ([#8732](https://togithub.com/typeorm/typeorm/issues/8732)) ([0494008](https://togithub.com/typeorm/typeorm/commit/0494008b703240bf593c6f8f2c601cb0d6761805)), closes [#8681](https://togithub.com/typeorm/typeorm/issues/8681)
- missing timestamp in created migrations filenames ([#8802](https://togithub.com/typeorm/typeorm/issues/8802)) ([ceee439](https://togithub.com/typeorm/typeorm/commit/ceee4396d31da1a7dde53cb50689f53659c8a4b1))
- PoolConnection leaked by MysqlDriver ([#8803](https://togithub.com/typeorm/typeorm/issues/8803)) ([d2cfd22](https://togithub.com/typeorm/typeorm/commit/d2cfd224cacb5db9761aa9679764d699b8abbc65))
- remove console.log calls from SelectQueryBuilder ([#8795](https://togithub.com/typeorm/typeorm/issues/8795)) ([54c7db4](https://togithub.com/typeorm/typeorm/commit/54c7db49355bb09514b6e977d1d7235c02557a0b)), closes [#8792](https://togithub.com/typeorm/typeorm/issues/8792)
- stop crashing when redis is offline and ignoreErrors on cache options is set ([#8725](https://togithub.com/typeorm/typeorm/issues/8725)) ([edc39d1](https://togithub.com/typeorm/typeorm/commit/edc39d14a97d90c534b56693b988a0ad139e69fd))
##### Features
- add support for insert with alias ([#4003](https://togithub.com/typeorm/typeorm/issues/4003)) ([#8791](https://togithub.com/typeorm/typeorm/issues/8791)) ([4b37030](https://togithub.com/typeorm/typeorm/commit/4b37030fc02878a27b0d57d4217b2efab49999af))
- applicationName parameter for CockroachDB ([#8800](https://togithub.com/typeorm/typeorm/issues/8800)) ([79b7f5c](https://togithub.com/typeorm/typeorm/commit/79b7f5c22840992e205d61f6433916aaf80ea647))
### [`v0.3.3`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#033-httpsgithubcomtypeormtypeormcompare032033-2022-03-23)
[Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.2...0.3.3)
##### Bug Fixes
- improve initialization of custom repository ([#8782](https://togithub.com/typeorm/typeorm/issues/8782)) ([52a641c](https://togithub.com/typeorm/typeorm/commit/52a641ca7ce8e4b168155b5043d1e9289c694fc7))
- resolve entities correctly in datasource when globs are specified ([#8778](https://togithub.com/typeorm/typeorm/issues/8778)) ([a641c5d](https://togithub.com/typeorm/typeorm/commit/a641c5dff86df683b84e14873e88011013258f87))
##### Features
- support for Common Table Expressions ([#8534](https://togithub.com/typeorm/typeorm/issues/8534)) ([7cc1848](https://togithub.com/typeorm/typeorm/commit/7cc1848fd4a44aefa986026ee659ed872ea6ab8f)), closes [#1116](https://togithub.com/typeorm/typeorm/issues/1116) [#5899](https://togithub.com/typeorm/typeorm/issues/5899) [#4753](https://togithub.com/typeorm/typeorm/issues/4753)
### [`v0.3.2`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#032-httpsgithubcomtypeormtypeormcompare031032-2022-03-22)
[Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.1...0.3.2)
##### Bug Fixes
- broken CLI in ESM projects since version 0.3.0 ([#8773](https://togithub.com/typeorm/typeorm/issues/8773)) ([97699e8](https://togithub.com/typeorm/typeorm/commit/97699e816e03867efe595f620ceb152af91f9f56))
##### Features
- add typeorm CLI variations that include `ts-node` ([#8776](https://togithub.com/typeorm/typeorm/issues/8776)) ([05fc744](https://togithub.com/typeorm/typeorm/commit/05fc74446988d100052f46e2dbf61c6cc2999b99))
- allows user to specify which mysql package should be used ([#8771](https://togithub.com/typeorm/typeorm/issues/8771)) ([35106df](https://togithub.com/typeorm/typeorm/commit/35106dfe78a92783abca7d06307ab9106ae536bc))
##### Reverts
- json/jsonb change introduced in 0.3.1 ([#8777](https://togithub.com/typeorm/typeorm/issues/8777)) ([edf27d9](https://togithub.com/typeorm/typeorm/commit/edf27d97a30d1aaf28e5c7a7aab96d16152e4983))
### [`v0.3.1`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#031-httpsgithubcomtypeormtypeormcompare030031-2022-03-21)
[Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.0...0.3.1)
##### Bug Fixes
- bugfixes introduced in 0.3.0 ([#8764](https://togithub.com/typeorm/typeorm/issues/8764)) ([d61f857](https://togithub.com/typeorm/typeorm/commit/d61f857ce9447a25d074810759fd5c4aad9a08e3)), closes [#8762](https://togithub.com/typeorm/typeorm/issues/8762) [#8759](https://togithub.com/typeorm/typeorm/issues/8759) [#8758](https://togithub.com/typeorm/typeorm/issues/8758) [#8757](https://togithub.com/typeorm/typeorm/issues/8757)
##### Features
- new array find operators (`ArrayContains`, `ArrayContainedBy`, `ArrayOverlap`) ([#8766](https://togithub.com/typeorm/typeorm/issues/8766)) ([9f1b8e3](https://togithub.com/typeorm/typeorm/commit/9f1b8e3425739a871c2d0ad84ddd6e7456117f7f)):
##### BREAKING CHANGES
- we do not call JSON.stringify() to json/jsonb column types in Postgres. Instead, we delegate value directly to underlying pg driver. This is a correct way of handling jsons.
- array: true must be explicitly defined for array json/jsonb values
- strings being JSON-stringified must be manually escaped
### [`v0.3.0`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#030-httpsgithubcomtypeormtypeormpull8616-2022-03-17)
[Compare Source](https://togithub.com/typeorm/typeorm/compare/0.2.45...0.3.0)
Changes in the version includes changes from the `next` branch and `typeorm@next` version.
They were pending their migration from 2018. Finally, they are in the master branch and master version.
##### Features
- compilation `target` now is `es2020`. This requires Node.JS version `14+`
- TypeORM now properly works when installed within different node_modules contexts
(often happen if TypeORM is a dependency of another library or TypeORM is heavily used in monorepo projects)
- `Connection` was renamed to `DataSource`.
Old `Connection` is still there, but now it's deprecated. It will be completely removed in next version.
New API:
```ts
export const dataSource = new DataSource({
// ... options ...
})
// load entities, establish db connection, sync schema, etc.
await dataSource.connect()
```
Previously, you could use `new Connection()`, `createConnection()`, `getConnectionManager().create()`, etc.
They all deprecated in favour of new syntax you can see above.
New way gives you more flexibility and simplicity in usage.
- new custom repositories syntax:
```ts
export const UserRepository = myDataSource.getRepository(UserEntity).extend({
findUsersWithPhotos() {
return this.find({
relations: {
photos: true
}
})
}
})
```
Old ways of custom repository creation were dropped.
- added new option on relation load strategy called `relationLoadStrategy`.
Relation load strategy is used on entity load and determines how relations must be loaded when you query entities and their relations from the database.
Used on `find*` methods and `QueryBuilder`. Value can be set to `join` or `query`.
- `join` - loads relations using SQL `JOIN` expression
- `query` - executes separate SQL queries for each relation
Default is `join`, but default can be set in `ConnectionOptions`:
```ts
createConnection({
/* ... */
relationLoadStrategy: "query"
})
```
Also, it can be set per-query in `find*` methods:
```ts
userRepository.find({
relations: {
photos: true
}
})
```
And QueryBuilder:
```ts
userRepository
.createQueryBuilder()
.setRelationLoadStrategy("query")
```
For queries returning big amount of data, we recommend to use `query` strategy,
because it can be a more performant approach to query relations.
- added new `findOneBy`, `findOneByOrFail`, `findBy`, `countBy`, `findAndCountBy` methods to `BaseEntity`, `EntityManager` and `Repository`:
```ts
const users = await userRepository.findBy({
name: "Michael"
})
```
Overall `find*` and `count*` method signatures where changed, read the "breaking changes" section for more info.
- new `select` type signature in `FindOptions` (used in `find*` methods):
```ts
userRepository.find({
select: {
id: true,
firstName: true,
lastName: true,
}
})
```
Also, now it's possible to specify select columns of the loaded relations:
```ts
userRepository.find({
select: {
id: true,
firstName: true,
lastName: true,
photo: {
id: true,
filename: true,
album: {
id: true,
name: true,
}
}
}
})
```
- new `relations` type signature in `FindOptions` (used in `find*` methods):
```ts
userRepository.find({
relations: {
contacts: true,
photos: true,
}
})
```
To load nested relations use a following signature:
```ts
userRepository.find({
relations: {
contacts: true,
photos: {
album: true,
},
}
})
```
- new `order` type signature in `FindOptions` (used in `find*` methods):
```ts
userRepository.find({
order: {
id: "ASC"
}
})
```
Now supports nested order by-s:
```ts
userRepository.find({
order: {
photos: {
album: {
name: "ASC"
},
},
}
})
```
- new `where` type signature in `FindOptions` (used in `find*` methods) now allows to build nested statements with conditional relations, for example:
```ts
userRepository.find({
where: {
photos: {
album: {
name: "profile"
}
}
}
})
```
Gives you users who have photos in their "profile" album.
- `FindOperator`-s can be applied for relations in `where` statement, for example:
```ts
userRepository.find({
where: {
photos: MoreThan(10),
}
})
```
Gives you users with more than 10 photos.
- `boolean` can be applied for relations in `where` statement, for example:
```ts
userRepository.find({
where: {
photos: true
}
})
```
##### BREAKING CHANGES
- minimal Node.JS version requirement now is `14+`
- drop `ormconfig` support. `ormconfig` still works if you use deprecated methods,
however we do not recommend using it anymore, because it's support will be completely dropped in `0.4.0`.
If you want to have your connection options defined in a separate file, you can still do it like this:
```ts
import ormconfig from "./ormconfig.json"
const MyDataSource = new DataSource(require("./ormconfig.json"))
```
Or even more type-safe approach with `resolveJsonModule` in `tsconfig.json` enabled:
```ts
import ormconfig from "./ormconfig.json"
const MyDataSource = new DataSource(ormconfig)
```
But we do not recommend use this practice, because from `0.4.0` you'll only be able to specify entities / subscribers / migrations using direct references to entity classes / schemas (see "deprecations" section).
We won't be supporting all `ormconfig` extensions (e.g. `json`, `js`, `ts`, `yaml`, `xml`, `env`).
- support for previously deprecated `migrations:*` commands was removed. Use `migration:*` commands instead.
- all commands were re-worked. Please refer to new CLI documentation.
- `cli` option from `BaseConnectionOptions` (now `BaseDataSourceOptions` options) was removed (since CLI commands were re-worked).
- now migrations are running before schema synchronization if you have both pending migrations and schema synchronization pending
(it works if you have both `migrationsRun` and `synchronize` enabled in connection options).
- `aurora-data-api` driver now is called `aurora-mysql`
- `aurora-data-api-pg` driver now is called `aurora-postgres`
- `EntityManager.connection` is now `EntityManager.dataSource`
- `Repository` now has a constructor (breaks classes extending Repository with custom constructor)
- `@TransactionRepository`, `@TransactionManager`, `@Transaction` decorators were completely removed. These decorators do the things out of the TypeORM scope.
- Only junction table names shortened.
**MOTIVATION:** We must shorten only table names generated by TypeORM.
It's user responsibility to name tables short if their RDBMS limit table name length
since it won't make sense to have table names as random hashes.
It's really better if user specify custom table name into `@Entity` decorator.
Also, for junction table it's possible to set a custom name using `@JoinTable` decorator.
- `findOne()` signature without parameters was dropped.
If you need a single row from the db you can use a following syntax:
```ts
const [user] = await userRepository.find()
```
This change was made to prevent user confusion.
See [this issue](https://togithub.com/typeorm/typeorm/issues/2500) for details.
- `findOne(id)` signature was dropped. Use following syntax instead:
```ts
const user = await userRepository.findOneBy({
id: id // where id is your column name
})
```
This change was made to provide a more type-safe approach for data querying.
Due to this change you might need to refactor the way you load entities using MongoDB driver.
- `findOne`, `findOneOrFail`, `find`, `count`, `findAndCount` methods now only accept `FindOptions` as parameter, e.g.:
```ts
const users = await userRepository.find({
where: { /* conditions */ },
relations: { /* relations */ }
})
```
To supply `where` conditions directly without `FindOptions` new methods were added:
`findOneBy`, `findOneByOrFail`, `findBy`, `countBy`, `findAndCountBy`. Example:
```ts
const users = await userRepository.findBy({
name: "Michael"
})
```
This change was required to simply current `find*` and `count*` methods typings,
improve type safety and prevent user confusion.
- `findByIds` was deprecated, use `findBy` method instead in conjunction with `In` operator, for example:
```ts
userRepository.findBy({
id: In([1, 2, 3])
})
```
This change was made to provide a more type-safe approach for data querying.
- `findOne` and `QueryBuilder.getOne()` now return `null` instead of `undefined` in the case if it didn't find anything in the database.
Logically it makes more sense to return `null`.
- `findOne` now limits returning rows to 1 at database level.
**NOTE:** `FOR UPDATE` locking does not work with `findOne` in Oracle since `FOR UPDATE` cannot be used with `FETCH NEXT` in a single query.
- `where` in `FindOptions` (e.g. `find({ where: { ... })`) is more sensitive to input criteria now.
- `FindConditions` (`where` in `FindOptions`) was renamed to `FindOptionsWhere`.
- `null` as value in `where` used in `find*` methods is not supported anymore.
Now you must explicitly use `IsNull()` operator.
Before:
```ts
userRepository.find({
where: {
photo: null
}
})
```
After:
```ts
userRepository.find({
where: {
photo: IsNull()
}
})
```
This change was made to make it more transparent on how to add "IS NULL" statement to final SQL,
because before it bring too much confusion for ORM users.
- if you had entity properties of a non-primitive type (except Buffer) defined as columns,
then you won't be able to use it in `find*`'s `where`. Example:
Before for the `@Column(/*...*/) membership: MembershipKind` you could have a query like:
```ts
userRepository.find({
membership: new MembershipKind("premium")
})
```
now, you need to wrap this value into `Equal` operator:
```ts
userRepository.find({
membership: Equal(new MembershipKind("premium"))
})
```
This change is due to type-safety improvement new `where` signature brings.
- `order` in `FindOptions` (used in `find*` methods) doesn't support ordering by relations anymore.
Define relation columns, and order by them instead.
- `where` in `FindOptions` (used in `find*` methods) previously supported `ObjectLiteral` and `string` types.
Now both signatures were removed. ObjectLiteral was removed because it seriously breaks the type safety,
and `string` doesn't make sense in the context of `FindOptions`. Use `QueryBuilder` instead.
- `MongoRepository` and `MongoEntityManager` now use new types called `MongoFindManyOptions` and `MongoFindOneOptions`
for their `find*` methods.
- `primary relation` (e.g. `@ManyToOne(() => User, { primary: true }) user: User`) support is removed.
You still have an ability to use foreign keys as your primary keys,
however now you must explicitly define a column marked as primary.
Example, before:
```ts
@ManyToOne(() => User, { primary: true })
user: User
```
Now:
```ts
@PrimaryColumn()
userId: number
@ManyToOne(() => User)
user: User
```
Primary column name must match the relation name + join column name on related entity.
If related entity has multiple primary keys, and you want to point to multiple primary keys,
you can define multiple primary columns the same way:
```ts
@PrimaryColumn()
userFirstName: string
@PrimaryColumn()
userLastName: string
@ManyToOne(() => User)
user: User
```
This change was required to simplify ORM internals and introduce new features.
- prefix relation id columns contained in embedded entities ([#7432](https://togithub.com/typeorm/typeorm/pull/7432))
- find by Date object in sqlite driver ([#7538](https://togithub.com/typeorm/typeorm/pull/7538))
- issue with non-reliable `new Date(ISOString)` parsing ([#7796](https://togithub.com/typeorm/typeorm/pull/7796))
##### DEPRECATIONS
- all CLI commands do not support `ormconfig` anymore. You must specify a file with data source instance instead.
- `entities`, `migrations`, `subscribers` options inside `DataSourceOptions` accepting `string` directories support is deprecated.
You'll be only able to pass entity references in the future versions.
- all container-related features (`UseContainerOptions`, `ContainedType`, `ContainerInterface`, `defaultContainer`,
`useContainer`, `getFromContainer`) are deprecated.
- EntityManager's `getCustomRepository` used within transactions is deprecated. Use `withRepository` method instead.
- `Connection.isConnected` is deprecated. Use `.isInitialized` instead.
- `select` in `FindOptions` (used in `find*` methods) used as an array of property names is deprecated.
Now you should use a new object-literal notation. Example:
Deprecated way of loading entity relations:
```ts
userRepository.find({
select: ["id", "firstName", "lastName"]
})
```
New way of loading entity relations:
```ts
userRepository.find({
select: {
id: true,
firstName: true,
lastName: true,
}
})
```
This change is due to type-safety improvement new `select` signature brings.
- `relations` in `FindOptions` (used in `find*` methods) used as an array of relation names is deprecated.
Now you should use a new object-literal notation. Example:
Deprecated way of loading entity relations:
```ts
userRepository.find({
relations: ["contacts", "photos", "photos.album"]
})
```
New way of loading entity relations:
```ts
userRepository.find({
relations: {
contacts: true,
photos: {
album: true
}
}
})
```
This change is due to type-safety improvement new `relations` signature brings.
- `join` in `FindOptions` (used in `find*` methods) is deprecated. Use `QueryBuilder` to build queries containing manual joins.
- `Connection`, `ConnectionOptions` are deprecated, new names to use are: `DataSource` and `DataSourceOptions`.
To create the same connection you had before use a new syntax: `new DataSource({ /*...*/ })`.
- `createConnection()`, `createConnections()` are deprecated, since `Connection` is called `DataSource` now, to create a connection and connect to the database
simply do:
```ts
const myDataSource = new DataSource({ /*...*/ })
await myDataSource.connect()
```
- `getConnection()` is deprecated. To have a globally accessible connection, simply export your data source and use it in places you need it:
```ts
export const myDataSource = new DataSource({ /*...*/ })
// now you can use myDataSource anywhere in your application
```
- `getManager()`, `getMongoManager()`, `getSqljsManager()`, `getRepository()`, `getTreeRepository()`, `getMongoRepository()`, `createQueryBuilder()`
are all deprecated now. Use globally accessible data source instead:
```ts
export const myDataSource = new DataSource({ /*...*/ })
export const Manager = myDataSource.manager
export const UserRepository = myDataSource.getRepository(UserEntity)
export const PhotoRepository = myDataSource.getRepository(PhotoEntity)
// ...
```
- `getConnectionManager()` and `ConnectionManager` itself are deprecated - now `Connection` is called `DataSource`,
and each data source can be defined in exported variable. If you want to have a collection
of data sources, just define them in a variable, simply as:
```ts
const dataSource1 = new DataSource({ /*...*/ })
const dataSource2 = new DataSource({ /*...*/ })
const dataSource3 = new DataSource({ /*...*/ })
export const MyDataSources = {
dataSource1,
dataSource2,
dataSource3,
}
```
- `getConnectionOptions()` is deprecated - in next version we are going to implement different mechanism of connection options loading
- `AbstractRepository` is deprecated. Use new way of custom repositories creation.
- `Connection.name` and `BaseConnectionOptions.name` are deprecated. Connections don't need names anymore since we are going to drop all related methods relying on this property.
- all deprecated signatures will be removed in `0.4.0`
##### EXPERIMENTAL FEATURES NOT PORTED FROM NEXT BRANCH
- `observers` - we will consider returning them back with new API in future versions
- `alternative find operators` - using `$any`, `$in`, `$like` and other operators in `where` condition.
Configuration
📅 Schedule: Branch creation - "before 6am" in timezone Asia/Hong_Kong, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled due to failing status checks.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, click this checkbox.
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
0.2.45
->0.3.6
Release Notes
typeorm/typeorm
### [`v0.3.6`](https://togithub.com/typeorm/typeorm/releases/tag/0.3.6) [Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.5...0.3.6) ##### Features - add `for_key_share` ("FOR KEY SHARE") lock mode for postgres driver ([#8879](https://togithub.com/typeorm/typeorm/issues/8879)) ([4687be8](https://togithub.com/typeorm/typeorm/commit/4687be8b77b0f807b2fe4b1e2278e05d0dbd4431)), closes [#8878](https://togithub.com/typeorm/typeorm/issues/8878) - new driver: Cloud Spanner ([#8730](https://togithub.com/typeorm/typeorm/issues/8730)) ([62518ae](https://togithub.com/typeorm/typeorm/commit/62518ae1226f22b2f230afa615532c92f1544f01)) ### [`v0.3.5`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#035-httpsgithubcomtypeormtypeormcompare034035-2022-04-05) [Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.4...0.3.5) ##### Bug Fixes - `.save` repository method not returning generated uuids for aurora-postgres ([#8825](https://togithub.com/typeorm/typeorm/issues/8825)) ([ed06f4c](https://togithub.com/typeorm/typeorm/commit/ed06f4c1f1056837f03a97a25762742a12620a94)) - allow hstore type to use transformers in driver postgres ([#8823](https://togithub.com/typeorm/typeorm/issues/8823)) ([b1a0107](https://togithub.com/typeorm/typeorm/commit/b1a01074c99b1fee9b2da2c056f5f773367d391b)) - broken shebang parameters of `cli-ts-node-commonjs` and `cli-ts-node-esm` on some linux distros ([#8821](https://togithub.com/typeorm/typeorm/issues/8821)) ([c5dfc11](https://togithub.com/typeorm/typeorm/commit/c5dfc11ea7b8b33aa9e621b64b953c1d62a27989)), closes [#8818](https://togithub.com/typeorm/typeorm/issues/8818) - find select object api should support false values [#8796](https://togithub.com/typeorm/typeorm/issues/8796) ([#8807](https://togithub.com/typeorm/typeorm/issues/8807)) ([9ac8e9e](https://togithub.com/typeorm/typeorm/commit/9ac8e9ed0da0ac5bba71b76ee99d6f0c4eb0871f)) - resolve missing ConnectionOptions export in index.ts ([#8850](https://togithub.com/typeorm/typeorm/issues/8850)) ([1693a17](https://togithub.com/typeorm/typeorm/commit/1693a17011195c353e5bc1d93d9c26ac48624a0b)), closes [#8837](https://togithub.com/typeorm/typeorm/issues/8837) - save correct discriminator with STI ([#8819](https://togithub.com/typeorm/typeorm/issues/8819)) ([9d1e246](https://togithub.com/typeorm/typeorm/commit/9d1e2460edae9c01f6a56c727f0321b265f78d89)), closes [#2927](https://togithub.com/typeorm/typeorm/issues/2927) - Update DeepPartial for usage of generics with Repository class ([#8817](https://togithub.com/typeorm/typeorm/issues/8817)) ([8ba742e](https://togithub.com/typeorm/typeorm/commit/8ba742eb36586a21a918ed178208874a53ace3f9)) - fixed issue with `typeorm init` command ([#8820](https://togithub.com/typeorm/typeorm/issues/8820)) ### [`v0.3.4`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#034-httpsgithubcomtypeormtypeormcompare033034-2022-03-26) [Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.3...0.3.4) ##### Bug Fixes - BaseEntity.reload method regression and made `findOne` to throw error on missing conditions in runtime ([#8801](https://togithub.com/typeorm/typeorm/issues/8801)) ([ee8c1ec](https://togithub.com/typeorm/typeorm/commit/ee8c1ecbc210adcc685d6156a941004b9d724227)) - improve DeepPartial recursion ([#8732](https://togithub.com/typeorm/typeorm/issues/8732)) ([0494008](https://togithub.com/typeorm/typeorm/commit/0494008b703240bf593c6f8f2c601cb0d6761805)), closes [#8681](https://togithub.com/typeorm/typeorm/issues/8681) - missing timestamp in created migrations filenames ([#8802](https://togithub.com/typeorm/typeorm/issues/8802)) ([ceee439](https://togithub.com/typeorm/typeorm/commit/ceee4396d31da1a7dde53cb50689f53659c8a4b1)) - PoolConnection leaked by MysqlDriver ([#8803](https://togithub.com/typeorm/typeorm/issues/8803)) ([d2cfd22](https://togithub.com/typeorm/typeorm/commit/d2cfd224cacb5db9761aa9679764d699b8abbc65)) - remove console.log calls from SelectQueryBuilder ([#8795](https://togithub.com/typeorm/typeorm/issues/8795)) ([54c7db4](https://togithub.com/typeorm/typeorm/commit/54c7db49355bb09514b6e977d1d7235c02557a0b)), closes [#8792](https://togithub.com/typeorm/typeorm/issues/8792) - stop crashing when redis is offline and ignoreErrors on cache options is set ([#8725](https://togithub.com/typeorm/typeorm/issues/8725)) ([edc39d1](https://togithub.com/typeorm/typeorm/commit/edc39d14a97d90c534b56693b988a0ad139e69fd)) ##### Features - add support for insert with alias ([#4003](https://togithub.com/typeorm/typeorm/issues/4003)) ([#8791](https://togithub.com/typeorm/typeorm/issues/8791)) ([4b37030](https://togithub.com/typeorm/typeorm/commit/4b37030fc02878a27b0d57d4217b2efab49999af)) - applicationName parameter for CockroachDB ([#8800](https://togithub.com/typeorm/typeorm/issues/8800)) ([79b7f5c](https://togithub.com/typeorm/typeorm/commit/79b7f5c22840992e205d61f6433916aaf80ea647)) ### [`v0.3.3`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#033-httpsgithubcomtypeormtypeormcompare032033-2022-03-23) [Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.2...0.3.3) ##### Bug Fixes - improve initialization of custom repository ([#8782](https://togithub.com/typeorm/typeorm/issues/8782)) ([52a641c](https://togithub.com/typeorm/typeorm/commit/52a641ca7ce8e4b168155b5043d1e9289c694fc7)) - resolve entities correctly in datasource when globs are specified ([#8778](https://togithub.com/typeorm/typeorm/issues/8778)) ([a641c5d](https://togithub.com/typeorm/typeorm/commit/a641c5dff86df683b84e14873e88011013258f87)) ##### Features - support for Common Table Expressions ([#8534](https://togithub.com/typeorm/typeorm/issues/8534)) ([7cc1848](https://togithub.com/typeorm/typeorm/commit/7cc1848fd4a44aefa986026ee659ed872ea6ab8f)), closes [#1116](https://togithub.com/typeorm/typeorm/issues/1116) [#5899](https://togithub.com/typeorm/typeorm/issues/5899) [#4753](https://togithub.com/typeorm/typeorm/issues/4753) ### [`v0.3.2`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#032-httpsgithubcomtypeormtypeormcompare031032-2022-03-22) [Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.1...0.3.2) ##### Bug Fixes - broken CLI in ESM projects since version 0.3.0 ([#8773](https://togithub.com/typeorm/typeorm/issues/8773)) ([97699e8](https://togithub.com/typeorm/typeorm/commit/97699e816e03867efe595f620ceb152af91f9f56)) ##### Features - add typeorm CLI variations that include `ts-node` ([#8776](https://togithub.com/typeorm/typeorm/issues/8776)) ([05fc744](https://togithub.com/typeorm/typeorm/commit/05fc74446988d100052f46e2dbf61c6cc2999b99)) - allows user to specify which mysql package should be used ([#8771](https://togithub.com/typeorm/typeorm/issues/8771)) ([35106df](https://togithub.com/typeorm/typeorm/commit/35106dfe78a92783abca7d06307ab9106ae536bc)) ##### Reverts - json/jsonb change introduced in 0.3.1 ([#8777](https://togithub.com/typeorm/typeorm/issues/8777)) ([edf27d9](https://togithub.com/typeorm/typeorm/commit/edf27d97a30d1aaf28e5c7a7aab96d16152e4983)) ### [`v0.3.1`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#031-httpsgithubcomtypeormtypeormcompare030031-2022-03-21) [Compare Source](https://togithub.com/typeorm/typeorm/compare/0.3.0...0.3.1) ##### Bug Fixes - bugfixes introduced in 0.3.0 ([#8764](https://togithub.com/typeorm/typeorm/issues/8764)) ([d61f857](https://togithub.com/typeorm/typeorm/commit/d61f857ce9447a25d074810759fd5c4aad9a08e3)), closes [#8762](https://togithub.com/typeorm/typeorm/issues/8762) [#8759](https://togithub.com/typeorm/typeorm/issues/8759) [#8758](https://togithub.com/typeorm/typeorm/issues/8758) [#8757](https://togithub.com/typeorm/typeorm/issues/8757) ##### Features - new array find operators (`ArrayContains`, `ArrayContainedBy`, `ArrayOverlap`) ([#8766](https://togithub.com/typeorm/typeorm/issues/8766)) ([9f1b8e3](https://togithub.com/typeorm/typeorm/commit/9f1b8e3425739a871c2d0ad84ddd6e7456117f7f)): ##### BREAKING CHANGES - we do not call JSON.stringify() to json/jsonb column types in Postgres. Instead, we delegate value directly to underlying pg driver. This is a correct way of handling jsons. - array: true must be explicitly defined for array json/jsonb values - strings being JSON-stringified must be manually escaped ### [`v0.3.0`](https://togithub.com/typeorm/typeorm/blob/HEAD/CHANGELOG.md#030-httpsgithubcomtypeormtypeormpull8616-2022-03-17) [Compare Source](https://togithub.com/typeorm/typeorm/compare/0.2.45...0.3.0) Changes in the version includes changes from the `next` branch and `typeorm@next` version. They were pending their migration from 2018. Finally, they are in the master branch and master version. ##### Features - compilation `target` now is `es2020`. This requires Node.JS version `14+` - TypeORM now properly works when installed within different node_modules contexts (often happen if TypeORM is a dependency of another library or TypeORM is heavily used in monorepo projects) - `Connection` was renamed to `DataSource`. Old `Connection` is still there, but now it's deprecated. It will be completely removed in next version. New API: ```ts export const dataSource = new DataSource({ // ... options ... }) // load entities, establish db connection, sync schema, etc. await dataSource.connect() ``` Previously, you could use `new Connection()`, `createConnection()`, `getConnectionManager().create()`, etc. They all deprecated in favour of new syntax you can see above. New way gives you more flexibility and simplicity in usage. - new custom repositories syntax: ```ts export const UserRepository = myDataSource.getRepository(UserEntity).extend({ findUsersWithPhotos() { return this.find({ relations: { photos: true } }) } }) ``` Old ways of custom repository creation were dropped. - added new option on relation load strategy called `relationLoadStrategy`. Relation load strategy is used on entity load and determines how relations must be loaded when you query entities and their relations from the database. Used on `find*` methods and `QueryBuilder`. Value can be set to `join` or `query`. - `join` - loads relations using SQL `JOIN` expression - `query` - executes separate SQL queries for each relation Default is `join`, but default can be set in `ConnectionOptions`: ```ts createConnection({ /* ... */ relationLoadStrategy: "query" }) ``` Also, it can be set per-query in `find*` methods: ```ts userRepository.find({ relations: { photos: true } }) ``` And QueryBuilder: ```ts userRepository .createQueryBuilder() .setRelationLoadStrategy("query") ``` For queries returning big amount of data, we recommend to use `query` strategy, because it can be a more performant approach to query relations. - added new `findOneBy`, `findOneByOrFail`, `findBy`, `countBy`, `findAndCountBy` methods to `BaseEntity`, `EntityManager` and `Repository`: ```ts const users = await userRepository.findBy({ name: "Michael" }) ``` Overall `find*` and `count*` method signatures where changed, read the "breaking changes" section for more info. - new `select` type signature in `FindOptions` (used in `find*` methods): ```ts userRepository.find({ select: { id: true, firstName: true, lastName: true, } }) ``` Also, now it's possible to specify select columns of the loaded relations: ```ts userRepository.find({ select: { id: true, firstName: true, lastName: true, photo: { id: true, filename: true, album: { id: true, name: true, } } } }) ``` - new `relations` type signature in `FindOptions` (used in `find*` methods): ```ts userRepository.find({ relations: { contacts: true, photos: true, } }) ``` To load nested relations use a following signature: ```ts userRepository.find({ relations: { contacts: true, photos: { album: true, }, } }) ``` - new `order` type signature in `FindOptions` (used in `find*` methods): ```ts userRepository.find({ order: { id: "ASC" } }) ``` Now supports nested order by-s: ```ts userRepository.find({ order: { photos: { album: { name: "ASC" }, }, } }) ``` - new `where` type signature in `FindOptions` (used in `find*` methods) now allows to build nested statements with conditional relations, for example: ```ts userRepository.find({ where: { photos: { album: { name: "profile" } } } }) ``` Gives you users who have photos in their "profile" album. - `FindOperator`-s can be applied for relations in `where` statement, for example: ```ts userRepository.find({ where: { photos: MoreThan(10), } }) ``` Gives you users with more than 10 photos. - `boolean` can be applied for relations in `where` statement, for example: ```ts userRepository.find({ where: { photos: true } }) ``` ##### BREAKING CHANGES - minimal Node.JS version requirement now is `14+` - drop `ormconfig` support. `ormconfig` still works if you use deprecated methods, however we do not recommend using it anymore, because it's support will be completely dropped in `0.4.0`. If you want to have your connection options defined in a separate file, you can still do it like this: ```ts import ormconfig from "./ormconfig.json" const MyDataSource = new DataSource(require("./ormconfig.json")) ``` Or even more type-safe approach with `resolveJsonModule` in `tsconfig.json` enabled: ```ts import ormconfig from "./ormconfig.json" const MyDataSource = new DataSource(ormconfig) ``` But we do not recommend use this practice, because from `0.4.0` you'll only be able to specify entities / subscribers / migrations using direct references to entity classes / schemas (see "deprecations" section). We won't be supporting all `ormconfig` extensions (e.g. `json`, `js`, `ts`, `yaml`, `xml`, `env`). - support for previously deprecated `migrations:*` commands was removed. Use `migration:*` commands instead. - all commands were re-worked. Please refer to new CLI documentation. - `cli` option from `BaseConnectionOptions` (now `BaseDataSourceOptions` options) was removed (since CLI commands were re-worked). - now migrations are running before schema synchronization if you have both pending migrations and schema synchronization pending (it works if you have both `migrationsRun` and `synchronize` enabled in connection options). - `aurora-data-api` driver now is called `aurora-mysql` - `aurora-data-api-pg` driver now is called `aurora-postgres` - `EntityManager.connection` is now `EntityManager.dataSource` - `Repository` now has a constructor (breaks classes extending Repository with custom constructor) - `@TransactionRepository`, `@TransactionManager`, `@Transaction` decorators were completely removed. These decorators do the things out of the TypeORM scope. - Only junction table names shortened. **MOTIVATION:** We must shorten only table names generated by TypeORM. It's user responsibility to name tables short if their RDBMS limit table name length since it won't make sense to have table names as random hashes. It's really better if user specify custom table name into `@Entity` decorator. Also, for junction table it's possible to set a custom name using `@JoinTable` decorator. - `findOne()` signature without parameters was dropped. If you need a single row from the db you can use a following syntax: ```ts const [user] = await userRepository.find() ``` This change was made to prevent user confusion. See [this issue](https://togithub.com/typeorm/typeorm/issues/2500) for details. - `findOne(id)` signature was dropped. Use following syntax instead: ```ts const user = await userRepository.findOneBy({ id: id // where id is your column name }) ``` This change was made to provide a more type-safe approach for data querying. Due to this change you might need to refactor the way you load entities using MongoDB driver. - `findOne`, `findOneOrFail`, `find`, `count`, `findAndCount` methods now only accept `FindOptions` as parameter, e.g.: ```ts const users = await userRepository.find({ where: { /* conditions */ }, relations: { /* relations */ } }) ``` To supply `where` conditions directly without `FindOptions` new methods were added: `findOneBy`, `findOneByOrFail`, `findBy`, `countBy`, `findAndCountBy`. Example: ```ts const users = await userRepository.findBy({ name: "Michael" }) ``` This change was required to simply current `find*` and `count*` methods typings, improve type safety and prevent user confusion. - `findByIds` was deprecated, use `findBy` method instead in conjunction with `In` operator, for example: ```ts userRepository.findBy({ id: In([1, 2, 3]) }) ``` This change was made to provide a more type-safe approach for data querying. - `findOne` and `QueryBuilder.getOne()` now return `null` instead of `undefined` in the case if it didn't find anything in the database. Logically it makes more sense to return `null`. - `findOne` now limits returning rows to 1 at database level. **NOTE:** `FOR UPDATE` locking does not work with `findOne` in Oracle since `FOR UPDATE` cannot be used with `FETCH NEXT` in a single query. - `where` in `FindOptions` (e.g. `find({ where: { ... })`) is more sensitive to input criteria now. - `FindConditions` (`where` in `FindOptions`) was renamed to `FindOptionsWhere`. - `null` as value in `where` used in `find*` methods is not supported anymore. Now you must explicitly use `IsNull()` operator. Before: ```ts userRepository.find({ where: { photo: null } }) ``` After: ```ts userRepository.find({ where: { photo: IsNull() } }) ``` This change was made to make it more transparent on how to add "IS NULL" statement to final SQL, because before it bring too much confusion for ORM users. - if you had entity properties of a non-primitive type (except Buffer) defined as columns, then you won't be able to use it in `find*`'s `where`. Example: Before for the `@Column(/*...*/) membership: MembershipKind` you could have a query like: ```ts userRepository.find({ membership: new MembershipKind("premium") }) ``` now, you need to wrap this value into `Equal` operator: ```ts userRepository.find({ membership: Equal(new MembershipKind("premium")) }) ``` This change is due to type-safety improvement new `where` signature brings. - `order` in `FindOptions` (used in `find*` methods) doesn't support ordering by relations anymore. Define relation columns, and order by them instead. - `where` in `FindOptions` (used in `find*` methods) previously supported `ObjectLiteral` and `string` types. Now both signatures were removed. ObjectLiteral was removed because it seriously breaks the type safety, and `string` doesn't make sense in the context of `FindOptions`. Use `QueryBuilder` instead. - `MongoRepository` and `MongoEntityManager` now use new types called `MongoFindManyOptions` and `MongoFindOneOptions` for their `find*` methods. - `primary relation` (e.g. `@ManyToOne(() => User, { primary: true }) user: User`) support is removed. You still have an ability to use foreign keys as your primary keys, however now you must explicitly define a column marked as primary. Example, before: ```ts @ManyToOne(() => User, { primary: true }) user: User ``` Now: ```ts @PrimaryColumn() userId: number @ManyToOne(() => User) user: User ``` Primary column name must match the relation name + join column name on related entity. If related entity has multiple primary keys, and you want to point to multiple primary keys, you can define multiple primary columns the same way: ```ts @PrimaryColumn() userFirstName: string @PrimaryColumn() userLastName: string @ManyToOne(() => User) user: User ``` This change was required to simplify ORM internals and introduce new features. - prefix relation id columns contained in embedded entities ([#7432](https://togithub.com/typeorm/typeorm/pull/7432)) - find by Date object in sqlite driver ([#7538](https://togithub.com/typeorm/typeorm/pull/7538)) - issue with non-reliable `new Date(ISOString)` parsing ([#7796](https://togithub.com/typeorm/typeorm/pull/7796)) ##### DEPRECATIONS - all CLI commands do not support `ormconfig` anymore. You must specify a file with data source instance instead. - `entities`, `migrations`, `subscribers` options inside `DataSourceOptions` accepting `string` directories support is deprecated. You'll be only able to pass entity references in the future versions. - all container-related features (`UseContainerOptions`, `ContainedType`, `ContainerInterface`, `defaultContainer`, `useContainer`, `getFromContainer`) are deprecated. - EntityManager's `getCustomRepository` used within transactions is deprecated. Use `withRepository` method instead. - `Connection.isConnected` is deprecated. Use `.isInitialized` instead. - `select` in `FindOptions` (used in `find*` methods) used as an array of property names is deprecated. Now you should use a new object-literal notation. Example: Deprecated way of loading entity relations: ```ts userRepository.find({ select: ["id", "firstName", "lastName"] }) ``` New way of loading entity relations: ```ts userRepository.find({ select: { id: true, firstName: true, lastName: true, } }) ``` This change is due to type-safety improvement new `select` signature brings. - `relations` in `FindOptions` (used in `find*` methods) used as an array of relation names is deprecated. Now you should use a new object-literal notation. Example: Deprecated way of loading entity relations: ```ts userRepository.find({ relations: ["contacts", "photos", "photos.album"] }) ``` New way of loading entity relations: ```ts userRepository.find({ relations: { contacts: true, photos: { album: true } } }) ``` This change is due to type-safety improvement new `relations` signature brings. - `join` in `FindOptions` (used in `find*` methods) is deprecated. Use `QueryBuilder` to build queries containing manual joins. - `Connection`, `ConnectionOptions` are deprecated, new names to use are: `DataSource` and `DataSourceOptions`. To create the same connection you had before use a new syntax: `new DataSource({ /*...*/ })`. - `createConnection()`, `createConnections()` are deprecated, since `Connection` is called `DataSource` now, to create a connection and connect to the database simply do: ```ts const myDataSource = new DataSource({ /*...*/ }) await myDataSource.connect() ``` - `getConnection()` is deprecated. To have a globally accessible connection, simply export your data source and use it in places you need it: ```ts export const myDataSource = new DataSource({ /*...*/ }) // now you can use myDataSource anywhere in your application ``` - `getManager()`, `getMongoManager()`, `getSqljsManager()`, `getRepository()`, `getTreeRepository()`, `getMongoRepository()`, `createQueryBuilder()` are all deprecated now. Use globally accessible data source instead: ```ts export const myDataSource = new DataSource({ /*...*/ }) export const Manager = myDataSource.manager export const UserRepository = myDataSource.getRepository(UserEntity) export const PhotoRepository = myDataSource.getRepository(PhotoEntity) // ... ``` - `getConnectionManager()` and `ConnectionManager` itself are deprecated - now `Connection` is called `DataSource`, and each data source can be defined in exported variable. If you want to have a collection of data sources, just define them in a variable, simply as: ```ts const dataSource1 = new DataSource({ /*...*/ }) const dataSource2 = new DataSource({ /*...*/ }) const dataSource3 = new DataSource({ /*...*/ }) export const MyDataSources = { dataSource1, dataSource2, dataSource3, } ``` - `getConnectionOptions()` is deprecated - in next version we are going to implement different mechanism of connection options loading - `AbstractRepository` is deprecated. Use new way of custom repositories creation. - `Connection.name` and `BaseConnectionOptions.name` are deprecated. Connections don't need names anymore since we are going to drop all related methods relying on this property. - all deprecated signatures will be removed in `0.4.0` ##### EXPERIMENTAL FEATURES NOT PORTED FROM NEXT BRANCH - `observers` - we will consider returning them back with new API in future versions - `alternative find operators` - using `$any`, `$in`, `$like` and other operators in `where` condition.Configuration
📅 Schedule: Branch creation - "before 6am" in timezone Asia/Hong_Kong, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled due to failing status checks.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.