1005 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Umed Khudoiberdiev
7dac12c2b1
fix: drop xml & yml connection option support (#9930) 2023-04-09 11:30:28 +05:00
AlexMesser
f1330ad6e2
fix: firstCapital=true not working in camelCase() function 2023-04-06 14:10:38 +05:00
acuthbert
947ffc3432
feat: leftJoinAndMapOne and innerJoinAndMapOne map result to entity (#9354)
* feat: leftJoinAndMapOne and innerJoinAndMapOne now map correctly with QueryBuilder

When joining to a query builder instead of an entity or table name, typeorm now
correctly supports mapping the result to an entity. This introduces a new argument
to the join functions to supply the join attributes with a source of meta data
for the mapping

For example:

const loadedPost = await connection.manager
      .createQueryBuilder(Post, "post")
      .innerJoinAndMapOne(
           "post.tag",
           qb => qb.from(Tag, "tag"),
           "tag",
           "tag.id = post.tagId",
           undefined,
           // The next argument is new - it helps typeorm know which entity
           // to use to complete the mapping for a query builder.
           Tag
      )
      .where("post.id = :id", { id: post.id })
      .getOne()

* style: Auto Formatting

* trigger CircleCI

---------

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
2023-04-06 13:51:43 +05:00
sinopsysHK
197cc05e90
fix: prevent foreign key support during migration batch under sqlite (#9775)
* fix: prevent foreign keys support during migration batch under sqlite

Schema changes in migrations batch cannot be done on table which has referring
 foreign keys with ON DELETE CASCADE without deleting its content.

Closes: #9770

* Update MigrationExecutor.ts

* Update command.ts

---------

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2023-04-06 13:12:10 +05:00
Nguyen Ba Hung
4ac8c00117
feat: add support for json datatype for sqlite (#9744) 2023-04-06 12:31:46 +05:00
Daniel Huth
f7f6817864
fix: improve EntityNotFound error message in QueryBuilder.findOneOrFail (#9872)
* fix: EntityNotFound error message in QueryBuilder.findOneOrFail

* change test

* change test

* change test
2023-04-06 11:34:00 +05:00
Leon Miller-Out
0619aca174
test: when calling AVG on an integer column, MS SQL Server returns an int. (#9784)
In this case, 50 instead of 50.5. Apparently the ANSI standard for SQL
is silent on this issue, so either behavior should be considered
acceptable.
2023-04-06 11:15:16 +05:00
कारतोफ्फेलस्क्रिप्ट™
7d1f1d6958
feat: support for SQL aggregate functions SUM, AVG, MIN, and MAX to the Repository API (#9737)
* feat: Add support for SQL aggregate functions SUM, AVG, MIN, and MAX to the Repository API

* rename field name to make tests work in oracle

* fix the comments

* update the docs

* escape column name

* address PR comment

* format the code
2023-02-07 19:01:04 +05:00
Umed Khudoiberdiev
4555211bcb
feat: update mssql dependency and other dependencies as well (#9763)
* updating dependencies

* fixing circleci config

* reverting mongodb version back

* increasing cli commands test timeout
2023-02-07 18:20:09 +05:00
Umed Khudoiberdiev
adce6985d8
Revert "fix: add support for mongodb v4 (#9450)" (#9762)
This reverts commit 8150525354a7a66e68152ef7bd894ad93266d2af.
2023-02-07 13:08:41 +05:00
Matheus Melo Antiquera
8150525354
fix: add support for mongodb v4 (#9450)
* fix: add support for mongodb driver v4

This new fix allow support to mongodb driver v4

Closes: #7907

* fix: add support for mongodb driver v4
This new fix allow support to mongodb driver v4

Closes: #7907

---------

Co-authored-by: Matheus Melo Antiquera <matheusantiquera@finchsolucoes.com.br>
2023-02-07 12:57:35 +05:00
Dmitry Zotov
7c00bb8e0e fixed wrong callback definition in tests 2023-02-07 12:51:06 +05:00
Filip Wróbel
0eb74411d6
feat: naming strategy for legacy Oracle (#9703)
* feat: naming strategy for legacy Oracle

This feature is LegacyOracleNamingStrategy which can be used to handle Oracle error ORA-00972.

* feat: naming strategy for legacy Oracle

This feature is LegacyOracleNamingStrategy which can be used to handle Oracle error ORA-00972.
2023-02-07 11:58:09 +05:00
변경연
6b37e3818b
fix: remove unnecessary .js extension in imports (#9713)
* fix: remove extension when importing file

* removed unnecessary .js extension in imports

---------

Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
2023-01-28 16:01:24 +05:00
Mattias Fjellvang
defb409f56
feat: support time travel queries, upsert, enums, spatial types in cockroachdb (#9128)
* feature: adds support for enum type (fixes #9068)

* temporarily ran package to test on different repo

* playing around - bumped version

* Revert "playing around - bumped version"

This reverts commit 7df4adb3e698419c174c2daee88614f8dafdbb6c.

* Revert "temporarily ran package to test on different repo"

This reverts commit 48f394e8eb32c22fe757010b446c85740bf80b5f.

* feat: add support for geometry data type

* feature: properly hydrate enum array values

* feature: adds support for geography and geometry for cockroachdb

* bugfix: fixes issue with primary generated columns being invalid column type (fixes #8532)

* Revert "bugfix: fixes issue with primary generated columns being invalid column type (fixes #8532)"

This reverts commit e00cdb090638d34668e3e10acd5f8267fe3bd028.

* bugfix: type casts to string when using ANY

* feature: cast geometry/geography to geojson

* feature: added references to srid

* bugfix: prevent error if trying to close already closed connection

* feature: added cockrachodb as part of postgres family

* feature: ensures support for spatial columns for cockroachdb

* feature: adds support for UPSERT for CockroachDB (fixes #9199)

* minor: added TODO; unsure how to achieve this

* feature: adds support for time travelling queries for cockroachdb

* bugfix: only run time travel query on SELECT statements

* refactor: changed UsertType from 'upsert' to 'primary-key' since this is more logical

* feature: added posibility to set timeTravelQuery to false, instead of the parameter function; help for disabling time travel queries during tests

* feature: allow timeTravelQueries in find* queries

* bugfix: when using timetravel queries with joinAttributes it now prevents error 'AS OF SYSTEM TIME must be in top level' error

* lint

* minor fix

* fixed failing test

* implemented ENUM type;
added tests;

* fixed failing tests

* fixed failing test

* fixed spatial types synchronization;
implemented spatial indices;
added tests for spatial columns;

* refactored Time Travel Query functionality;
removed TTQ from find options;
added tests for TTQ;

* added docs for Time Travel Queries

* minor changes

* added GeoJSON types;
other minor fixes;

* updated docs

* updated docs

Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
2023-01-03 19:25:22 +05:00
Adrian Parry
67973b4726
fix: materialized hints support for cte (#9605)
Fix implementation of materialized hints in common table expressions
Previous behavior did not account for NOT MATERIALIZED hints, also
placed materialized hints in wrong place (before "AS")

Co-authored-by: Adrian Parry <adrian.parry@reign.cl>
2022-12-29 19:55:54 +05:00
sinkhaha
8668c29d83
feat: support busy_timeout param parameter for sqlite (#9623)
Co-authored-by: sinkhaha <1468709606@qq.com>
2022-12-29 18:52:55 +05:00
Derek Bonner
2c54381815
feat: allow for partial index conditions for on conflict statments in postgres (#8971)
* feat: allow for partial index conditions for on conflict statments in postgres

* fix: change variable to match postgres documentation and convert from array to string type

* fix: generalize use of index predicate. add documentation and expand test cases

* lint fix

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
Co-authored-by: Alex Messer <dmzt08@gmail.com>
2022-12-03 21:11:10 +05:00
Morteza PRK
598e26980d
feat: implement exists query method (#9303)
Adding `Exists` method to query builder and EntityManager, to check whether a row exists given the conditions

Closes: #2815

Co-authored-by: mortzprk <mortz.prk@gmail.com>
2022-12-03 21:00:18 +05:00
Michael Wolz
53fad8f235
fix: disable transactionSupport option for CordovaDriver (#9391)
* fix: disable transaction support for cordova driver

the cordova-sqlite-storage plugin does not support transactions. fc4133c
introduced an exception when starting a transactions but did not disable
the transactionSupport in general leading to errors when using the
`save` and `remove` method of the `EntityPersistExecutor`. With this PR
the `EntityPersistExecutor` will respect the drivers `transactionSupport`
option.

* docs: add note on transaction limitations for cordova driver
2022-12-03 20:54:23 +05:00
4l3ss
93e6b3dd8e
fix: cacheId not used when loading relations with take (#9469)
* fix: cacheId not used loading relations

The cacheId is set to undefined for the main request used for pagination when we load related entities

* fix: tests
2022-12-03 20:16:50 +05:00
Adrian Burlacu
73148c9ad4
feat: add Open DB Flags and URI DB Name in SQLite (#9468)
* Add the open database flags for sqlite3.

* Check for URI before trying to create the DB dir.

* Spacing.

* Add the sqlite open connection flags.

* Spacing.

Co-authored-by: Adrian Burlacu <adrian.burlacu@live.com>
2022-12-03 19:46:49 +05:00
Patrick Gallagher
d490793c7c
fix: left instead of inner join for where or + optional relations (#9516) 2022-12-03 19:05:21 +05:00
Umed Khudoiberdiev
4ec04fa120
feat: added opaque types support over primitives in find-options (#9560)
* added opaque types support over primitives in find-options
* removed lock-verify because of its deprecation
* fixing auto type mapping
2022-11-21 23:24:30 +05:00
Michael Wolz
4a36d0e8c1
fix: boolean parameter escape in SQLiteDriver (#9400)
* fix: sqlite boolean parameter escape

sqlite does not support boolean parameters. Even though sqlite is able to transform true to 1 and false to 0 there might be some limitations with other implementations that build up on this.

Fixes: #1981 (again)

* fix: remove obsolete where boolean value transformation

3cbbe90c already handles the boolean value transformation so it is not necessary to have additional code in the query runner for handling this

* test: add test cases for sqlite query parameter escape

* fix typo
2022-11-05 13:56:51 +05:00
Ville Laitila
c053257bbe
test: old name fixed in test case name (#9428)
syncSchema was renamed to synchronize but nobody
updated the test case name.
2022-11-04 16:23:17 +05:00
Julian Pömp
cdabaa3028
fix: synchronize with typeorm_metadata table only if needed (#9175)
* fix: create typeorm metadata table before migration, if not exists

Creating a view in a migration results in an error: `QueryFailedError:
relation "typeorm_metadata" does not exist` (see #9173). This fix
creates the table before a migration runs.

Closes: #9173

* refactor: use function from RdbmsSchemaBuilder to create typeorm_metadata table

* test: add test for fix issue #9173

* test: replace describe.only() with describe()

* refactor: apply suggestions from review

* refactor: add syncWithMetadata param to createView function

* style: run npm format

* removed only test

* test: add missing syncWithMetaData parameter in create-view.ts

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2022-09-20 17:27:42 +05:00
Jannik Mewes
de15df14ed
feat: orphanedRowAction=disabled (rebase of PR 8285) (#8678)
* updated implementation, using "disable" keyword

* rebase test restructure

* rebase orphanedRowAction tests with keyword "disabled"

* rename test suite files to reflect changed naming: skip -> disable
Simplify test suite to comply with postgres12

* Update tests to reflect 0.3 breaking changes

* prettied

Co-authored-by: Jannik <jannik@jannikmewes.de>
2022-09-19 21:22:57 +05:00
AlexMesser
cc639610dc
fix: add missing support for primaryKeyConstraintName property in EntitySchema
adds missing support for primaryKeyConstraintName property in EntitySchema definition;
adds tests for another custom constraint names in EntitySchema definition;
2022-08-30 21:44:48 +05:00
Taylor Hakes
68e8f22894
feat: add setOnLocked for SKIP LOCKED and NOWAIT (#9317) 2022-08-26 00:24:16 +05:00
John
c4f46506d8
fix: change postgres driver version checking query (#9319)
* fix #9318

fix: change postgres driver version checking query

Change the postgres `SHOW server_version` query to use `SELECT version()` which adds compatibility with AWS Redshift database

Closes: #9318

* git-issue 9318: remove describe from only in test

* fix-9318: prettier format test
2022-08-25 17:40:12 +05:00
Dmitry Guketlev
f045536f24
fix: entity manager remove using entity schemas (#9221)
Currently the entity manager remove method does not recognize the first param if it is an entity schema.
2022-08-24 21:47:19 +05:00
Hyunji Song
e49d0c8740
fix: find query mongodb properly with @DeleteDateColumn() (#9262)
* fix: use existing query and filter deleted data

* test: add mongo-repository query test with DeleteDateColumn

* style: lint MongoEntityManager

* fix: not override $or with query.$or

* test: not override query.$or
2022-08-24 21:11:07 +05:00
Umed Khudoiberdiev
48e64e6973 removed logging 2022-08-24 20:01:37 +05:00
Umed Khudoiberdiev
d285fd0a2b
fixes #8939, #9061, closes #9168 (#9180)
* fixes #8939, #9061, closes #9168

* fixes

* fixing mssql error
2022-07-06 16:44:17 +05:00
Julian Pömp
bcdddc32bd
feat: add nativeBinding option to better-sqlite3 driver (#9157)
* feat: add nativeBinding option to better-sqlite3 driver

better-sqlite3 allows to set the `nativeBinding` option since version v7.5.0. It allows to define a custom path for the native api binary `better_sqlite3.node`. This feature is very important for developers who want to create binaries of their node apps for different platforms (e.g. with pkg). [More information](https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#new-databasepath-options=).

* docs: add description about nativeBinding option for better-sqlite3 driver

* refactor: apply prettier, test if nativeBinding is correctly set to better-sqlite3 driver

* refactor: apply prettier

* refactor: replaced describe.only() with describe()
2022-06-29 18:54:17 +05:00
AlexMesser
78df84c732
feat: allow explicitly named primary keys, foreign keys, and indices (#8900)
* feat: add constraintName to JoinColumn

Add a constraintName to JoinColumn decorators to allow specifying foreignKey name.
Use constraintName when building JoinTable entities as well.

Partially solves: #1355

* test: add tests for constraintNames on JoinColumn

* docs: add constraintName documentation to JoinColumn and JoinTable

* test: update snapshot in 5444 test

Add constraintName property with correct variable undefined to snapshot in tests for issue 5444.

* prettier

* added support for custom FK name in Sqlite;
added test;

* removed .only

* fixed FK constraint renaming on table/column rename

* minor fix

* fixed @Unique and @Index constraints renaming on table/column rename

* working on constraint name support for PK

* replaced `constraintName` with `primaryKeyConstraintName` and `foreignKeyConstraintName`

* fixed failing test

* working on constraint name support for PK

* updated docs

Co-authored-by: Matthijs Hatzmann <matthijs.hatzmann@tradecast.eu>
2022-04-29 17:48:40 +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