2008 Commits

Author SHA1 Message Date
Piotr Kuczynski
dd55218648
fix(cli): init command reading package.json from two folders up (#11789) 2025-11-25 14:13:25 +01:00
Artem Kustikov
2681051f78
feat(mssql): support 'vector' type for MS SQL Server (#11732) 2025-11-12 21:22:20 +01:00
Piotr Kuczynski
6381c8d519
docs: fix typos in the js documentation (#11754) 2025-11-09 21:57:31 +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
Kishan Kumar
d7867ebff1
feat: manage MongoDB SOCKS5 proxy settings (#11731) 2025-10-20 23:14:32 +02:00
chen
925dee002b
feat: entity schema support trees (#11606) 2025-09-29 10:36:35 +02:00
Piotr Kuczynski
4f05718237
feat: add support for jsonpath column type in PostgreSQL (#11684) 2025-09-26 18:56:53 +02:00
Lucian Mocanu
c16ef63db7
chore: update dependencies (#11666) 2025-09-19 18:34:39 +02:00
Michael Bromley
34d87149ec
Revert "fix: do not create junction table metadata when it already exists (#11114)" (#11660)
This reverts commit 3c26cf18a77b5b0cd7c15c811fc3d0a43af32e47.
2025-09-19 11:03:18 +02:00
David Höck
974ead202d
fix: JSON parsing for mysql2 client library (#8319) (#11659) 2025-09-19 10:34:17 +02:00
Naor Peled
a49f612289
feat(postgres): support vector/halfvec data types (#11437) 2025-09-18 22:12:07 +03: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
8b76e1af74
feat(mysql): add support for MySQL 9 / MariaDB 12 (#11575) 2025-09-17 09:08:31 +02:00
Simon Garner
3fac86b60e
fix: update tests to reflect migration template changes (#11653) 2025-09-17 08:37:12 +02:00
Prateek Hegde
9cdfb20b12
chore: bump sha.js from 2.4.11 to 2.4.12 (fix security issue: CVE-2025-9288) (#11639)
* chore: bump sha.js from 2.4.11 to 2.4.12 (fix security issue: CVE-2025-9288)

* test: add unit tests for hash() to ensure sha.js upgrade compatibility

- Verify SHA1 output for known inputs
- Test truncation with options.length
- Handle empty string input
- Confirm deterministic behavior for identical inputs

* removed .only from test/unit/util/string-utils.ts to run all the unit tests

* fix(hash): ensure negative or zero options.length returns full hash

- Updated hash() to only truncate when options.length > 0
- Prevents accidental truncation when options.length is negative
- Maintains expected behavior for full-length hash

* added strict +ve number input validation for hash()

* simplified the logic to check number len before applying slice() in StringUtils.ts->hash()

---------

Co-authored-by: Prateek Hegde <prateek.hegde@deliverysolutions.co>
Co-authored-by: Prateek Hegde <prateek@Prateeks-MacBook-Pro.local>
2025-09-10 09:19:54 +12: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
Lucian Mocanu
22b26d1153
feat: allow VirtualColumns to be initially non-selectable (#11586) 2025-08-18 21:28:55 +03:00
Bartłomiej Rutkowski
b6ffd462dd
perf: Cache package.json location between getNearestPackageJson invocations (#11580)
* perf: Cache package.json location between invocation

Cache package.json location to improve performance of migrations with a lot of files

Closes: #4136

* refactor: Use map. Move tests to appropriate files

Move tests and use Map instead of object as per review comments

* test: Check number of invocations in test

Change test to assert number of stat and readFile calls

* test: Change assert for CI

Added assertion to make both local and CI work

* Create package.json in test

* Create file only if not existed before

* test: Fix test assertion based on platform

* test: Change package.json type

* ci: Trigger tests

---------

Co-authored-by: Bartlomiej Rutkowski <brutkowski@tilt.app>
2025-08-18 21:16:55 +03:00
chen
d1e3950907
feat: support virtual columns in entity schema (#11597)
* feat: add entity mode virtual-property

* test: virtual columns
2025-08-16 18:06:00 +03:00
Vampire
f351757a15
fix: resolve array modification bug in QueryRunner drop methods (#11564)
* fix: resolve array modification bug in QueryRunner drop methods

Fix iteration bug in QueryRunner implementations where dropping multiple
database objects (columns, indices, foreign keys, unique constraints) would
skip elements due to in-place array modification during iteration.

The issue occurred when methods like dropColumns(), dropIndices(),
dropForeignKeys(), and dropUniqueConstraints() iterated over arrays while
simultaneously modifying them by removing elements. This caused a classic
"off-by-one" iteration bug where alternate elements would be skipped.

Changes:
- Update all affected QueryRunner drop methods to iterate over a shallow
  copy of the input array using [...array] spread syntax
- Add comprehensive regression tests in test/github-issues/11563/
- Test coverage includes all affected drivers: Postgres, MySQL, SQL Server,
  Oracle, CockroachDB, Spanner, SAP, and Aurora MySQL

Affected drivers:
- SpannerQueryRunner
- PostgresQueryRunner
- MysqlQueryRunner
- SqlServerQueryRunner
- OracleQueryRunner
- CockroachQueryRunner
- SapQueryRunner
- AuroraMysqlQueryRunner

Closes #11563

* fix: create multiple indices same column

* chore: functional tests instead of github issues
2025-07-09 08:23:47 +02:00
Ragy Hosny
3c26cf18a7
fix: do not create junction table metadata when it already exists (#11114)
* fix: do not include already user defined junction tables in entityMetaData
2025-07-08 22:15:35 +12:00
Antti
66ee307784
fix: preserve useIndex when cloning a QueryExpressionMap (or a QueryBuilder) (#10679)
* fix: preserve useIndex when cloning a QueryExpressionMap

Closes #10678

* test: add test related to issue #10678
2025-07-04 23:16:50 +02:00
Lucian Mocanu
aebc7ebc67
feat(sap): use the native driver for connection pooling (#11520)
* feat(sap): use the native driver for connection pooling

* Add pool error handler
2025-07-01 23:43:12 +02: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
Lucian Mocanu
abf8863a53
feat(sap): add support for REAL_VECTOR and HALF_VECTOR data types in SAP HANA Cloud (#11526)
* feat(sap): add support for REAL_VECTOR data type

* feat(sap): add support for HALF_VECTOR data type
2025-06-22 01:43:10 +02:00
Lucian Mocanu
f2d2236218
fix(oracle): pass duplicated parameters correctly to the client when executing a query (#11537) 2025-06-21 14:05:15 +02:00
Lucian Mocanu
ead4f98ee4
fix: improve async calls on disconnect (#11523) 2025-06-19 00:43:38 +02:00
Mohamed Nader Baccari
42e7cbe7da
fix: fix null pointer exception on date array column comparison (#11532)
* fix: fix null pointer exception on date array column comparison

Follow up to https://github.com/typeorm/typeorm/pull/11269 which was
calling Array.map without validating if the array was null. Now only
normalize if both values (entity and database) are not null.

Closes: https://github.com/typeorm/typeorm/issues/11514

* clean test
2025-06-18 09:05:39 +12:00
Yevhen Komarov
63a3b9abc1
fix: multiple relations with same column name(s) generate invalid SELECT statement (#11400)
* fix: Multiple relations with same columns cause invalid SQL to be generated
Closes: #1668, #9788,  #9814, #10121, #10148, #11109, #11132, #11180

* refactor: extract cloneObject util

* fix: improve cloneObject

* test: remove duplicate tests

* test: transformed the test: add City, Country, and Order entities with composite foreign key relations,

* test: change to composite primary key

---------

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
2025-06-17 18:38:16 +02:00
gongAll
ce23d4648e
fix(tree-entity): closure junction table primary key definition should match parent table (#11422)
* fix #9600 https://github.com/typeorm/typeorm/issues/9600

* implement tests.

* implement tests.

* implement tests.

* move tests fo functional tab.
implement remaining tests.
implement remaining fields.

* fix code rabbit detected errors.

* add MySQL-specific type checks to closure-table tests

* split closure-table tests for MySQL-specific scenarios

* remove redundant MySQL type checks from closure-table tests

* move MySQL-specific closure-table tests to a separate file

---------

Co-authored-by: Gonçalo Alves <goncalo.alves@knowledgeworks.pt>
Co-authored-by: gioboa <giorgiob.boa@gmail.com>
2025-06-17 09:08:08 +12:00
DinoDeveloper
24c3e38c51
fix: add collation update detection in PostgresDriver (#11441)
* fix(postgres): collation not updated in DB when changed in entity

Closes: #8647

* test: issue #8647

* test: add enableDrivers, combine seperated cases

* test: update test name

* test: remove unnecessary characters in test case

* style: fix formatting

* style: fix comments typo
2025-06-05 15:25:43 +02:00
KimYeonghun
413f0a68c8
fix: handle limit(0) and offset(0) correctly in SelectQueryBuilder (#11507)
* fix: handle limit(0) and offset(0) correctly in SelectQueryBuilder

- Fix JavaScript falsy value issue where limit(0) was treated as undefined
- Now limit(0) correctly generates 'LIMIT 0' SQL clause instead of being ignored
- Add helper functions hasLimit/hasOffset to distinguish between undefined and 0
- Add comprehensive test cases for zero value handling in limit/offset/take/skip
- Prevents potential security issue where limit(0) returned all records

Fixes potential data exposure when limit(0) was intended to return empty result

* fix: prettier formatting

* test: expand test coverage for LIMIT/OFFSET edge cases and regression prevention
2025-06-05 14:40:58 +02:00
Sakura
a9c16ee66d
feat: add upsert support for Oracle, SQLServer and SAP HANA (#10974) 2025-06-05 08:45:45 +02:00
Md. Minhaz Ahamed(mmarifat)
2bfa300996
fix(postgres): resolve alias or table name in upsert/insert or update conditionally (#11452)
* fix: resolve regression in upsert and orUpdate for PostgreSQL driver

This fix addresses a regression introduced in
pull request #11082 by ensuring correct handling of alias names and table names when they are equal or distinct when entities use schema

Closes: #11440

* style: code formatted

* chore: run tests by running through all the drivers

* chore: set enabledDrivers as postgres

* chore: added postgres family members as enabled drivers

* chore: accepted suggestion to remove extra comments

Co-authored-by: Mike Guida <mike@mguida.com>

---------

Co-authored-by: Mike Guida <mike@mguida.com>
2025-06-04 22:39:38 +02:00
Simon Garner
b8dbca515e
fix(mssql): avoid mutating input parameter array values (#11476)
* test(mssql): add test for unwanted mutation of input params

* fix(mssql): avoid mutating input parameter array values

* chore: add comment explaining input array test assertion
2025-05-14 21:41:07 +12:00
Denes Antonio de Souza
144634d4c0
feat(spanner): support insert returning (#11460)
* Update SpannerDriver.ts

* Update package.json

* Update package.json

* Update package.json

* Update package-lock.json

* Update package.json

* #11453

* Revert "Update package.json"

This reverts commit 20f24de10cda62ad0c9a368b14290fbb4f355b32.

* Revert "Update package.json"

This reverts commit bcf6678e95b57570ea526935bb7490c9b11a16da.

* Update package.json

* Revert "Update package-lock.json"

This reverts commit a003e5659336b38b8cade5f1605c17f7c3e59673.

* #11460

* #11460

* FIX/Spanner Numeric type value string

* #11460 Test functional spanner

* test: update returning tests

* refactor: simplify condition

* style: fix lint/format

* test: fix returning test for spanner

---------

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
2025-05-13 22:45:53 +02:00
Christian Forgács
e9eaf79604
Fix/11466 mssql find operator (#11468)
* chore: enable driver `mssql` for test of issue #3113

* chore: add test case for #11298 to issue #11285 to prevent functionality of #11285

* fix: unhandled find operator with array value for mssql (#11466)

* fixup! fix: unhandled find operator with array value for mssql (#11466)

* Revert "chore: enable driver `mssql` for test of issue #3113"

This reverts commit a302d63eeac5892e920d97705b4230414ef81e6d.

* fixup! chore: add test case for #11298 to issue #11285 to prevent functionality of #11285

---------

Co-authored-by: Christian Forgács <christian@wunderbit.de>
2025-05-13 12:45:06 +12:00
Simon Garner
23bb1ee271
feat: add updateAll and deleteAll methods to EntityManager and Repository APIs (#11459)
* Add updateAll() methods

* Add deleteAll() methods

* Fix softDelete/restore error messages

* Add test for Repository.delete() with criteria

* Add test for Repository.deleteAll() method

* Move/rename “Repository > delete” test files

* Tweak comments

* Add tests for Repository update methods

* Add updateAll and deleteAll to EntityManager API docs

* Add updateAll and deleteAll to Repository API docs

* Fix tests
2025-05-13 12:33:44 +12:00
Eliya Cohen
c464ff87cb
feat: add tagged template for executing raw SQL queries (#11432)
* Added a new SQL tagged template feature for executing raw SQL queries with automatic parameter handling.

---------

Co-authored-by: Simon Garner <simon@equalogic.com>
2025-05-09 13:19:40 +12:00
Maxim Bronnikov
b94dfb3e31
fix: update/delete/softDelete by criteria of condition objects (#10910)
Co-authored-by: maxbronnikov10 <maxbronnikov2004@gmail.com>
2025-05-06 15:30:05 -06:00
Lucian Mocanu
fadad1a74c
fix: cleanup after streaming in sap hana (#11399) 2025-05-01 22:48:09 +02:00
TanguyPoly
b9842e3be9
fix: beforeQuery promises not awaited before query execution (#11086)
* fix: beforeQuery promises not awaited before query execution

Closes: #11085

* fix: run format

Closes: #11085

* fix: apply same beforeQuery & afterQuery logic to all drivers

* fix: use a different broadcaster for BeforeQuery / AfterQuery

* fix: BeforeQuery / AfterQuery event types

* fix: move broadCasterResult.wait in finally block

* fix: remove duplicated broadcasterResult.wait in ReactNativeQueryRunner

* fix: fix prettier issue

* fix: implemented requested changes

* fix: broken sqlite tests

* Revert "fix: broken sqlite tests"

This reverts commit 4bacd5f4b55bb09297e9086decefe62f08ceead0.

* Revert "fix: implemented requested changes"

This reverts commit 1d2f59bf2bf8ec276f84bcd8b840ca5420c4088f.

* review: undefined type at the end

* fix: move database connection logic outside of the promise bloc

---------

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
2025-05-01 09:16:32 +12:00
Mohamed Nader Baccari
a61654e079
fix: change how array columns are compared on column changed detection (#11269)
* fix: change how array columns are compared on column changed detection

Closes: #5967

* add tests with date array colum

* Normalize date arrays before comparing
2025-04-30 11:33:12 +12:00
Caíque de Castro Soares da Silva
61a6f971af
fix: prevent error when replication is undefined (#11423)
* fix: prevent error when replication is undefined

* fix format

* add test

* update test name

* fix test

* fix test

* skip test

* add unit test

* fix unit test

* fix unit test
2025-04-25 14:30:42 +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
Ievgen Makukh
fe71a0c3e4
perf(query-runner): use Date.now() intead of +new Date() (#10811)
* perf(query-runner): use Date.now() intead of +new Date()

* perf: use Date.now() instead of new Date().getTime()

---------

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
Co-authored-by: Mike Guida <mike@mguida.com>
2025-04-15 13:18:22 -06:00
iliagrvch
046aebe696
feat: Add query timeout support for MySql (#10846)
Add "enableQueryTimeout" option to MysqlConnectionOptions. When enabled the value of "maxQueryExecutionTime" will be passed to mysql driver as query timeout.

---------

Co-authored-by: Mike Guida <mike@mguida.com>
2025-04-15 12:17:04 -06: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
Pieter Wigboldus
7c5ea99b31
feat: generate ESM migrations via esm flag (#10802)
Including jsdoc for typehinting
Add esm as an option in the migrate cli
Update the documentation for the JS migrations

fixes #10801

Co-authored-by: Mike Guida <mike@mguida.com>
2025-04-04 12:05:33 -06:00