125 Commits

Author SHA1 Message Date
Lucian Mocanu
835647ac92
test: use built-in wait function and fix wait times to avoid flaky tests (#11812) 2025-11-29 10:25:39 +01:00
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
Lucian Mocanu
c16ef63db7
chore: update dependencies (#11666) 2025-09-19 18:34:39 +02:00
Naor Peled
96ea431eb7
feat: add new undefined and null behavior flags (#11332)
- added configurable handling for null/undefined in where clauses (ignore, SQL NULL, or throw) across queries, query builders, and repository/entity-manager methods
2025-09-18 08:41:16 +03: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
Pieter Wigboldus
4c8fc3a7cb
feat: add FormattedConsoleLogger (#11401)
* fix: Build ESM migrations for JS

Including jsdoc for typehinting
Add esm as an option in the migrate cli
Update the documentation for the JS migrations

Closes: #10801

* fix: Fix the migration documentation

* Cleanup the types in the migrations

* Add the formatted sql console

* Add the formatSql to the logger

* Update src/logger/FormattedConsoleLogger.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Make names in test more consistent

* Add a sub query example

* Set the language to the sql formatter

* Import SqlLanguage as a type from sql-formatter

* Remove empty console log

* Remove console log

* Add the dataSourceType

* Remove js extension from import

* Use another package to format the SQL in the logging

Same package as we use to generate the migrations

* Not need to add all the spaces in the log

* Fix the expected formatted queries

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-16 18:55:23 +02:00
Lucian Mocanu
fb06662bea
build: setup SAP HANA tests (#11347)
* build: setup SAP HANA tests

* test: fix/skip failing SAP HANA tests

* fix(sap): rename schema
2025-03-29 22:35:44 +01:00
Lucian Mocanu
6ba408214e
build: improve test workflow (#11361) 2025-03-26 22:10:19 +01: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
Oleg "OSA413" Sokolov
5d6d893662
test: fix and run tests on Windows (#11257)
* Skip tests that don't work on Windows

* Bring back tests on Windows

* Skip the test on all platforms exept Windows

* Make the test run only on Windows

* Add simple winodws test

* fix cli test on Windows

* let's see if this test passes on linux

* limit test to Windows and run format

* Add withPlatform test helper

* Mock platform in file path tests using withPlatform()

* Fix test: relative paths should not change on non-win32 platforms

* Lowercase relative path on non-win32 platform

* test: add better-sqlite3 and sqlite for Windows tests

---------

Co-authored-by: Simon Garner <simon@equalogic.com>
2025-03-14 16:01:46 +05:00
Doug Ayers
ba47b62379
chore(test): set timezone to UTC (#11247)
Fixes #11246

To mitigate timezone discrepancies with timestamps in tests with hard coded assertions, standardize on UTC

Co-authored-by: Mike Guida <mike@mguida.com>
2025-03-12 21:56:33 +05:00
Alexey Pelykh
dd49a254dc
fix: don't escape indexPredicate (#10618)
* fix: don't escape indexPredicate

* style: npm run format
2024-01-26 11:26:12 +05:00
Lucian Mocanu
c22e30f1d2
build: set TS compile target to ES2021 (#10595)
* build: set TS compile target to ES2021

* docs: update minimum supported node version

* build: use @tsconfig/node16
2024-01-04 09:57:12 +05:00
Tait Clarridge
3cda7ec39d
feat: add isolated where statements (#10213)
- Add `isolateWhereStatements` to the `BaseDataSourceOptions` object
  and automatically isolate where statements in the query builder
  if it is true
2024-01-02 11:54:43 +05:00
Rafi Shamim
d184d8598c
test: stop using unsafe CockroachDB setting (#10404)
Disabling the raft log is going to be disallowed in CockroachDB. Also,
this setting wasn't having any effect, since the tests use an in-memory
cluster.
2023-10-05 09:03:51 +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
MURAKAMI Masahiko
e51991076d
fix: don't use temporary table name to create foreign key, unique, check constraint with SQLite (#9185)
* fix: don't use temporary table name to create foreign key, unique, check constraint with SQLite

In migration steps, finally temporary table name is renamed to original table name. these constraints name should be created from original table name not temporary table name.

Closes: #9176

* style: remove unnecessary comment
2022-08-24 21:37:45 +05:00
AlexMesser
0418ebcaf6
feat: fix issues with generated columns and add support in other drivers (#8806)
* added integration with typeorm metadata table for mysql generated columns

* added more tests

* fixed failing tests

* added test case and fix for #8761

* fixed failing tests

* fixed failing tests

* fixing failing tests

* working on postgres implementation

* added test for postgres;
fixes in postgres generated columns;

* working on "gc" implementation in cockroachdb

* added "gc" implementation for sql server

* added "gc" implementation for oracle

* removed unneeded files

* added "gc" implementation for sqlite;
added additional test cases;

* fixed failing test

* fixed failing test

* minor fix in cockroachdb

* added "gc" implementation for spanner

* minor change
2022-04-13 23:50:16 +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
Umed Khudoiberdiev
22d21b0a82 added test util scenario for spanner driver 2022-04-02 20:25:22 +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
matt penrice
9e844d9ff7
feat: sqlite attach (#8396)
* Updated to latest master. Cleans up codestyle, ignores yarn

* re-adds the portable path tests

* mapping bug fix that appears with unrecognised existing tables

* Review comments

* review comments

* test breakage with node 12
2022-02-16 20:29:04 +05:00
Tadas Varanauskas
f8154eb4c5
feat: custom name for typeorm_metadata table (#8528)
This new feature adds a new connection option `metadataTableName`
that allows for renaming of the `typeorm_metadata` table

Closes: #7266

Co-authored-by: Tadas Varanauskas <tadas@bitlocus.com>
2022-01-31 16:52:22 +05:00
Umed Khudoiberdiev
a92120ac88 removed redundant console.log 2021-11-10 20:48:31 +05:00
Umed Khudoiberdiev
0cc8fbb1ce fixed lint issue 2021-11-10 20:29:59 +05:00
Umed Khudoiberdiev
0af0f36224 fixed broken logging enable from ormconfig in tests 2021-11-10 20:20:14 +05:00
Joe Flateau
3f981975d4
feat: add upsert methods for the drivers that support onUpdate (#8104)
* feat: add upsert methods for the drivers that support it

This adds EntityManager#upsert, BaseEntity#upsert and EntityManager#upsert

Closes: #2363

* docs: Document which drivers support upsert operations

* docs: fix typo in entity manager upsert many example

* refactor: remove mongodb style upsert signature, enforce types of conflict paths

* docs: add note to repository docs specifying which drivers support upsert

* refactor: cannot staticly type conflict paths because that would break typescript pre-4

* refactor: remove test utility methods in favor of some repeated checks
2021-11-10 00:09:49 +05:00
MG
4aaafdffe2
build: local development with oracle (#7881) 2021-11-09 14:00:14 +05:00
James Ward
1197f88138
refactor: unwrap promises where possible (#8234) 2021-10-29 13:39:11 -04:00
James Ward
f6019bfe93 test: adds xfail helper to support known failing tests
in cases where we have tests that have been created for existing
issues this can be utilized so that we can confirm the tests
continue to fail - and we can also determine if a different
code change has resolved it
2021-07-27 10:21:19 -04:00
James Ward
8436fdb7e8
refactor: Move tablePath calculation out of the EntityMetadata class (#7856) 2021-07-09 01:50:29 -04:00
Pavlo Mykhailenko
052014cdba
fix: update operation in MongoDB impact all matched documents (#7803)
mongo update operation should update all matched documents, but now it updates the first found document

fixes #7788
2021-06-26 10:18:18 -04:00
James Ward
3d2833d905
test: cockroachdb performance in tests settings (#7772) 2021-06-20 23:55:33 -04:00
James Ward
1b29591880
refactor: drop promise utils (#6746)
* stop using PromiseUtils.create & extractValue as they're doing nothing

because we never use PromiseUtils.create, PromiseUtils.extract was technically
never used either - the only case we were using this was in a test
where we can replace it with Promise.resolve

* stop using PromiseUtils.settle in test 1014

there was no reason to use this call in the test
as it was not using the results and only used the `Promise.all`
functionality

* use Promise.all instead of PromiseUtils.runInSequence in tests

in these cases of PromiseUtils.runInSequence in tests there was no need
for us to be running them in sequence - so instead we could use Promise.all
& Array.map for a replacement.  removes the dependency on PromiseUtils &
also speeds up our tests

* run tests sequentially for those that deal with ActiveRecord

because the activerecord mechanism creates a "global" scope through
the class that ActiveRecord is applied to we have to run through the
connections sequentially or end up with them being all over the place
as far as what activerecord model is connected to what connection

* use standard async/await + for/of instead of runInSequence

in cases where actual order of the runs matter we can do for/of
and then await any of the results - because none of the usages of
runInSequence that rely on the correct order actually use the results

* use Promise.all on runInSequence cases where order doesn't matter

* drop PromiseUtils altogether

* sequentially run when dealing with QueryRunner

queryrunner is not 'thread-safe' or async safe

* drop the test to lookup by Promise

before, the test wasn't validating that you could lookup by promise
the test was verifying that if you used something that wasn't a promise
but instead had a magic __value__ variable you'd get a lookup

that's not a promise, unfortunately

I can't find that a promise may be passed into the find options anywhere
in the documentation so I've removed this test
2020-09-21 15:32:14 +05:00
Ryan Shea
4ef6b65b64
fix: columns with transformer should be normalized for update (#5700)
* fix: columns with transformer should be normalized for update

Closes: #2703

* fix: test case to use separate logger per connection

* fix: test dummy column type

int means int8 on cockroachdb. Explicitly specify int4.

* fix: use string instead of number for test

int4 doesn't work for all dbs. Use string because it's universal.

* fix: let typeorm infer proper test column type

Co-authored-by: Ryan Shea <ryan.shea@alphaledger.com>
2020-05-18 06:35:01 +03:00
justblender
6c6bde7ebd feat: Add basic support for custom cache providers (#5309)
* Add basic support for custom cache providers

* Rename 'cacheProvider' to 'cache'

* Update caching documentation

* Add CustomQueryResultCache example in caching.md

* Add custom cache provider test
2020-01-22 19:19:22 +05:00
Zotov Dmitry
4c20d2e160 working on tests;
bugfixes;
2019-02-15 13:10:32 +05:00
Umed Khudoiberdiev
c1904de330
Merge branch 'master' into postgresql-exclude-constraint 2018-11-24 23:37:34 +05:00
Gints Polis
0df5090e73 Fix #2875 Migration Executor returns executed migrations 2018-10-30 20:37:40 +02:00
Eoin O'Brien
3beab58fe5
Add support for PostgreSQL exclusion constraints 2018-10-29 22:40:41 +00:00
Zotov Dmitry
f3770e65ff fixed issue #1758 2018-03-19 14:56:19 +05:00
Zotov Dmitry
20c5552c04 removed createSchema() from schema sync;
fixes in MigrationExecutor;
fixes in Oracle driver;
2018-03-01 18:23:40 +05:00
Zotov Dmitry
49aebb6d40 debugging CI issue; 2018-02-28 18:19:57 +05:00
Zotov Dmitry
fdadf24030 Merge branch 'next' into schema-builder-refactoring
# Conflicts:
#	CHANGELOG.md
#	src/connection/Connection.ts
#	src/entity-manager/EntityManager.ts
#	src/query-builder/InsertQueryBuilder.ts
#	src/query-builder/QueryBuilder.ts
#	src/schema-builder/RdbmsSchemaBuilder.ts
2018-02-27 21:19:13 +05:00
Umed Khudoiberdiev
1606ab8afb refactored entity schemas 2018-02-27 18:45:44 +05:00
Zotov Dmitry
5f2246d136 Merge branch 'next' into schema-builder-refactoring
Conflicts:
	src/decorator/columns/Column.ts
2018-02-22 12:32:00 +05:00
Piotr Deszyński
652176a759 fix(transformers): Fixed problem with transformes and entity update 2018-02-21 23:41:45 +01:00
Zotov Dmitry
7a0919b7c8 Merge branch 'next' into schema-builder-refactoring
Conflicts:
	CHANGELOG.md
	src/driver/oracle/OracleDriver.ts
	src/query-builder/QueryBuilder.ts
	test/functional/query-builder/join/query-builder-joins.ts
	test/utils/test-utils.ts
2018-02-20 13:31:41 +05:00
Umed Khudoiberdiev
71cc6bae4a fixed broken test utils 2018-02-15 10:29:43 +05:00
Umed Khudoiberdiev
4b38dfbdb5 added logging options to test utils 2018-02-13 18:06:18 +05:00