5213 Commits

Author SHA1 Message Date
Patrick Molgaard
bbdc20f8ca
perf: partially lift matching from regexp to js (#9032)
Digging further into #3857.

See also #8955, #8956.

As [previously
discussed](https://github.com/typeorm/typeorm/issues/3857#issuecomment-699505893),
the query builder currently suffers from poor performance in two ways:
quadratic numbers of operations with respect to total table/column
counts, and poor constant factor performance (regexps can be expensive
to build/run!)

The constant-factor performance is the more tractable problem: no longer
quadratically looping would be a chunky rewrite of the query builder,
but we can locally refactor to be a bunch cheaper in terms of regexp
operations.

This change cuts the benchmark time here in ~half (yay!).

We achieve this by simplifying the overall replacement regexp (we don't
need our column names in there, since we already have a plain object
where they're the keys to match against) so compilation of that is much
cheaper, plus skipping the need to `escapeRegExp` every column as a
result.
2022-05-31 20:56:42 +05:00
rinsuki
862a4027af
feat: support TS 4.7+ node16/nodenext module mode (#9043)
in node16/nodenext module mode of TS 4.7+, If package has `exports` entry on package.json, needs "types" field in `exports.*` for typings.

so just I added it.

ref. https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/
2022-05-31 18:35:13 +05:00
Auridas F
ef025bd7f6
docs: update TableForeignKeyOptions.name description (#9057)
`TableForeignKeyOptions.name` reflects the name of the foreign key. The name of the table where this foreign key resides is actually referenced by `referencedTableName`
2022-05-31 18:25:39 +05:00
apeltop
0659ec3952
docs: correct typos (#9047) 2022-05-30 15:26:09 +05:00
Dmitry Zotov
cf3efec729 replaced Slack link to actual 2022-05-23 18:50:08 +05:00
元路
1b4cb00ea2
docs: minor fix in index.md (#9025) 2022-05-23 11:40:32 +05:00
Deividas Gineika
676fd1bf77
fix: add missing enumName support for EntitySchema (#9024) 2022-05-23 11:36:07 +05:00
Patrick Molgaard
189592c779
perf: don't recompile escapeRegExp for every query (#8956)
Context: the query builder is pretty CPU intensive, and can be slow -
e.g. https://github.com/typeorm/typeorm/issues/3857

One of the things which makes this slow is `escapeRegExp` in the query
builder: we freshly construct the same RegExp once per
`replacePropertyName` invocation (many times per overall query!) and
since the RegExp itself is constant -- we can lift it out and construct
it once.

Over-all this saves about 8% on our query build times as measured by
 #8955.
2022-05-20 17:04:25 +05:00
Patrick Molgaard
22570f51f3
test: add benchmark for select querybuilder (#8955)
Motivation: the query builder (and within it, replacePropertyNames and
associated functions) is pretty CPU intensive. For our workload, it's
one of the hottest functions in our entire stack.

While improved in https://github.com/typeorm/typeorm/pull/4760,
There are still outstanding issues relating to perf e.g. https://github.com/typeorm/typeorm/issues/3857

As we all know though, the first step in optimization is to measure
systematically ;)

https://wiki.c2.com/?ProfileBeforeOptimizing

On my machine, this benchmark runs in ~3500ms or about 0.35ms/query.
This tells us there's a way to go - on my stack, that's about 1/3 of a
typical query's latency!
2022-05-20 16:51:43 +05:00
Yusuf Ganiyu
ea176b27d4
docs: update migrations.md (#9022) 2022-05-20 16:14:42 +05:00
Gary Lee
d0ed02d9ce
docs: edit mistypes in the Repository API document (#9012)
docs: edit mistypes in the Repository API document

- Edited mistypes in the example code in findAndCountBy and findOneBy method.
2022-05-20 15:42:16 +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
Peter
9f8429f5eb
docs: extended extension section in README.md file (#8933) 2022-04-27 19:04:52 +05:00
Sudarshan Gaikaiwari
49cbe23277
fix: migration successful now displays name of the migration file (#8904)
Co-authored-by: Sudarshan Gaikaiwari <sudarshan.gaikaiwari@getcruise.com>
2022-04-18 17:56:03 +05:00
Andrew Greenan
2d8afbea16
docs: update InitCommand.ts (#8897)
Use `AppDataSource` instead of `dataSource`. Looks like a bug introduced into the `InitCommand` from 3b8a031ece
2022-04-16 18:32:43 +05:00
matt
7dfb69f366
fix: add missing connect call on RedisQueryResultCache connect (#8894) 2022-04-15 20:27:35 +05:00
Alessandro Maruccia
8e9b273885
docs: update generate migration docs (#8896) 2022-04-15 20:25:45 +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
Gilad S
b84cb9b2aa
docs: add the documentation site as homepage in package.json (#8888)
This way the npm module page will also link to the documentation site, instead of displaying 2 links to the same github page
2022-04-13 20:34:17 +05:00
Daniel Hensby
9adab34e5d
fix: update mssql peerDependency (#8887)
Update peerDependency for MSSQL lib which was upgraded devDeps previously
2022-04-13 18:25:53 +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
Uros Smolnik
4687be8b77
feat: add for_key_share ("FOR KEY SHARE") lock mode for postgres driver (#8879)
Adds support for new lock mode `for_key_share` - generating FOR KEY SHARE lock. Postgres specific.

Closes: #8878
2022-04-12 17:30:52 +05:00
kevaLsabhany
dfd0585965
docs: update README.md (#8881)
Removed unnecessary import statements from code snippets.
2022-04-12 17:22:06 +05:00
Gilad S
1197d1d61c
docs: change bold line to h4 title to improve search index (#8862)
* docs: change bold line to h4 title to improve search index

* Update supported-platforms.md
2022-04-11 21:16:28 +05:00
Stjepan
9d331b1ac9
refactor: update ColumnOptions.ts (#8865) 2022-04-11 21:15:35 +05:00
Marouane
a145f0046d
docs: fix code indentation (#8864)
bad indentation break syntax highlighting.
2022-04-11 21:14:38 +05:00
Andrzej Wódkiewicz
273f89e92d
refactor: reword migrations option jsdoc (#8873)
`migrations` option is not accepting direcrories, but glob patterns that
resolve to particular files.
2022-04-11 21:14:19 +05:00
Seth Samuel
cc5a5c1a7b
chore: Update package.json to expand Redis peer dependency. (#8877) 2022-04-11 20:48:11 +05:00
Umed Khudoiberdiev
c814b07653 version bump 0.3.5 2022-04-05 21:59:24 +05:00
Umed Khudoiberdiev
7b4bca73ae fixes #8849 2022-04-05 21:54:10 +05:00
Emmanuel LEVEQUE
7832a1a1c6
refactor: clarify error message on datasource loading (#8853) 2022-04-05 20:21:23 +05:00
Jake Malone
1693a17011
fix: resolve missing ConnectionOptions export in index.ts (#8850)
Closes: #8837
2022-04-04 21:06:27 +05:00
Grisha
3730fd07d1
chore: add missing exports to index.ts (#8844) (#8845)
* chore: add missing exports to index.ts 

New functions from 0.3.1 are missing in index.ts file

* style: prettier format

* fix: lint errors
2022-04-04 19:47:20 +05:00
Gilad S
7a20922929
docs: add typeorm-codebase-sync to the README.md file (#8847) 2022-04-04 19:46:04 +05:00
Umed Khudoiberdiev
69c33a2594 refactor: this test can be removed since of deprecation of ormconfig.json 2022-04-04 19:15:04 +05:00
Umed Khudoiberdiev
6774605181 refactor: consistent SQLs 2022-04-02 22:20:03 +05:00
Nelson Fleig
8ba742eb36
fix: Update DeepPartial for usage of generics with Repository class (#8817)
* test: test usage of generics with Repository class

* test: cleanup

* fix: update DeepPartial to work with generic Repository

* fix: restore package-lock.json from typeorm/master
2022-04-02 22:19:20 +05:00
Umed Khudoiberdiev
ec27803f28 refactor: removing globals usages 2022-04-02 22:04:20 +05:00
Umed Khudoiberdiev
2205a1a6a5 remove globals usages 2022-04-02 21:40:13 +05:00
Felix Gohla
9d1e2460ed
fix: save correct discriminator with STI (#8819)
When using a STI scheme and an EntityManager or Repository
with base class target, the wrong discriminator was written to the
database despite giving an concrete entity.
This was because of the entity's target being ignored in favor of the
target of the Repository or the EntityManager.

fixes #2927
2022-04-02 20:55:42 +05:00
ByungJoon Lee
baa2f44f2d
docs: added "erdia" extension to readme (#8841)
* added "erdia" extension to readme
* Update README.md, README_ko.md
2022-04-02 20:29:49 +05:00
Rafael Lemos
d18e0eefd5
docs: fix function name (#8840)
The name of the function declared in the repository does not match with the function name used in the examples.
2022-04-02 20:28:37 +05:00
Rafael Lemos
5176a0aff7
docs: missing argument at migration:generate (#8839)
`migration:generate` requires data-source path as argument
2022-04-02 20:27:39 +05:00
fedemahf
aa6b1891d6
docs: fix typo (#8838) 2022-04-02 20:26:38 +05:00
Umed Khudoiberdiev
22d21b0a82 added test util scenario for spanner driver 2022-04-02 20:25:22 +05:00
Jacob Lauritzen
e58c796071
refactor: clarify deprecation or orUpdate (#8829)
* docs: clarify deprecation of orUpdate

* docs: add examples for migration to non-deprecated call signature
2022-03-31 17:50:20 +05:00
Samuel
b1a01074c9
fix: allow hstore type to use transformers in driver postgres (#8823)
The HSTORE type is the only type bypassing the transformer
column options.
This fix makes the option available to this column type as well.

Co-authored-by: Samuel Roy <sam@pricemetry.com>
2022-03-30 20:28:31 +05:00
Arseny Yankovsky
ed06f4c1f1
fix: .save repository method not returning generated uuids for aurora-postgres (#8825)
* fix: fixed .save repository method not returning generated uuids for aurora driver

* fix(aurora-postgres): fixed .save repository method not returning generated uuids for aurora driver
2022-03-30 20:18:12 +05:00
Gilad S
c5dfc11ea7
fix: broken shebang parameters of cli-ts-node-commonjs and cli-ts-node-esm on some linux distros (#8821)
Changed to nodejs workaround instead of relying on shebang parameters, as they work a bit differently on some linux distros, and using the "-S" parameter breaks the CLI on Windows

Closes #8818
2022-03-29 10:29:02 +05:00
Umed Khudoiberdiev
5ae9f3786b failing test fix 2022-03-29 10:21:35 +05:00