1908 Commits

Author SHA1 Message Date
Markus Fürer
b188c1e634
chore: initial setup of ESLint (#10203)
* build: 👷 Initial setup of ESLint

* build: 👷 show erros as warnings

* refactor: ♻️ example of rule "no-var"

* build: 🚨 add rule "no-unsafe-optional-chaining"
2024-01-02 12:04:37 +05:00
Gazy Mahomar
25e6ecdfd2
fix: nested transactions issues (#10210)
* fix: nested transactions issues

* Forgot test description

---------

Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
2024-01-02 12:03:28 +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
Alessio Napolitano
dc1bfed6d5
fix: resolve issues on upsert (#10588)
* fix: resolve issues on upsert

Closes: #10587

* fix: test 10563 multiple foreach

* run format

* removed only
2024-01-02 11:49:24 +05:00
Clinton Blackburn
bafcd1709b
feat: exposed entity and criteria properties on EntityNotFoundError (#10202)
These properties can be used by consumers to aid in rendering human-readable error messages.
2023-12-29 21:30:06 +05:00
Tolga Paksoy
b53e410e5a
fix: empty objects being hydrated when eager loading relations that have a @VirtualColumn (#10432)
* test: add scenario for #10431

* fix: empty objects being hydrated by unselected virtual properties
2023-12-29 21:18:11 +05:00
kyoungmin kim
d41930f0d6
fix: logMigration has incorrect logging condition (#10323)
* fix: logMigration has correct logging condition

Closes: #10322

* fix: add test description

Closes: #10322
2023-12-29 20:16:40 +05:00
Dinko Osrecki
f6bb6711e2
feat: support mssql@10 (#10356)
* feat: add support for mssql@10

Add mssql@10 to peerDependency, alongside mssql@9.
Update tests to use latest version of mssql and Node v16.

Closes: #10340

* fixed failing test

---------

Co-authored-by: Alex Messer <dmzt08@gmail.com>
2023-12-29 19:46:52 +05:00
Lukas Spiss
fdb9866ad2
fix: update UpdateDateColumn on upsert (#10458)
Closes: #9015
2023-12-29 19:21:57 +05:00
Szymon Bretner
696e688d00
fix: SQLite simple-enum column parsing (#10550) 2023-12-29 19:16:33 +05:00
Joren Vandeweyer
a4900ae15f
fix: extend GiST index with range types for Postgres driver (#10572)
* fix: extend spatial column types for postgres driver

Extend spatial column type with range types for postgres. This fixes a bug when using spatial indices.

Closes: #10567

* format

* remove only from test, ready for pr

* changed a way how we determine index type

---------

Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
2023-12-29 19:09:30 +05:00
Harry Brundage
72b1d1b865
feat: ability to change default replication mode (#10419)
* Add a replication test suite

* Allow overriding the default destination for read queries when using replication

For many applications that want to use read slaves, data consistency isn't super important, and so all reads can be sent by default to a read slave. For some applications though, it's only select queries that can be sent to read slaves as end-users of the application expect data consistency almost everywhere. This new setting lets apps like those change the default such that query builders need to opt *in* to sending to a read slave, instead of opt out.
2023-12-29 19:06:58 +05:00
Nemanja Stanic
b6b46fb133
feat: add exists and exists by (#10291)
This PR deprecates `exist` in favor of `exists` and `existsBy`.
2023-12-29 16:29:02 +05:00
Fawzi Abdulfattah
6c918ea392
fix: resolve issue queryBuilder makes different parameter identifiers for same parameter (#10327)
Closes: #7308
2023-12-29 16:19:55 +05:00
Marco Ellwanger
af77a5d0ac
fix: default value in child table/entity column decorator for multiple table inheritance is ignored for inherited columns (#10563) (#10564) 2023-12-29 15:37:13 +05:00
Gabriel Kim
cf37f1370b
fix: migrations on indexed TIMESTAMP WITH TIME ZONE Oracle columns (#10506)
ignore auto-generated virtual columns and attempt to map them into
their respective reference columns

Closes: #10493
2023-12-29 15:26:12 +05:00
michaelzaytsev
39fdcf651f
fix: resolve issue of generating migration for numeric arrays repeatedly (#10471)
Closes: #10043
2023-12-29 15:19:46 +05:00
strongpauly
ae006af501
feat: entityId in InsertEvent (#10540)
Co-authored-by: Paul Potsides <paul@koble.ai>
2023-12-29 15:16:32 +05:00
Dinko Osrecki
ccb9aff89a
test: fix migration-generate test suite (#10361)
* test: fix migration-generate test suite

WIP

Closes: #10360

* fixed mssql test hang;
added option to disable process exit;

---------

Co-authored-by: Alex Messer <dmzt08@gmail.com>
2023-12-29 15:02:44 +05:00
Lucian Mocanu
45e31cc57a
feat: implement column comments for SAP HANA (#10502)
* feat: implement column comments for SAP HANA

* test: improve schema tests for SAP HANA
2023-12-29 15:01:23 +05:00
Lucian Mocanu
7e9cead8a3
feat: implement streaming for SAP HANA (#10512) 2023-12-29 14:53:30 +05:00
Gabriel Kim
89c525761d
feat: user-defined index name for STI discriminator column (#10509)
avoid index duplication on the discriminator column when using STI
and explicitly defining an index for it

Closes: #10496
2023-12-29 14:50:52 +05:00
Gabriel Kim
b240d87f34
feat: custom STI discriminator value for EntitySchema (#10508)
add discriminator value metadata to EntitySchema

Closes: #10494
2023-12-29 14:43:59 +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
growms
e296063b12
fix: ManyToMany ER_DUP_ENTRY error (#10343)
* fix: ensure comparing EntityMapIds in `buildForSubjectRelation`

I have found the issue (for me at least). In the method `buildForSubjectRelation` of `ManyToManySubjectBuilder`, in order to know if it is needed to insert the relation rows `databaseRelatedEntityIds` is compared with `relatedEntityRelationIdMap` (line 154). The problem is that `databaseRelatedEntityIds` is not always an "EntityIdMap". If one is overloading the entity in the `afterLoad` event of an EventSubscriber for example the line 102 :
`const databaseRelatedEntityValue = relation.getEntityValue(subject.databaseEntity);` will return an "enhanced" object with additional properties. To fix this, in this commit, we ensure that `databaseRelatedEntityIds` is containing an "EntityIdMap".

Closes #5704

* refactor:  describe.only -> describe

removes describe.only.

* style: npm run format

format code.

* Update issue-5704.ts

refactor: typo on post title

---------

Co-authored-by: blemoine <services+bitbucket@blemoine.pro>
2023-09-30 15:04:27 +05:00
Zivvvv
022d2b5f62
fix: aggregate function throw error when column alias name is set (#10035)
* fix: aggregate function throw error when column alias name is set

Closes: #9927
2023-08-19 20:52:03 +05:00
Jose Toscano
c6f608d3e8
fix: resolve issue building eager relation alias for nested relations (#10004)
* fix: resolve issue building eager relation alias for nested relations

Fix alias error for nested relations. When loading eager relations from
nested levels only the first level was handled through the alias builder

Closes: #9944

* fix: update test: issue-9944 to include postgres

Add postgress as enabled driver for test "issue-9944"

* fix: resolve issue building eager relations withput parsing for "." to get relations

Fix alias error for nested relations by usinf relation.propertyName instead of relation.propertyPath
By using property path, we would have to parse for "." to get the nested relations, but that could
bring issued with column names that had dots within the name.
2023-08-19 20:44:22 +05:00
Sean McGivern
d937f6106a
fix: scrub all comment end markers from comments (#10163)
This was only removing the first comment end marker, so it was still
possible to generate invalid SQL with the comment method.
2023-08-19 20:36:33 +05:00
Nicolas ROGER
9f8899f56c
fix: improve helper for cli for commands missing positionals (#10133)
* fix: improve helper for cli for commands missing positionals

Add positionals to:
 - MigrationCreateCommand
 - MigrationGenerateCommand
 - SubscriberCreateCommand
 - EntityCreateCommand

* fix: re-enable migration-create/generate tests
2023-08-19 20:34:32 +05:00
grainrigi
f8fa1fd821
fix: ignore changes for columns with update: false in persistence (#10250)
Closes: #10249
2023-08-19 20:22:35 +05:00
Nadia Karlinsky
df7c06948c
feat: add MSSQL disableAsciiToUnicodeParamConversion option and tests (#10161)
This adds a new property `disableAsciiToUnicodeParamConversion` to `SqlServerConnectionOptions` to
control whether the `MssqlParameter` types char, varchar, and text are converted to their unicode
equivalents, nchar, nvarchar, and ntext. This defaults to false, maintaining the current behavior.

Closes:  #10131
2023-08-19 17:51:39 +05:00
juliengbt
b1a3a39504
fix: #10040 TypeORM synchronize database even if it is up to date (#10041)
* test: #10040 TypeORM synchronize database even if it is up to date

* formating

* fix: TypeORM synchronize database even if it is up to date #10040
2023-06-20 12:38:55 -07:00
Felix Gohla
d4607a8672
test: fix test from #9034 with STI for Oracle (#10037)
Oracle does not have a `onUpdate: 'CASCADE'` option.
Thus, the test fixtures had to be adapted.
Checking for the correct `onUpdate` actions for Oracle was introduced in #9786.
2023-05-10 14:40:15 +05:00
AlexMesser
607d6f9595
fix: added transaction retry logic in cockroachdb (#10032)
* added transaction retry logic in cockroachdb

* added option to control max transaction retries;
added delay before transaction retry;
updated docs;

* fixes in retry logic

* enable storing queries after retrying transaction
2023-05-09 23:46:07 +05:00
LoneRifle
8795c864e8
fix: support More/LessThanOrEqual in relations (#9978)
* test(select-buildwhere): exercise More/LessThanOrEqual for relations

Extract the relevant test suite from functional/find-options, modifying
the tests to use the equivalent More/LessThanOrEqual operators

* fix(select-buildwhere): support More/LessThanOrEqual for relations

Tweak `buildWhere()` to recognise more find operators and output
the SQL equivalent

- Recognise `moreThanOrEqual` and `lessThanOrEqual`, in addition to
  `moreThan` and `lessThan`
- If the find operator ends with `OrEqual`, append `=` to the
  SQL operator

* code style change

---------

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2023-05-09 22:32:41 +05:00
Felix Gohla
06c1e98ae2
fix: create correct children during cascade saving entities with STI (#9034)
* test: test saving disciminators STI, cascading

This commit adds an test for checking whether discriminators are saved
correctly when saving a field with cascade that uses
Single-Table-Inheritance.

Related to: #7758

* fix: Create correct children with STI

This commit fixes the `create` function for EntityManager and Repository
to create entities of correct type when using Single Table Inheritance.
Refactors the otherwise repeated code into a new function on
EntityMetadata.

Related to: #7758

* test: check STI type setting discriminator manually

Related to: #9033

* feature: allow setting discriminator value manually

This commit allows using an instance of a base class in a
Single Table Inheritance scenario and setting the discriminator value
manually.

Related to: #9033

* test: test saving disciminators with trees in STI

This commit adds an test for checking whether discriminators are saved
correctly when saving a tree that also uses Single-Table-Inheritance.

Related to: #7758

* fix: Create correct children with STI and trees

This commit fixes the `create` function for EntityManager and TreeRepository
to create entities of correct type when using Single Table Inheritance
and complex inheritance with Trees.

Related to: #7758
2023-05-09 22:14:01 +05:00
leoojg
96b7ee44b2
fix: correct encode mongodb auth credentials (#10024)
* fix: correct encode mongodb auth credentials

when use the special character `@` into mongodb password result in unauthorized because the it has no encoding

Closes: #9885

* we need to close connections at the end

* fixed js issue

* adjust import statement

* style: run prettier

---------

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2023-05-09 16:25:49 +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
ertl
938f94bded
fix: add onDelete option validation for oracle (#9786)
* fix: add onDelete option validation for oracle

Closes: #9189

* refactor: move fk validation logic to EntityMetadataValidator.ts

* fix: skip assertion for other databases

* fix: styles

---------

Co-authored-by: ke <ke@sbs.co.at>
2023-05-09 15:49:22 +05:00
Riqwan Thamir
21a9d67fcf
fix: RelationIdLoader has access to queryPlanner when wrapped in transaction (#9990)
fix issue - createQueryBuilder in repository loses queryplanner when wrapped in txn upsteam until RelationIdLoader

Closes: #9988
2023-05-09 15:28:30 +05:00
smith-xyz
2a2bb4bdc1
fix: allow json as alias for longtext mariadb (#10018) 2023-05-09 14:54:52 +05:00
smith-xyz
d8a2e3730f
feat: mariadb uuid inet4 inet6 column data type support (#9845)
* feat: mariadb inet4, inet6, uuid data type support

* refactor: cleanup unnecessary methods

* style: mysqldriver formatting

* fix: handle length column metadata mariadb uuid

* fix: 8832 test suite to verify errors correctly

* style: fix 8832 test formatting

* fix: 8832 error testing cleanup

* fix: remove defaulting column type feature

* style: fix formatting

* fix: remove unnecessary dbms error test

* fix: remove unused import in test

* fix: ensure defaulting uuid generation column type
2023-04-25 11:36:20 +05:00
Umed Khudoiberdiev
0e56f0fcf8
fix: select + addOrderBy broke in 0.3.14 (#9961)
* added test for #9960
* fixing the issue
* limiting only to postgres because of NULLS FIRST syntax
* lint
2023-04-18 22:52:05 +05:00
spotykatch
3d67901fde
fix: resolve duplicate subscriber updated columns (#9958)
Closes: #9948
2023-04-18 14:40:28 +05:00
Lucian Mocanu
51eecc2aa0
fix: prevent unique index identical to primary key (all sql dialects) (#9940)
Co-authored-by: Lucian Mocanu <lucian.mocanu@nexontis.com>
2023-04-15 14:52:59 +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
mptr
3a72e35081
test: cli init with local typeorm package (#9926)
* test: cli init with local typeorm package

Uses the locally built files instead of the typeorm
package published to npmjs. This enables testing project
initialisation with unreleased typeorm package versions.

* fix: enable init cli to be testable w non-releases
2023-04-13 05:24:44 +05:00
Umed Khudoiberdiev
7dac12c2b1
fix: drop xml & yml connection option support (#9930) 2023-04-09 11:30:28 +05:00
Umed Khudoiberdiev
12e9db07b6
feat: QueryBuilder performance optimizations (#9914)
* small optimization in driver utils - shortening alias become a bit faster

* added entity metadatas as a map into DataSource for search optimization purposes

* ultra small optimization - looks like symbols work slow. Need to re-think its usage

* small optimizations to improve performance

* replace property names optimization

* tsc error fix

* big optimization - now replacePropertyNames executed only for the final SQL query

* trying to fix the bug in select query builder with orders not being properly replaced with their aliaces

* fixing tests
2023-04-06 14:21:40 +05:00
AlexMesser
f1330ad6e2
fix: firstCapital=true not working in camelCase() function 2023-04-06 14:10:38 +05:00