* 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
* 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: #2254fixes: #3132fixes: #3226fixes: #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>
* 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
* 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>
change the line 46 in relations-faq.md:
"Sometimes you want to have in your object id of the related object without loading it. "
into this:
"Sometimes you want to have, in your object, the id of the related object without loading it. "
The following grammatical adjustments are related to the "Avoid relation property initializers" section, found in the relations-faq page;
1. Adjust the grammatical error found in the following phrase "But if you have initializer" by adding "an" before the word "initializer".
2. Adjust the grammatical error found in the following phrase "the loaded object will look like as follow" by removing the "like" word and adding an "s" to "follow".
* feat: add custom timestamp option in migration creation
An option in the CLI to specify a custom timestamp when creating or generating a migration.
Closes: #8500
* feat: add custom timestamp option in migration creation
docs: added description for the option
An option in the CLI to specify a custom timestamp when creating or generating a migration.
Closes: #8500
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>
* feat: support importing TypeORM in esm projects
Closes: #6974Closes: #6941
* bugfix: generate index.mjs directly out of commonjs exports
The new implementation generates ESM exports directly out of the commonjs exports, and provides a default export to maintain compatability with existing `import`s of the commonjs implementation
* feat: support loading ESM entity and connection config files
When TypeORM tries to load an entity file or a connection config file, it will determine what is the appropriate module system to use for the file and then `import` or `require` it as it sees fit.
Closes: #7516Closes: #7159
* fix: adapt ImportUtils.importOrRequireFile tests to older version of nodejs
* fix: improved importOrRequireFile implementation
* feat: add solution to circular dependency issue in ESM projects
* docs: added FAQ regarding ESM projects
* chore: add `"type": "commonjs"` to package.json
* style
* docs: improve `ts-node` usage examples for CLI commands in ESM projects
* feat: add support for generating an ESM base project
* refactor: renamed `Related` type to `Relation`
* docs: added a section in the Getting Started guide regarding the `Relation` wrapper type in ESM projects
* docs: improved documentation of the `Relation` type
* docs: improved documentation of the `Relation` type
* docs: added ESM support to the list of TypeORM features
1. Fixed a typo- changed the key from listener to listeners in RemovalOptions.
2.Changed documentation related to RemoveOptions for the 'chunk' operation.
* docs: Improve various docs formatting
code syntax highlight on `leftJoinAndSelect`
capitalise SQL word
* docs: capitalise SQL word on classes methods docs
* docs: lowercase SQL word to trigger auto-test
* docs: uppercase SQL word to trigger auto-test
- Fixes https://github.com/typeorm/typeorm/issues/8420
- v4.0.0 and newer of node-redis will no longer auto-connect, so we need to add that step
- For backwards compatibility, we check for the existence of a "v4" property so we don't try to call `connect` on older versions of the client
- A `legacyMode` flag exists in the new v4.0.0 of node-redis to keep a similar calling style without having to change any code
- Note that the legacyMode flag is **required** to be passed if the calling code isn't going to be changed
* docs: fix a typo on `decorator-reference.md`
fix double spacing and improve formatting consistency on `many-to-many-relations.md`
* docs: add code syntax highlight on `leftJoinAndSelect`
* feat: implement generated columns for postgres 12 driver
The implementation has the potential to make full text search much faster when using postgres. You can simply pre-generate all tsvector's
* test: add tests for generated columns in postgres 12
* docs: document generated columns for postgres 12
* fix: check postgres version for generated columns
Generated columns are only available on postgres version 12+
* test: add postgres 12 to tests
Currently, there are only tests for postgres 9. This adds postgres 12 as test target
* test: remove generated column from model
MariaDB will fail with a generated column type
* test: use non alpine container for postgres 12
* test: skip generated columns test on mariadb
* fix: detect generated column change
* fix: circle ci postgres version
* fix: add replication mode to isGeneratedColumnsSupported() function
Latest changes in master introduce replication mode. This commit adjust the the pull request #6469 to this change
* fix: ci testing for postgres 12
Latest changes in master broke the postgres 12 test setup
* style: remove SqlServerConnectionOptions generic parameter for createTypeormGeneratedMetadataTable function
imnotjames notice this in his review of the pull request
* style: remove unnecessary return of Promise.resolve()
This return of Promise.resolve() has no effect. We can leave it out
* style: fix whitespace issue for config.yml
* refactor: use VersionUtils
Instead of parsing the version string with parseFloat, use the typeorm VersionUtils
* fix: fix failing build
After merging the upstream into the pr fork, the build stopped working. The reason why the build fails, is because in the upstream one import is missing and one variable was removed
* refactor: replace promise.all() with for loop
* refactor: make requested changes
* fix: update table name
* fix: server version query and escape table column in queries
* code refactoring
* fixed lint issue
* removed "enabledDrivers" from test
Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.
BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.
Closes: #3909
* 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
* feat: extend column options interfaces to also support Postgres10+ Identity generationStrategy
* feat: extend PrimaryGeneratedColumn support for Postgres10+ identity
* feat: update buildCreateColumnSql with Postgres10+ IDENTITY support
* feat: update loadTables for Postgres10+ IDENTITY column recognition
* doc: add description of identity support for PrimaryGeneratedColumn
* test: add test for SQL of table with IDENTITY COLUMN in Postgres 10+
* feat: take identity generation type into consideration when checking for changed column
* fix: better non behavior changing way of checking for identity column
* chore: rebase and resolve PR conversations
* feat: add relation options to all tree queries
Closes: #8076
* fix: corrected array index in test case
* try to fix failing test
* fix: sort the array in order to be able to apply tests
* feat: Add dependency configuraiton for views #8240
Add dependsOn option to @View decorator, where dependencies can be listed. Also use these dependencies to order draop/create view correctly when generating migrations
* fix: Make dropping views dependencies more readable
Rename some variables in viewDependencyChain in RdbmsSchemaBuilder and add more thorough comments, so its more readable.
Co-authored-by: Svetlozar <ext-svetlozar@getitdone.co>