4332 Commits

Author SHA1 Message Date
James Ward
c714867d3d
fix: ensure browser builds don't include any non-browser modules (#6743)
currently we pull in BetterSqlite3Driver, SqliteDriver, and a few other
drivers & files that aren't possible to use in a browser context.
this change adds some more browser compatibility features so
webpack builds targeted at browsers will be able to complete

closes #6739
2020-09-19 13:02:03 +05:00
Arty
5084e47be4
feat: add option to pass postgres server notices to client logger (#6215)
This feature for postgres connections means when you pass the logNotifications option, db notices and notifications will be passed to the logger with info log level

Closes: #2216
2020-09-17 16:40:28 +05:00
Louai Hamada
4bc7431043
docs: update many-to-many-relations.md (#6725)
* Update many-to-many-relations.md

* Update many-to-many-relations.md

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2020-09-17 16:16:16 +05:00
jesussegado
6e28322ca6
fix: migration:generate issue with onUpdate using mariadb 10.4 (#6714)
* Update MysqlQueryRunner.ts

In Mariadb the extra information of a DDL is in upper case and in javascript String.indexOf() function is case sensitive, because of that when you generate a new migrations  in mariadb it always create a line to update  "onUpdate" lines.

 example:
```sql
CREATE TABLE `test` (
  `test_id` int(11) NOT NULL AUTO_INCREMENT,
  `test_update` timestamp() NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`test_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
```

When you try to generate a new migration always create the next migration file:

```ts
import { MigrationInterface, QueryRunner } from 'typeorm';

export class test261600082802966 implements MigrationInterface {
  name = 'test261600082802966';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'ALTER TABLE `test` CHANGE `test_update` `test_update` timestamp() NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP()'
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'ALTER TABLE `test` CHANGE `test_update` `test_update` timestamp() NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE current_timestamp()'
    );
  }
}
```
Entity file test.ts
```ts
import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class test extends BaseEntity {
  @PrimaryGeneratedColumn({})
  test_id: number;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP()',
    onUpdate: 'CURRENT_TIMESTAMP()',
    nullable: false,
  })
  test_update: Date;
}
```

* Update MysqlQueryRunner.ts

* add test to issue 6714

* Update MysqlQueryRunner.ts

* Update issue-6714.ts

Co-authored-by: jesusegado <j.fernandez@lionline.de>
2020-09-17 16:12:51 +05:00
James Ward
8820d4a871
test: disable logging for test 1960 (#6721)
this test was emitting logs for no real reason so this removes the
`logging: true` when creating the testing connection
2020-09-17 16:11:31 +05:00
James Ward
96eddfba85
chore: explicitly pull in typescript 3.9 (#6724)
this bumps the version of typescript accepted to >=3.9.7,<4.0
we were implicitly pulling in that version (per the package-lock.json)
so this just codifies it in the package.json as well
2020-09-17 16:09:55 +05:00
James Ward
4baac71086
style: backport style fixes in next to cut down on churn (#6715)
the `next` branch has a number of style fixes for the project aroundnd
whitespaces - this pulls them into `master` to cut down on the files
changes between the two branches
2020-09-15 16:33:27 +05:00
James Ward
2b3780836f
fix: backport FindOperator return types (#6717)
the `next` branch added return types to `FindOperator`s and
this backports that change
2020-09-15 16:27:24 +05:00
Juuso Mikkonen
b50576e102
docs: correct the comment of OneToMany decorator (#6712) 2020-09-14 16:12:10 +05:00
James Ward
208cf6b051
fix: prevent multiple release listeners in PostgresQueryRunner (#6708)
move on-error-release code to the queryRunner connect function
so we only need to have one listener per query runner on each
connection - cutting donw the number of listeners total &
preventing a problem with too many listeners

closes #6699
2020-09-14 16:10:13 +05:00
James Ward
7a52f18c86
feat: backport SQLite Busy handler & WAL mode enable (#6588)
* added sqlitebusy handling logic

* added sqlite wal mode enable logic

* cleaner if block

* move pragma journal mode setting to driver connection

* add enable-wal test

Co-authored-by: Umed Khudoiberdiev <zarrhost@gmail.com>
2020-09-13 02:57:33 +05:00
Arty
370442c27a
feat: Beautify generated SQL for migrations (#6685)
* feat: Beautify generated SQL for migrations

Allows user to pass an optional flag to beautify generated SQL for migrations

Closes: #4415

* fixed formatter version

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2020-09-13 01:36:05 +05:00
James Ward
330262d9a4
chore: bump all package versions except typescript (#6696)
also updates some tests to support typing changes
2020-09-13 01:31:26 +05:00
James Ward
8b68f40a01
feat: create EntityTarget and use instead of EntitySchema / ObjectType / etc (#6701) 2020-09-11 18:39:37 +05:00
James Ward
9583430e82
fix: hdb-pool is not namespaced under @sap (#6700)
closes #6697
2020-09-11 18:36:57 +05:00
James Ward
ea59b8d46b
fix: sql.js v1.2+ don't support undefined parameters (#6698)
before sql.js 1.2 it seems undefined were treated as if they were null,
but as of 1.2 they cause a query error & fail to execute

this change swaps out any undefined parameters with `null`s

closes #5720
2020-09-11 18:34:58 +05:00
Umed Khudoiberdiev
7167903229 version bump 0.2.26 2020-09-10 12:30:30 +05:00
Michael Bromley
7ddaf23e47
fix: unnecessary migrations for unsigned numeric types (#6632)
* fix: Unnecessary migrations for unsigned numeric types

In MariaDB, unsigned numeric types (``<tiny,small,medium>int`) without an explicit `width` property set would generate migrations on every run. This is due to an error in setting the default width for unsigned types.

Fixes #2943

* test: Enable all tests

* refactor: Move isDefaultColumnWidth() method out of BaseQueryRunner

See https://github.com/typeorm/typeorm/pull/6632#pullrequestreview-480932808 for discussion as to why.

* fix: Correct unsigned int behaviour for MySQL 5.7

* fix: Correct position of zerofill check

Plus stylistic change based on code review
2020-09-10 12:21:19 +05:00
Jaan Oras
ae3cf0efb1
fix: handle 'error' events from pool connection (#6262) 2020-09-08 19:31:12 +05:00
Gareth Parker
2d4a8d7f48
test: Testing that the discriminatorValue gets saved for ChildEntity when saved by cascade (#6671)
* test: Testing that the discriminatorValue gets saved for ChildEntity when saved by cascade

* test: Update assertions to not be specific to retrieval order

Co-authored-by: Gareth Parker <gareth.parker@ros.gov.uk>
2020-09-08 18:39:33 +05:00
Cristian Magalhães
620a2432ba
docs: update query runner examples (#6680)
* refactor: add two examples to use timesteamp when create migration using js/ts

* refactor: add two examples to use timesteamp when create migration using js/ts
2020-09-08 18:38:55 +05:00
Tulio Molina
a8b2845d08
docs: update select-query-builder.md (#6681)
Found a typo on the "Adding WHERE expression" section: user.firstName is used in the SQL snippet where you actually meant user.id
2020-09-08 18:37:13 +05:00
Michael
8b8bc353d0
fix: add missing schema for OracleDriver (#6673) 2020-09-06 19:38:35 +05:00
James Ward
802e0f6e8a
test: escape table name for Github #4410 (#6672) 2020-09-05 19:25:40 +05:00
James Ward
fa21f874a5
build: add oracle to CI (#6623)
* build: add oracle to build database services

* only enable test 1972 for MySQL

* disable github issue 3118 for oracle
2020-09-05 04:20:54 +05:00
Sebastian Domagała
23110d1646
fix: update query deep partial TypeScript definition (#6085)
User should be able to pass function if field is an array
2020-09-04 22:25:01 +05:00
ZBAGI
16a2d8023d
fix: Child entities not being saved correctly with cascade actions (#6219)
* fix: Child entities not being saved correctly with cascade actions

* fixes tslint complains
2020-09-04 21:39:00 +05:00
Json Choi
4fc4a1b4eb
fix: make only a single SELECT to get inserted default and generated values of multiple entities (#6669)
* fix: re-select inserted default and generated values with a single SELECT

closes #6266

* test: add test case for fix of #6266

* fix lint error
2020-09-04 15:56:46 +05:00
Json Choi
ef2011d7e9
fix: get correct insert ids for multiple entities inserted (#6668)
* fix: (sqlite) get correct increment primary key for mutiple entities inserted

Closes: #2131

* fix: (mysql) get correct increment primary key for mutiple entities inserted

Closes: #5973

* test: add test case for fix of #2131

* docs: update note about sqlite lastID
2020-09-04 15:37:41 +05:00
Michael Bromley
c81b405a36
fix: Unnecessary migrations for fulltext indices (#6634)
* fix: Unnecessary migrations for fulltext indices

Fixes #6633 (see issue for root cause explanation)

* test: Enable all tests

* refactor: Add `isFullTextColumnTypeSupported()` method to Driver interface

* fix: Include isFullTextColumnTypeSupported method in SqlServerDriver
2020-09-04 15:37:04 +05:00
Umed Khudoiberdiev
df70dc39b5 added directory typing 2020-09-04 13:20:43 +05:00
Umed Khudoiberdiev
a50e09ab66 added directory typing 2020-09-04 13:07:02 +05:00
Michael Bromley
0397e44817
fix: Migration issues with scale & precision in sqlite/sql.js (#6638)
* fix: Migration issues with scale & precision in sqlite/sql.js

Specifying precision or scale properties on columns with SQLite/sql.js would result in migrations being generated even on an unchanged schema.

This was due to the precision and scale arguments not correctly being inferred when reading the table. This change handles scale and precision in the same way that "length" was already being correctly handled.

Fixes #6636

* awaited the test

* fix missing async

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
2020-09-03 17:47:16 +05:00
James Ward
490ad0d424
refactor: only use PlatformTools.load for optional dependencies (#6630) 2020-09-03 13:07:49 +05:00
Tomas Reimers
2b5f139cea
feat: support absolute paths in migrationsDir for the CLI (#6660)
Right now the CLI will ALWAYS prepend the CWD to `options.cli.migrationsDir`. 

This prevents us from using absolute paths there. 

How would we feel about changing that to support absolute paths (by only prepending CLI if the path DOES NOT start with "/")? If we're open to it, I'm happy to make the change for the other CLI commands as well.
2020-09-03 12:50:37 +05:00
James Ward
cf3ad6211a
fix: pass ids_ to alias builder to prevent length overflow (#6624) 2020-09-02 20:46:14 +05:00
James Ward
4f7481b55a
chore: instead of require, import chalk from chalk (#6637) 2020-09-02 19:47:36 +05:00
Arty
c99ba4052d
feat: FileLogger accepts custom file path (#6642)
This allows users to override default log filepath and save typeorm logs in a custom location

Closes: #4410
2020-09-02 19:41:55 +05:00
xgqfrms
85c07fda2f
docs: update zh_CN link path (#6652)
* update zh_CN link path

* Update README-zh_CN.md
2020-09-02 18:49:00 +05:00
Umed Khudoiberdiev
10b05a9210
removing gitads 2020-09-02 12:15:27 +05:00
James Ward
d1ed5723bb
build: use docker-compose for database services (#6602) 2020-08-24 13:12:03 +05:00
Matthias Kunnen
8d90d40362
fix: DeepPartial with any and {[k: string]: any} (#6581)
* test: Test DeepPartial with any and {[k: string]: any}

This tests #6580.

* fix: DeepPartial with any and {[k: string]: any}

Fixes #6580.
2020-08-23 13:35:16 +05:00
Lachlan McCarty
9d2df28b4c
fix: change InsertQueryBuilder.values() with an empty array into a no-op (#6584)
Change InsertQueryBuilder.values() with an empty array into a no-op instead of the current behavior of inserting a row of DEFAULT values.

Closes: #3111
2020-08-23 13:29:30 +05:00
James Ward
5a9150e65e
chore: remove uneccessary cockroachdriver calls in view-entity tests (#6587)
this is a backport of changes from the `next` branch
2020-08-20 00:04:19 +05:00
James Ward
10d0aea9c0
chore: pin version of cockroach to a known good version (#6585) 2020-08-19 22:15:18 +05:00
James Ward
c96ab43f3c
build: use npm install to work around npm/cli#558 (#6571)
the lockfile we use was generated on a mac & includes
`fsevents` as a dependency. while this is optional for
OSX it's not available for linux & this causes problems
with the `npm ci` command.  npm v7 will correct this
but until we're using that we should switch to
using npm install
2020-08-18 00:21:13 +05:00
dependabot[bot]
31029bdfd4
chore(deps-dev): bump class-transformer from 0.2.3 to 0.3.1 (#6532)
Bumps [class-transformer](https://github.com/typestack/class-transformer) from 0.2.3 to 0.3.1.
- [Release notes](https://github.com/typestack/class-transformer/releases)
- [Changelog](https://github.com/typestack/class-transformer/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/typestack/class-transformer/compare/v0.2.3...v0.3.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-16 16:21:06 +05:00
James Ward
15afef3c9e
chore: discourage questions as issues (#6535) 2020-08-16 16:15:14 +05:00
Ashwin Ramaswami
92f2554f09
docs: fix typos (#6538) 2020-08-16 15:47:18 +05:00
Ilan
6b795a8b99
docs: update supported-platforms.md (#6545) 2020-08-16 15:46:43 +05:00