Changelog History
Page 2
-
v0.3.1 Changes
March 21, 2022π Bug Fixes
π Features
π₯ 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 Changes
March 17, 2022π Changes in the version includes changes from the
next
branch andtypeorm@next
version. They were pending their migration from 2018. Finally, they are in the master branch and master version.π Features
compilation
target
now ises2020
. This requires Node.JS version14+
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 toDataSource
. OldConnection
is still there, but now it's deprecated. It will be completely removed in next version. New API:
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:
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 onfind*
methods andQueryBuilder
. Value can be set tojoin
orquery
.join
- loads relations using SQLJOIN
expressionquery
- executes separate SQL queries for each relation
0οΈβ£ Default is
join
, but default can be set inConnectionOptions
:createConnection({ /* ... */ relationLoadStrategy: "query" })
Also, it can be set per-query in
find*
methods:userRepository.find({ relations: { photos: true } })
And QueryBuilder:
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 toBaseEntity
,EntityManager
andRepository
:
const users = await userRepository.findBy({ name: "Michael" })
Overall
find*
andcount*
method signatures where changed, read the "breaking changes" section for more info.- π new
select
type signature inFindOptions
(used infind*
methods):
userRepository.find({ select: { id: true, firstName: true, lastName: true, } })
Also, now it's possible to specify select columns of the loaded relations:
userRepository.find({ select: { id: true, firstName: true, lastName: true, photo: { id: true, filename: true, album: { id: true, name: true, } } } })
- π new
relations
type signature inFindOptions
(used infind*
methods):
userRepository.find({ relations: { contacts: true, photos: true, } })
To load nested relations use a following signature:
userRepository.find({ relations: { contacts: true, photos: { album: true, }, } })
- π new
order
type signature inFindOptions
(used infind*
methods):
userRepository.find({ order: { id: "ASC" } })
π Now supports nested order by-s:
userRepository.find({ order: { photos: { album: { name: "ASC" }, }, } })
- π new
where
type signature inFindOptions
(used infind*
methods) now allows to build nested statements with conditional relations, for example:
userRepository.find({ where: { photos: { album: { name: "profile" } } } })
Gives you users who have photos in their "profile" album.
FindOperator
-s can be applied for relations inwhere
statement, for example:
userRepository.find({ where: { photos: MoreThan(10), } })
Gives you users with more than 10 photos.
boolean
can be applied for relations inwhere
statement, for example:
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 in0.4.0
. If you want to have your connection options defined in a separate file, you can still do it like this:
import ormconfig from "./ormconfig.json" const MyDataSource = new DataSource(require("./ormconfig.json"))
Or even more type-safe approach with
resolveJsonModule
intsconfig.json
enabled: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. Usemigration:*
commands instead.π all commands were re-worked. Please refer to new CLI documentation.
π
cli
option fromBaseConnectionOptions
(nowBaseDataSourceOptions
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
andsynchronize
enabled in connection options).aurora-data-api
driver now is calledaurora-mysql
aurora-data-api-pg
driver now is calledaurora-postgres
EntityManager.connection
is nowEntityManager.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:
const [user] = await userRepository.find()
This change was made to prevent user confusion. π See this issue for details.
findOne(id)
signature was dropped. Use following syntax instead:
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 acceptFindOptions
as parameter, e.g.:
const users = await userRepository.find({ where: { /* conditions */ }, relations: { /* relations */ } })
To supply
where
conditions directly withoutFindOptions
new methods were added:findOneBy
,findOneByOrFail
,findBy
,countBy
,findAndCountBy
. Example:const users = await userRepository.findBy({ name: "Michael" })
This change was required to simply current
find*
andcount*
methods typings, π improve type safety and prevent user confusion.- π
findByIds
was deprecated, usefindBy
method instead in conjunction withIn
operator, for example:
userRepository.findBy({ id: In([1, 2, 3]) })
This change was made to provide a more type-safe approach for data querying.
findOne
andQueryBuilder.getOne()
now returnnull
instead ofundefined
in the case if it didn't find anything in the database. Logically it makes more sense to returnnull
.findOne
now limits returning rows to 1 at database level.
NOTE:
FOR UPDATE
locking does not work withfindOne
in Oracle sinceFOR UPDATE
cannot be used withFETCH NEXT
in a single query.where
inFindOptions
(e.g.find({ where: { ... })
) is more sensitive to input criteria now.FindConditions
(where
inFindOptions
) was renamed toFindOptionsWhere
.π
null
as value inwhere
used infind*
methods is not supported anymore. Now you must explicitly useIsNull()
operator.
Before:
userRepository.find({ where: { photo: null } })
After:
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*
'swhere
. Example:
Before for the
@Column(/*...*/) membership: MembershipKind
you could have a query like:userRepository.find({ membership: new MembershipKind("premium") })
now, you need to wrap this value into
Equal
operator:userRepository.find({ membership: Equal(new MembershipKind("premium")) })
This change is due to type-safety improvement new
where
signature brings.π
order
inFindOptions
(used infind*
methods) doesn't support ordering by relations anymore. Define relation columns, and order by them instead.π
where
inFindOptions
(used infind*
methods) previously supportedObjectLiteral
andstring
types. Now both signatures were removed. ObjectLiteral was removed because it seriously breaks the type safety, andstring
doesn't make sense in the context ofFindOptions
. UseQueryBuilder
instead.MongoRepository
andMongoEntityManager
now use new types calledMongoFindManyOptions
andMongoFindOneOptions
for theirfind*
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:
@ManyToOne(() => User, { primary: true }) user: User
Now:
@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:
@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)
find by Date object in sqlite driver (#7538)
π issue with non-reliable
new Date(ISOString)
parsing (#7796)
π DEPRECATIONS
π all CLI commands do not support
ormconfig
anymore. You must specify a file with data source instance instead.π
entities
,migrations
,subscribers
options insideDataSourceOptions
acceptingstring
directories support is deprecated. You'll be only able to pass entity references in the future versions.0οΈβ£ all container-related features (
UseContainerOptions
,ContainedType
,ContainerInterface
,defaultContainer
, πuseContainer
,getFromContainer
) are deprecated.π EntityManager's
getCustomRepository
used within transactions is deprecated. UsewithRepository
method instead.π
Connection.isConnected
is deprecated. Use.isInitialized
instead.π
select
inFindOptions
(used infind*
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:
userRepository.find({ select: ["id", "firstName", "lastName"] })
π New way of loading entity relations:
userRepository.find({ select: { id: true, firstName: true, lastName: true, } })
This change is due to type-safety improvement new
select
signature brings.- π
relations
inFindOptions
(used infind*
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:
userRepository.find({ relations: ["contacts", "photos", "photos.album"] })
π New way of loading entity relations:
userRepository.find({ relations: { contacts: true, photos: { album: true } } })
This change is due to type-safety improvement new
relations
signature brings.π
join
inFindOptions
(used infind*
methods) is deprecated. UseQueryBuilder
to build queries containing manual joins.π
Connection
,ConnectionOptions
are deprecated, new names to use are:DataSource
andDataSourceOptions
. To create the same connection you had before use a new syntax:new DataSource({ /*...*/ })
.π
createConnection()
,createConnections()
are deprecated, sinceConnection
is calledDataSource
now, to create a connection and connect to the database simply do:
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:
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:
export const myDataSource = new DataSource({ /*...*/ }) export const Manager = myDataSource.manager export const UserRepository = myDataSource.getRepository(UserEntity) export const PhotoRepository = myDataSource.getRepository(PhotoEntity) // ...
- π
getConnectionManager()
andConnectionManager
itself are deprecated - nowConnection
is calledDataSource
, 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:
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
andBaseConnectionOptions.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 versionsalternative find operators
- using$any
,$in
,$like
and other operators inwhere
condition.
-
v0.2.45 Changes
March 04, 2022π Bug Fixes
- π allow clearing database inside a transaction (#8712) (f3cfdd2), closes #8527
- β‘οΈ discard duplicated columns on update (#8724) (0fc093d), closes #8723
- π fix entityManager.getId for custom join table (#8676) (33b2bd7), closes #7736
- π» force web bundlers to ignore index.mjs and use the browser ESM version directly (#8710) (411fa54), closes #8709
π Features
-
v0.2.44 Changes
February 23, 2022π Bug Fixes
- alter relation loader to use transforms when present (#8691) (2c2fb29), closes #8690
- cannot read properties of undefined (reading 'joinEagerRelations') (136015b)
- expo driver doesn't work properly because of new beforeMigration() afterMigration() callbacks (#8683) (5a71803)
- 0οΈβ£ ng webpack default import (#8688) (2d3374b), closes #8674
- π support imports of absolute paths of ESM files on Windows (#8669) (12cbfcd), closes #8651
π Features
-
v0.2.43 Changes
February 17, 2022 -
v0.2.42 Changes
February 16, 2022π Bug Fixes
- π proper column comment mapping from database to metadata in aurora-data-api (baa5880)
- β add referencedSchema to PostgresQueryRunner (#8566) (c490319)
- β adding/removing @Generated() will now generate a migration to add/remove the DEFAULT value (#8274) (4208393), closes #5898
- β adds entity-schema support for createForeignKeyConstraints (#8606) (f224f24), closes #8489
- π allow special keyword as column name for simple-enum type on sqlite (#8645) (93bf96e)
- correctly handle multiple-row insert for SAP HANA driver (#7957) (8f2ae71)
- π disable SQLite FK checks in synchronize / migrations (#7922) (f24822e)
- find descendants of a non-existing tree parent (#8557) (cbb61eb), closes #8556
- For MS SQL Server use lowercase "sys"."columns" reference. (#8400) (#8401) (e8a0f92)
- π improve DeepPartial type (#8187) (b93416d)
- π Lock peer dependencies versions (#8597) (600bd4e)
- π make EntityMetadataValidator comply with entitySkipConstructor, cover with test (#8445) (3d6c5da), closes #8444
- materialized path being computed as "undefined1." (#8526) (09f54e0)
- MongoConnectionOptions sslCA type mismatch (#8628) (02400da)
- mongodb repository.find filters soft deleted rows (#8581) (f7c1f7d), closes #7113
- π mongodb@4 compatibility support (#8412) (531013b)
- π must invoke key pragma before any other interaction if SEE setted (#8478) (546b3ed), closes #8475
- nested eager relations in a lazy-loaded entity are not loaded (#8564) (1cfd7b9)
- QueryFailedError when tree entity with JoinColumn (#8443) (#8447) (a11c50d)
- π relation id and afterAll hook performance fixes (#8169) (31f0b55)
- replaced custom uuid generator with
uuid
library (#8642) (8898a71) - single table inheritance returns the same discriminator value error for unrelated tables where their parents extend from the same entity (#8525) (6523fcc), closes #8522
- β‘οΈ updating with only
update: false
columns shouldn't trigger @UpdateDateColumn column updation (2834729), closes #8394 #8394 #8394 - upsert should find unique index created by one-to-one relation (#8618) (c8c00ba)
π Features
- β add comment param to FindOptions (#8545) (ece0da0)
- β add custom timestamp option in migration creation (#8501) (4a7f242), closes #8500 #8500
- β add support for node-redis v4.0.0 and newer (#8425) (0626ed1)
- β add support for Postgres 10+ GENERATED ALWAYS AS IDENTITY (#8371) (a0f09de), closes #8370
- β add WITH (lock) clause for MSSQL select with join queries (#8507) (3284808), closes #4764
- β adds entity-schema support for withoutRowid (#8432) (bd22dc3), closes #8429
- π allow soft-deletion of orphaned relation rows using orphanedRowβ¦ (#8414) (cefddd9)
- π custom name for typeorm_metadata table (#8528) (f8154eb), closes #7266
- deferrable option for Unique constraints (Postgres) (#8356) (e52b26c)
- π ESM support (#8536) (3a694dd), closes #6974 #6941 #7516 #7159
- π query builder negating with "NotBrackets" for complex expressions (#8476) (fe7f328)
- β‘οΈ separate update events into update, soft-remove, and recover (#8403) (93383bd), closes #8398
- soft delete recursive cascade (#8436) (d0f32b3)
- sqlite attach (#8396) (9e844d9)
βͺ Reverts
π₯ BREAKING CHANGES
- β‘οΈ update listeners and subscriber no longer triggered by soft-remove and recover
-
v0.2.41 Changes
November 18, 2021π Bug Fixes
- β add
retryWrites
toMongoConnectionOptions
(#8354) (c895680), closes #7869 - π create typeorm_metadata table when running migrations (#4956) (b2c8168)
- db caching won't work with replication enabled (#7694) (2d0abe7), closes #5919
- incorrect composite
UNIQUE
constraints detection (#8364) (29cb891), closes #8158 - π Postgres enum generates unnecessary queries on schema sync (#8268) (98d5f39)
- β‘οΈ resolve issue delete column null on after update event subscriber (#8318) (8a5e671), closes #6327
π Features
- β add
-
v0.2.40 Changes
November 11, 2021π Bug Fixes
π Features
- β add depth limiter optional parameter when loading nested trees using TreeRepository's findTrees() and findDescendantsTree() (#7926) (0c44629), closes #3909
- β add upsert methods for the drivers that support onUpdate (#8104) (3f98197), closes #2363
- π Postgres IDENTITY Column support (#7741) (969af95)
βͺ Reverts
-
v0.2.39 Changes
November 09, 2021π Bug Fixes
- β‘οΈ attach FOR NO KEY UPDATE lock to query if required (#8008) (9692930), closes #7717
- cli should accept absolute paths for --config (4ad3a61)
- create a different cacheId if present for count query in getManyAndCount (#8283) (9f14e48), closes #4277
- 0οΈβ£ defaults type cast filtering in Cockroachdb (#8144) (28c183e), closes #7110 #7110
- do not generate migration for unchanged enum column (#8161) (#8164) (4638dea)
- NativescriptQueryRunner's query method fails when targeting es2017 (#8182) (8615733)
- OneToManySubjectBuilder bug with multiple primary keys (#8221) (6558295)
- ordering by joined columns for PostgreSQL (#3736) (#8118) (1649882)
- π support DeleteResult in SQLiteDriver (#8237) (b678807)
π Features
- β add
typeorm
command wrapper to package.json in project template (#8081) (19d4a91) - β add dependency configuraiton for views #8240 (#8261) (2c861af)
- β add relation options to all tree queries (#8080) (e4d4636), closes #8076
- β add the ability to pass the driver into all database types (#8259) (2133ffe)
- π² more informative logging in case of migration failure (#8307) (dc6f1c9)
- π support using custom index with SelectQueryBuilder in MySQL (#7755) (f79ae58)
βͺ Reverts
-
v0.2.38 Changes
October 02, 2021