0.3.23
:warning: Note on a breaking change
This release includes a technically breaking change (from this PR) in the behaviour of the delete and update methods of the EntityManager and Repository APIs, when an empty object is supplied as the criteria:
await repository.delete({})
await repository.update({}, { foo: 'bar' })
- Old behaviour was to delete or update all rows in the table
- New behaviour is to throw an error:
Empty criteria(s) are not allowed for the delete/update method.
Why?
This behaviour was not documented and is considered dangerous as it can allow a badly-formed object (e.g. with an undefined id) to inadvertently delete or update the whole table.
When the intention actually was to delete or update all rows, such queries can be rewritten using the QueryBuilder API:
await repository.createQueryBuilder().delete().execute()
// executes: DELETE FROM table_name
await repository.createQueryBuilder().update().set({ foo: 'bar' }).execute()
// executes: UPDATE table_name SET foo = 'bar'
An alternative method for deleting all rows is to use:
await repository.clear()
// executes: TRUNCATE TABLE table_name
What's Changed
- chore: Fix publish command by @michaelbromley in https://github.com/typeorm/typeorm/pull/11379
- build(deps): bump tar-fs from 2.1.1 to 2.1.2 by @dependabot in https://github.com/typeorm/typeorm/pull/11370
- feat: add new foreign key decorator, and entity schemas options by @yevhen-komarov in https://github.com/typeorm/typeorm/pull/11144
- chore: fix changelog generation by @alumni in https://github.com/typeorm/typeorm/pull/11381
- feat: Build ESM migrations for JS by @w3nl in https://github.com/typeorm/typeorm/pull/10802
- docs(entity-subscribers): document primary key availability in UpdateEvent by @jovanadjuric in https://github.com/typeorm/typeorm/pull/11308
- test: remove unused type parameter from decorators by @mguida22 in https://github.com/typeorm/typeorm/pull/11412
- feat: Add query timeout support for MySql by @iliagrvch in https://github.com/typeorm/typeorm/pull/10846
- Chore: Added logging to the Entity Listener Metadata by @JackNytely in https://github.com/typeorm/typeorm/pull/11234
- Propagate
aggregatemethod's generic parameter to its returned cursor by @pringon in https://github.com/typeorm/typeorm/pull/10754 - refactor: define Position type for GeoJSON objects by @knoid in https://github.com/typeorm/typeorm/pull/11259
- perf(query-runner): use Date.now() intead of +new Date() by @Samuron in https://github.com/typeorm/typeorm/pull/10811
- feat: add FormattedConsoleLogger by @w3nl in https://github.com/typeorm/typeorm/pull/11401
- docs: update repository additional chunk option usage example by @knicefire in https://github.com/typeorm/typeorm/pull/11282
- docs: Correct "its" -> "it's" by @mdippery in https://github.com/typeorm/typeorm/pull/11428
- fix: prevent error when replication is undefined by @caiquecastro in https://github.com/typeorm/typeorm/pull/11423
- fix: change how array columns are compared on column changed detection by @mnbaccari in https://github.com/typeorm/typeorm/pull/11269
- build: setup testing matrix for postgres 14 and 17 by @mguida22 in https://github.com/typeorm/typeorm/pull/11433
- fix: beforeQuery promises not awaited before query execution by @TanguyPoly in https://github.com/typeorm/typeorm/pull/11086
- fix(sap): cleanup after streaming by @alumni in https://github.com/typeorm/typeorm/pull/11399
- feat: release PR releases using pkg.pr.new by @naorpeled in https://github.com/typeorm/typeorm/pull/11434
- docs: clarify where to add new tests by @mguida22 in https://github.com/typeorm/typeorm/pull/11438
- fix: update/delete/softDelete by criteria of condition objects by @maxbronnikov10 in https://github.com/typeorm/typeorm/pull/10910
- chore: Version 0.3.23 by @michaelbromley in https://github.com/typeorm/typeorm/pull/11439
New Contributors
- @yevhen-komarov made their first contribution in https://github.com/typeorm/typeorm/pull/11144
- @w3nl made their first contribution in https://github.com/typeorm/typeorm/pull/10802
- @iliagrvch made their first contribution in https://github.com/typeorm/typeorm/pull/10846
- @JackNytely made their first contribution in https://github.com/typeorm/typeorm/pull/11234
- @pringon made their first contribution in https://github.com/typeorm/typeorm/pull/10754
- @knoid made their first contribution in https://github.com/typeorm/typeorm/pull/11259
- @Samuron made their first contribution in https://github.com/typeorm/typeorm/pull/10811
- @knicefire made their first contribution in https://github.com/typeorm/typeorm/pull/11282
- @caiquecastro made their first contribution in https://github.com/typeorm/typeorm/pull/11423
- @mnbaccari made their first contribution in https://github.com/typeorm/typeorm/pull/11269
- @TanguyPoly made their first contribution in https://github.com/typeorm/typeorm/pull/11086
- @maxbronnikov10 made their first contribution in https://github.com/typeorm/typeorm/pull/10910
Full Changelog: https://github.com/typeorm/typeorm/compare/0.3.22...0.3.23