4934 Commits

Author SHA1 Message Date
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
d61f857ce9
fix: bugfixes introduced in 0.3.0 (#8764)
* fixes #8762; #8759; #8758; #8757;
2022-03-18 22:37:31 +05:00
Umed Khudoiberdiev
941b584ba1 version bump 0.3.0 2022-03-17 21:05:57 +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
Bitcollage
5608956730
refactor: remove spaces for consistency (#8751) 2022-03-15 15:29:07 +05:00
Umed Khudoiberdiev
486f8c5821 version bump 0.2.45 2022-03-04 19:42:54 +05:00
Hakan Uyumaz
0fc093d168
fix: discard duplicated columns on update (#8724)
Closes: #8723
2022-03-04 19:27:59 +05:00
Tadas Varanauskas
f3cfdd2641
fix: allow clearing database inside a transaction (#8712)
* fix: allow clearing database inside a transaction

Closes: #8527

* feat: added clear database inside transaction to sqlite and mysql databases

* feat: added clear database inside transaction to aurora, cockroach, oracle, sap, sql server drivers

Co-authored-by: Tadas Varanauskas <tadas@bitlocus.com>
2022-03-02 21:24:11 +05:00
Tom Welsh
96ac8f7eec
feat: add transformer to ViewColumnOptions (#8717)
* feat: add transformer to ViewColumnOptions

Added `transformer` field into ViewColumnOptions
Allow view column to unmarshal by custom ValueTransformer

* docs: add supported view-entity column options

* updated docs

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2022-03-02 21:14:07 +05:00
Joe Flateau
32549fec3a
refactor: DefaultNamingStrategy#getTableName should be protected, not private (#8707) 2022-03-01 11:58:50 +05:00
Gilad S
411fa54368
fix: force web bundlers to ignore index.mjs and use the browser ESM version directly (#8710)
Closes #8709
2022-03-01 11:57:00 +05:00
Umed Khudoiberdiev
10f46d9d06
fixing failing test 2022-02-26 19:28:31 +05:00
Umed Khudoiberdiev
ea16ac21ff
Update issue-8690.ts 2022-02-26 19:05:33 +05:00
Umed Khudoiberdiev
89a270fdd7
fixing failing test 2022-02-26 18:48:38 +05:00
Morteza PRK
6523526003
feat: add nested transaction (#8541)
* feat: add nested transaction

This will allow nested transaction for postgres driver using "save point"

Closes: #1505

* package-lock.json

* removed `RELEASE SAVEPOINT` from OracleQueryRunner

* fixed transaction support in sqljs-based drivers

* improved nested transactions logic across all drivers;
code refactoring;

* added nested transactions support for mssql

* fixed failing test

Co-authored-by: mortzprk <mortz.prk@gmail.com>
Co-authored-by: AlexMesser
2022-02-26 14:17:58 +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
Umed Khudoiberdiev
3131c5c607 version bump 0.2.44 2022-02-23 22:54:30 +05:00
Elliot Godzich
2c2fb29a67
fix: alter relation loader to use transforms when present (#8691)
Use column transforms when rendering queries during relation loading. Previously, transforms were ignored by the relation loader, causing unexpected values to be put into sql queries.

Closes: #8690
2022-02-23 20:37:34 +05:00
UrosStan
948d328aee
refactor: minor spelling fix (#8695) 2022-02-23 19:46:51 +05:00
UrosStan
329152447e
refactor: minor spelling fix (#8694)
Co-authored-by: Uros Stanimirovic <uros.stanimirovic@blinking.id>
2022-02-23 19:11:08 +05:00
Gilad S
2d3374b3b4
fix: ng webpack default import (#8688)
Closes #8674
2022-02-22 22:20:43 +05:00
Umed Khudoiberdiev
5a7180378e
fix: expo driver doesn't work properly because of new beforeMigration() afterMigration() callbacks (#8683) 2022-02-22 14:21:31 +05:00
Joe Flateau
87443954b5
feat: add option to upsert to skip update if the row already exists and no values would be changed (#8679)
* feat: add an option to upsert to allow skipping the update if no values have changed

* fix: relocate InsertOrUpdateOptions file with query-builder

* fix: only allow where is distinct from excluded on postgres

* fix: only expect postgres to skip the upsert update where nothing changed
2022-02-22 14:20:51 +05:00
Nix
7facbabd26
feat: allow {delete,insert}().returning() on MariaDB (#8673)
* feat: allow `returning()` on MariaDB >= 10.5.0

Closes: #7235

* build: update docker mariadb version to 10.5.13

* fix: MySqlDriver behavior returning is supported

* feat: what kind of DML returning is supported

* test: imporve test #7235
2022-02-21 18:21:14 +05:00
Lucian Mocanu
1f54c70b76
feat: Implement deferrable foreign keys for SAP HANA (#6104)
* Implement deferrable foreign keys for SAP HANA

* Fix code style

Co-authored-by: Lucian Mocanu <lucian.mocanu@nexontis.com>
2022-02-19 16:36:03 +05:00
Kyle Decot
136015b04e
fix: cannot read properties of undefined (reading 'joinEagerRelations') 2022-02-18 23:35:45 +05:00
Gilad S
12cbfcde7b
fix: support imports of absolute paths of ESM files on Windows (#8669)
Closes #8651
2022-02-18 23:34:40 +05:00
Umed Khudoiberdiev
6713a42fa1 fixing entity schema tests 2022-02-18 01:06:35 +05:00
Umed Khudoiberdiev
8742e339df returned problematic oracledb dep 2022-02-17 23:26:25 +05:00
Umed Khudoiberdiev
350cb9e901 version bump 0.2.43 2022-02-17 23:18:20 +05:00
Gilad S
96aed8aae0
fix: support require to internal files without explicitly writing .js in the path (#8660)
Closes #8656
2022-02-17 23:14:26 +05:00
Paweł Antyporowicz
7dbe956c56
feat: embedded entities with entity schema (#8626)
* feat: Embedded entities with entity schema

Added `embeddeds` field into EntitySchemaOptions
Added transformation to MetadataArgsStorage for embedded entities
Updated docs
Created new tests cases for EntitySchema with Embedded Entities
Changed type for field: `target` in EmbeddedMetadataArgs

CLOSES: #3632

* fixed docs

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2022-02-17 22:31:11 +05:00
Leandro
60a5b84826
docs: update select-query-builder RelationQueryBuilder with a example (#8658) 2022-02-17 20:49:22 +05:00
Umed Khudoiberdiev
a24d48a623 this test should not run if specific driver is disabled in ormconfig 2022-02-17 19:11:56 +05:00
Umed Khudoiberdiev
4590c9b996 this test should not run if specific driver is disabled in ormconfig 2022-02-17 18:49:14 +05:00
Umed Khudoiberdiev
6b0b15b0e6
Revert "feat: soft delete recursive cascade (#8436)" (#8654)
This reverts commit d0f32b3a17be9ffe9fbc6112e5731bbac91c3691.
2022-02-17 15:39:37 +05:00
Umed Khudoiberdiev
6ab9b3a327
removed only test 2022-02-17 15:30:14 +05:00
Umed Khudoiberdiev
a5493fba5e updated changelog and version bump 0.2.42 2022-02-16 21:56:56 +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
Lennard-Dietz
31f0b5535a
fix: relation id and afterAll hook performance fixes (#8169)
* perf: Increase performance when using entities with relation ids

Replace a quadratic runtime with a linear in results transformer

* perf: Increase performance of afterAll hook

Remove duplicate calculations of fitting subscribers for entity

* perf: Increase performance of entities with relation id

Use object instead of array for faster access

* style: fix indentation and some array operations
2022-02-16 20:23:51 +05:00
James Ward
8f2ae71201
fix: correctly handle multiple-row insert for SAP HANA driver (#7957)
the SAP HANA SQL dialect does not support inserts with multiple values
but it does support `INSERT ... SELECT` as well as a `SELECT ... FROM dummy`

with that in mind, the `InsertQueryBuilder` has been modified to support
this dialect similar to how we do for Oracle
2022-02-16 19:00:01 +05:00
James Ward
f24822ef9c
fix: disable SQLite FK checks in synchronize / migrations (#7922)
* fix: disable SQLite FK checks in synchronize / migrations

* test: add case for changing column in a table with foreign keys
2022-02-16 18:58:44 +05:00
oxeye-yuvalk
d0f32b3a17
feat: soft delete recursive cascade (#8436)
* feat: soft-delete-recursive-cascade

* fix get entity primary key

* better mapping for get parent ids

* fix use identifier and not entity from subject object

* remove only from test

* fix: replace primary key name to valid name

* fix: test bug

* fix: change returning to work on mssql

* fix: work for oracle

* add comments to subject executor

Co-authored-by: oxeye-yuvalk <oxeye-yuvalk@oxeye.io>
2022-02-16 18:26:49 +05:00
Francesco Salvi
3d6c5dae76
fix: make EntityMetadataValidator comply with entitySkipConstructor, cover with test (#8445)
Closes #8444

Co-authored-by: Francesco Salvi <francesco.salvi@bitbull.it>
2022-02-16 18:24:02 +05:00
Matthias Schwebler
09f54e0273
fix: materialized path being computed as "undefined1." (#8526)
* fix: materialized path being computed as "undefined1."

when tree entities are saved implicitly (through another related entity which hasMany tree-entities and "cascade" set to true) the ORM generates materialized-path strings prefixed with "undefined". Resulting in mpaths like "undefined1.2.3"

* fix: materialized path being computed as "undefined1."

removes it.only

* fix: materialized path being computed as "undefined1."

fixes unit tests

* fix: materialized path being computed as "undefined1."

Try to fix unit tests.

* fixing failing test

* fixing test

* fixing test

* fixing test

* Update materialized-path.ts

* Update materialized-path.ts

Co-authored-by: Matthias Schwebler <m.schwebler@sportradar.com>
Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2022-02-16 18:22:49 +05:00
metiftikci
93bf96ea63
fix: allow special keyword as column name for simple-enum type on sqlite (#8645)
* fix: Allow special keyword as column name for simple-enum type on sqlite

* fix: Fix tests

* fix: Fix tests
2022-02-16 16:46:43 +05:00
Matthias Kunnen
b93416d7bc
fix: improve DeepPartial type (#8187)
* test: DeepPartial with generics

* fix: resolve DeepPartial generic not matching valid input

* fix: resolve TS errors due to DeepPartial change

* deep partial type simplification

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2022-02-16 08:56:51 +05:00
Sakura
a11c50d551
fix: QueryFailedError when tree entity with JoinColumn (#8443) (#8447)
* fix: QueryFailedError when tree entity with joinColumns (#8443)

* test: add test for #8443
2022-02-15 21:17:02 +05:00
James Judd
e0adeee48e
revert: migration:show command must exist with zero status code (Fixes #7349) (#8185)
* feat: add --quiet option to migration:show command

* adding process.exit(0) back

* Update MigrationShowCommand.ts

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2022-02-15 21:13:16 +05:00
spotykatch
93383bd2ee
feat: separate update events into update, soft-remove, and recover (#8403)
Closes: #8398

BREAKING CHANGE: update listeners and subscriber no longer triggered by soft-remove and recover
2022-02-15 18:05:05 +05:00