74 Commits

Author SHA1 Message Date
Piotr Kuczynski
08a9397491
lint: fix offenses for @typescript-eslint/no-unused-vars rule in tests folder (#11755) 2025-11-09 21:54:36 +01:00
jeremyteyssedre
1f904675f4
fix(query-builder): handle empty result set when offset exceeds total (#11634)
* fix(query-builder): handle empty result set when offset exceeds total

* fix: lazy count can still be trusted when the result set is empty
2025-09-06 10:36:38 +12:00
Emmanuel Quincerot
5904ac3db2
perf: avoid unnecessary count on getManyAndCount (#11524)
* perf: avoid unnecessary count on getManyAndCount

Skip count query when it can be deduced from the
number of returned rows. This will avoid one round
trip and could be very helpful on pagination when the
limit is not reached.
2025-06-24 09:08:51 +12:00
Lucian Mocanu
01dddfef97
fix: add stricter type-checking and improve event loop handling (#11540)
* refactor: minor type improvements

* chore: add type-checked eslint rules

* fix: enable no-misused-promises

* fix: enable no-floating-promises

* fix: enable await-thenable

* fix: enable require-await

* fix: enable no-misused-new

* refactor: enable no-namespace

* refactor: enable tseslint eslint recommended

* code review
2025-06-22 11:51:29 +02:00
Mike Guida
45577df8b7
test: remove unused type parameter from decorators (#11412)
Remove unused `type` parameter from functions supplied to decorators in tests and sample code. This resolves 477 eslint unused var warnings.

All changes are modifying functions in test or sample code of the following style:

1. `@OneToMany((type) => Entity, ...)` to `@OneToMany(() => Entity)`
2. `@ManyToOne((type) => Entity, ...)`
3. `@ManyToMany((type) => Entity, ...)`
4. `@OneToOne((type) => Entity, ...) `

Note that we don't actually ever call this function with an argument.
2025-04-14 09:25:31 -06:00
Lucian Mocanu
8c2b2ae240
style: lint repository (#11346)
* style: lint uncommon rules

* style: fix `no-wrapper-object-types`

* fix: type errors after Object -> object change

* style: fix `prefer-const`

* build: add eslint/prettier exclusions
2025-03-20 22:15:39 +02:00
jeisberg
83567f5334
fix: composite key save issue (#10672)
* chore(TypeORM): Create test case to uncover TypeORM composite key save issue

* chore(TypeORM): Revert package.json test script alteration

* fix the issue

* fixed regression in 1551

* fixed test to prevent issues with auto increment when inserting rows in a different order

* fixed test to prevent issues with auto increment when inserting rows in a different order

---------

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2024-02-02 13:41:37 +05:00
tqh177
9460296147
fix: convert the join table ID to the referenceColumn ID type (#9887)
* fix: Convert the join table ID to the referenceColumn ID type

* test: add auto-increment-id-as-string test

* style: format auto-increment-id-as-string test
2023-05-09 15:59:06 +05:00
mptr
f6a3ce732d
feat: support for the latest mongodb v5 (#9925)
* fix: add support for mongodb driver v5

This new fix allow support to mongodb driver v5

Closes: #7907

* refactor: remove callback from MongoDriver connect

* fix: check for propertyName in transform

* fix: add support for mongodb driver v5

This new fix allow support to mongodb driver v5

Closes: #7907

* feat: mongodb 5.2.0 typings

* fix: instanceof ObjectId check

Instanceof check now no longer references to just the
type but the loaded class ref instead.

* test: fix test name to mongodb v5

---------

Co-authored-by: Matheus Melo Antiquera <matheusantiquera@finchsolucoes.com.br>
Co-authored-by: tgrassl <grassl.timon@gmail.com>
Co-authored-by: Matheus Melo Antiquera <matheus.melo.a@hotmail.com>
2023-04-15 13:30:01 +05:00
Umed Khudoiberdiev
adce6985d8
Revert "fix: add support for mongodb v4 (#9450)" (#9762)
This reverts commit 8150525354a7a66e68152ef7bd894ad93266d2af.
2023-02-07 13:08:41 +05:00
Matheus Melo Antiquera
8150525354
fix: add support for mongodb v4 (#9450)
* fix: add support for mongodb driver v4

This new fix allow support to mongodb driver v4

Closes: #7907

* fix: add support for mongodb driver v4
This new fix allow support to mongodb driver v4

Closes: #7907

---------

Co-authored-by: Matheus Melo Antiquera <matheusantiquera@finchsolucoes.com.br>
2023-02-07 12:57:35 +05:00
Umed Khudoiberdiev
48e64e6973 removed logging 2022-08-24 20:01:37 +05:00
Andrew Branch
d924b705e5
fix: support for TypeScript 4.8 (#9106)
* build: Fix build errors in TypeScript 4.8

See https://github.com/microsoft/TypeScript/issues/49461#issuecomment-1154443477

* style: Format

* removed `.js` extension

* removed `.js` extension

* removed `.js` extension

* fixing compiler errors

* fixing compiler errors

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2022-06-28 19:41:15 +05:00
AlexMesser
62518ae122
feat: Cloud Spanner support (#8730)
* working on Cloud Spanner driver implementation

* working on DDL synchronization

* working on DDL synchronization

* fixed failing test

* working on VIEW implementation

* fixed query parameters

* lint

* added transaction support;
added streaming support;

* fixed column types

* fixes after merge

* prettier

* added support for generated columns

* added escaping for distinct alias

* working on generated columns

* changed failing test

* updated tests for Spanner;
bugfixes;

* updated tests for Spanner;
bugfixes;

* updated tests for Spanner;
bugfixes;

* fixed failing test

* fixed failing test

* fixing failing tests

* fixing failing tests

* fixing failing tests

* added support for typeorm-generated uuid;
fixed caching;

* fixing failing tests

* fixing failing tests

* fixing failing tests

* fixing failing tests

* fixing failing tests

* fixing failing tests

* debugging failing test

* debugging failing test

* fixed bug in @PrimaryColumn decorator

* fixed failing tests

* fixed VIEW functionality;
fixed failing tests;

* updated docs
2022-04-12 17:31:57 +05:00
Samuel
b1a01074c9
fix: allow hstore type to use transformers in driver postgres (#8823)
The HSTORE type is the only type bypassing the transformer
column options.
This fix makes the option available to this column type as well.

Co-authored-by: Samuel Roy <sam@pricemetry.com>
2022-03-30 20:28:31 +05:00
Umed Khudoiberdiev
9f1b8e3425
feat: new array find operators (#8766)
* added new array find operators; delegating how json and jsonb are stored directly to underlying driver (breaking)

* array: true must be explicitly defined for array json/jsonb values; strings being JSON-stringified must be manually escpaed
2022-03-21 17:48:32 +05:00
Umed Khudoiberdiev
3b8a031ece
0.3.0 (#8616)
* added find options and new option relationLoadStrategy

* find now returns null instead of undefined; removed primary relations support; bugfixing; added some changes and tests from next branch;

* added typename to connection options; added data loader types, lot of deprecations; new es2020 emit by tsc; new custom repositories syntax

* applied lint fixing

* replaced some instanceof checks

* reverting docker compose image versions

* optimizing imports

* reverting back some instanceof checks to prevent compiler errors

* downgrading es compilation version

* docs: remove "primary" from relation options (#8619)

remove ex-line 26 for being deprecated in 0.3.0:
"* `primary: boolean` - Indicates whether this relation's column will be a primary column or not."

* Revert "reverting back some instanceof checks to prevent compiler errors"

This reverts commit 7bf12a39e2297d097aa2a42989afd0e9e4f49bb0.

* Revert "optimizing imports"

This reverts commit 7588ac14e4f1bf1a82e3b7883134b9c2c8ae5f3f.

* Revert "replaced some instanceof checks"

This reverts commit bfa5a2d706f697ed1c1beb38b4455c0d33121e5a.

* fixing few comments

* removing transaction decorators

* this test is invalid - it's not clear why the hell getTreeRepository will throw an error and it's not clear what kind of error its going to throw

* addded mixed list support in connection options

* trying to fix oracle length issue

* lintfix

* removed shorten usages

* added named entity target support to the connection

* fixing entity target support in relation options via entity schema

* debugging oracle issue

* fixed issue with alias not being shortened in many to many alias cases

* some day we'll have a prettier.

* fixing oracle tests

* fixing oracle failing test

* removed "null" support in where expressions; fixed softDelete and restore incorrect usages

* renamed FindConditions to FindOptionsWhere

* version bump

* docs: update loading relation in find method (v 0.3.0) (#8621)

* docs: update relation definition method

Update the method that allows loading a specific relation inside the find method.
This method is found on the one-to-one-relations page.
Change `const users = await userRepository.find({ relations: ["profile"] });` to `const users = await userRepository.find({ relations: {profile: true});`.

* fix formatting

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>

* docs: change relations option definition (#8620)

* docs: change relations option definition

change line 139 from 
`const users = await connection.getRepository(User).find({ relations: ["profile", "photos", "videos"] });`
to
`const users = await connection.getRepository(User).find({ relations: { profile: true, photos: true, videos: true] });`
to reflect version 0.3.0 changes

* docs: change relations option definition

Rectified a type on line 139
from:
`const users = await connection.getRepository(User).find({ relations: { profile: true, photos: true, videos: true] });`
to
`const users = await connection.getRepository(User).find({ relations: { profile: true, photos: true, videos: true} });`

* formatting

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>

* lint

* improved find options types

* fixed types and removed nonnever because it causes circual issue for some reason

* docs: update entitymanager definition (#8623)

* docs: update entitymanager definition

change the "What is EntityManager?" page to be up-to-date with v 0.3.0

1. line 6 changes from
`You can access the entity manager via 'getManager()' or from 'Connection'.`
to 
`You can access the entity manager via DataSource's manager.`

2. the import on `getManager` in line 10 becomes `Manager` that the user have configured beforehand:
`import {getManager} from "typeorm";`
becomes 
`import {Manager} from "./config/DataSource";`

3.change entityManager definition in line 13:
from
`const entityManager = getManager(); // you can also get it via getConnection().manager`
to
`const entityManager = Manager;`

* docs: update entitymanager definition

changed line 10 from: 
`import {Manager} from "./config/DataSource";`
to
`import {DataSource} from "typeorm";`

and changed line 13 and 14 from: 
`const entityManager = Manager;`
`const user = await entityManager.findOne(User, 1);`
to 
`const myDataSource = new DataSource({ /*...*/ });`
`const user = await myDataSource.manager.findOne(User, 1);`

for a simpler way of describing the origin of DataSource and how it works.

* In return type doesn't seem to work in all cases

* feat: mssql v7 support (#8592)

Adds support for v7 of the mssql library as v6 is EOL. This also makes use of the new toReadableStream method on requests to return a native stream where required.

* fix: prefix relation id columns contained in embedded entities (#6977) (#7432)

* fix: prefix relation id columns contained in embedded entities (#6977)

Searches embedded entity columns for relation ID column if relation column
is in embedded entity. If not found, creates new relation ID with embedded
metadata set to match the relation column.

fixes: #2254
fixes: #3132
fixes: #3226
fixes: #6977

* test: prefix subcounters sub-entity with "sub" to fit in 30 character identifier for oracle

Problem introduced with #6981

* fix: find by Date object in sqlite driver (#7538)

* fix: find by Date object in sqlite driver

In sqlite, Date objects are persisted as UtcDatetimeString.
But a Date object parameter was escaped with .toISOString(), making such queries impossible.
This commit aligns both transforms.
This bug does *not* apply to better-sql where you can only bind numbers, strings, bigints, buffers,
and null.
This is breaking for when the user inserted their dates manually as ISO and relied on this old
maltransformation, after this their find()s by Date won't work anymore.

BREAKING CHANGE: Change Date serialization in selects
Closes: #2286

* add failing test

* fix: find by Date object in sqlite driver (with query builder)

Also consider query builder parameter escaping

* test: add test for 3426

Co-authored-by: James Ward <james@notjam.es>

* manually ported changes from #7796

* updated changelog

* fixes after merge

* new findOne syntax

* new find* syntax

* new find* syntax

* lint

* tsc version bump

* tsc version bump and fixed mongodb issues

* moved date fns into non dev deps

* returned oracledb dep into place

* removed lock files

* returned lock files back

* eslint upgrade

* fixing mongodb issue

* fixing mongodb issue

* test: keep junction aliases short (#8637)

Tests a fix for an issue where junction aliases (e.g. in many-to-many relations)
are not unique because they are too long and thus truncated by the driver.

Closes: #8627
Related to: 76cee41dcf1c146d02715c7f48fed33672d28c67

* fixing mongodb issues

* fixing sqlite test

* fixing sqlite test

* fixing sqlite test

* fixing mongodb test

* fixing entity schema tests

* fixing entity schema tests

* merged latest master

* removed driver instanceof checks

* removed function instanceof checks

* removed Object instanceof checks

* removing instanceof checks...

* fixing instanceof checks

* added InstanceChecker to remove remaining instanceof checks

* fixed failing test

* linting

* fixing failing test

* version bump

* compiler fixes

* Connection type usages replace to DataSource

* updated dev deps

* updated deps, add prettier, removed oracledb due to m1 issue

* chalk downgrade

* fixing failing test

* applied prettier formatting

* replaced eslint to prettier

* okay I think we can call it lint

* fixing linting

* fixed prettier introduced compiler bug

* fixed failing test

* prettier;

* fixed failing test

* alias shortening only for junction tables;
fixed failing tests;

* changed aurora db names and reverted change of junction table name shorten algorithm

* format

* removed platform from docker compose

* made numeric parameters to not use parameters to prevent parameters number limit issue. Also enabled shorten only for junction tables

* fixing test

* fixing returning columns bugs

* fixing test

* fixed returning issue

* fixing merge conflicts

* updating documentation

* working on docs / improving api

* working on docs

* fixed isConnected issue

* re-worked commands

* commenting cli command tests for now

* commenting cli command tests for now

* removed platform

* returned Connection back

* refactor: export tree repository helper methods (#8753)

* Migrated protected tree methods to util class

* Added tree repository extend override

* Ran prettier format

* merge master into 0.3.0

Co-authored-by: Bitcollage <serkan.sipahi@yahoo.de>

* working on documentation

Co-authored-by: Bilel Taktak <47742269+Parsath@users.noreply.github.com>
Co-authored-by: Salah Azzouz <52634440+Salah-Azzouz@users.noreply.github.com>
Co-authored-by: Daniel Hensby <dhensby@users.noreply.github.com>
Co-authored-by: Nebojša Cvetković <nebkat@gmail.com>
Co-authored-by: Philip Waritschlager <philip+github@waritschlager.de>
Co-authored-by: James Ward <james@notjam.es>
Co-authored-by: Felix Gohla <37421906+felix-gohla@users.noreply.github.com>
Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
Co-authored-by: Jimmy Chen <50786287+Q16solver@users.noreply.github.com>
Co-authored-by: Bitcollage <serkan.sipahi@yahoo.de>
2022-03-17 21:01:45 +05:00
Ranjan Purbey
33b2bd7acc
fix: fix entityManager.getId for custom join table (#8676)
getId currently returns undefined for an entity with composite primary
key if primary key columns also foreign keys with lazy relations,
for e.g., in a custom join table. This commit tries to fix that

Closes: #7736 (maybe)
2022-02-26 14:15:38 +05:00
Francesco Ferraioli
f033045dd6
fix: entity to be Partial<Entity> | undefined in UpdateEvent (#7783) 2021-07-09 01:51:00 -04:00
James Ward
7a0f7733f2
test: update test to not use Promise.all in some cases (#7746)
single-connection databases can get out of order which breaks
the insert return code
2021-06-17 00:23:11 -04:00
dimitryvolkov
6be54d46ac
fix: don't transform json(b) column value when computing update changes (#6929)
Co-authored-by: dimitryvolkov <dimitryvolkov>
2021-03-27 09:40:24 +05:00
Emily Marigold Klassen
4dbb10e11f
feat: allow to pass the given table name as string in RelationDecorators (#7448)
* feat(RelationDecorators): allow to pass the given table name as string

* Update EntityMetadataBuilder.ts

added parentheses;

Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>
2021-03-08 23:54:52 +05:00
Johannes Sjoberg
215f106273
fix: Unknown fields are stripped from WHERE clause (issue #3416) (#5603)
* fix: Unknown fields are stripped from WHERE clause (issue #3416)

* update non-exist columns test
2020-05-18 06:19:31 +03:00
Umed Khudoiberdiev
5a2eb30726
feat: create-column, update-column, version-column column kinds now support user specified values (#5867)
* Fixes #3271 - create-column, update-column, version-column column kinds now support user specified values

* removed .only

* create/update/version kind columns now considered as "changed" columns

* removed .only
2020-04-13 06:01:52 +03:00
Kononnable
3e09cb7df5 fixes tests failing when mssql driver is disabled;
removed schema logs from test
2019-05-05 00:04:19 +02:00
Kevin Gravier
699eadcebe Fixed missing semi-colon in test 2019-04-30 10:00:44 -04:00
Kevin Gravier
7d8aaf5ca7 Added more checks to test 2019-04-30 10:00:44 -04:00
Kevin Gravier
fe78813120 Added tests 2019-04-30 10:00:43 -04:00
Umed Khudoiberdiev
ac3bd8817b removed only test 2019-04-26 00:07:24 +05:00
Umed Khudoiberdiev
d531dfb0c4 added test for ekifox issue 2019-04-26 00:05:33 +05:00
Umed Khudoiberdiev
0ae4e3f3af removed function escaping from select query builder 2019-03-09 18:24:00 +05:00
Umed Khudoiberdiev
5d5716f8dc fixing tests 2019-03-09 00:59:39 +05:00
Zotov Dmitry
3bbd65cd00 working on tests;
bugfixes;
2019-02-13 23:23:04 +05:00
Rustam Mamadaminov
47f6a4e92a fix unhandled promise rejection 2019-01-17 12:37:32 +05:00
Rustam Mamadaminov
a1febaa704 add tests 2019-01-15 17:47:56 +05:00
Rustam Mamadaminov
195d9c6feb fixes 2019-01-15 16:28:35 +05:00
Rustam Mamadaminov
05c5173ac5 fixes 2019-01-15 15:31:06 +05:00
Rustam Mamadaminov
aa1d7385d5 Tests for mongodb 2019-01-15 14:57:02 +05:00
Rustam Mamadaminov
4f58a03d81 fixing tests 2018-10-23 12:16:51 +05:00
Rustam Mamadaminov
50c1e0eb33 fixed EOF 2018-10-16 11:49:20 +05:00
Rustam Mamadaminov
241044fb20 fixes 2018-10-15 17:14:34 +05:00
Rustam Mamadaminov
22fb56a6a9 fixing 2018-10-15 15:20:56 +05:00
Rustam Mamadaminov
5f943e4c70 added tests 2018-10-15 14:55:51 +05:00
Umed Khudoiberdiev
4306b36723 fixed mocha test run issue 2018-04-25 11:50:09 +05:00
Umed Khudoiberdiev
1e6883ce28 fixes #2017 2018-04-25 11:06:07 +05:00
Jan Grądzki
f3ce25acfa added test for nested child entities 2018-04-24 16:34:42 +02:00
Umed Khudoiberdiev
3e4098c305 Merge branch 'master' into next
* master:
  skipping test for now to make CI working
  version bump
  fixed bug with partial selections via find options
  version bump
  fixed issue with find options accepting keys as expressions
  Update parameter name to stay consistent
  Update mongodb.md
  add unit test for issue 1685
  Feature to provide custom migration table name
  add tests for issue
  fix connection url parsing
  fixing #1672
  Fix #1656
  check if entity file already exists

# Conflicts:
#	CHANGELOG.md
#	package.json
#	src/decorator/transaction/Transaction.ts
#	src/migration/MigrationExecutor.ts
#	src/query-builder/QueryBuilder.ts
#	src/query-builder/transformer/RawSqlResultsToEntityTransformer.ts
2018-03-09 18:32:47 +05:00
Umed Khudoiberdiev
d46c8b0e6c fixed issue with find options accepting keys as expressions 2018-03-07 13:49:02 +05:00
Umed Khudoiberdiev
e118a8c327 issue #1672 - hydration performance issue 2018-02-28 12:17:25 +05:00
Umed Khudoiberdiev
28ff160a93 fixing failing tests 2017-12-12 20:44:19 +05:00