Skip to content

Commit

Permalink
Chore/flowaccount update (#2)
Browse files Browse the repository at this point in the history
* docs: fix small typo on package.json script example (typeorm#7408)

Add missing colon in JSON property at `package.json` `"script"` example

* feat: output Javascript Migrations instead of TypeScript (typeorm#7294)

* docs / test: Added tests and documentation for Feature 7253 - Migrations Javascript output

* Change in the test

* test: Re-arranged the tests to move them to the core tests directory

* tests: Adjusted Tests a bit

* tests - renamed tests to follow the other functional tests naming

* tests - renamed tests to follow the other functional tests naming

* tests - Fixed issues with the test connections setup

* tests - Removed unnecesary restore

* fix: improve EntityManager.save() return type (typeorm#7391)

This brings it in line with the equivalent method in Repository.

* fix: resolve issue building tree entities with embeded primary column (typeorm#7416)

Closes: typeorm#7415

* Adjust mongodb driver options & connect driver to support replica set (typeorm#7402)

- Dupplicate buildDriverOptions for mongodb especially
- Add hostReplicaSet to MongoConnectionOptions properties for collect host replica list
- Adjust buildConnectionUrl to build replica set connection url

* fix: performance issues of `RelationId`. (typeorm#7318)

* test: relationId is too slow

* perf: RelationId is too slow

When we join a lot of relations we can get 1k+ records from db even it is only 10 entities. Then when relationId are loaded the query contains too many duplciates for the same ids. The solution is to check that the relationId query fetches only unique values.

Closes: typeorm#5691

* fix: Array type default value should not generate SQL commands without change (typeorm#7409)

* fix(1532) Array type default value should not generate SQL commands without change

* Update PostgresDriver.ts

* removed `arrayCast` from `normalizeDefault` since casting for default value is already removed in `PostgresQueryRunner.loadTables()` method;
* removed support for function definition in `default` because function syntax suppose to support raw sql, we don't have to confuse things by applying custom modifications.

* Update User.ts

removed incorrect `default` definition with functions

Co-authored-by: AlexMesser <dmzt08@gmail.com>

* feat: add check and dryrun to migration generate (typeorm#7275)

Adds support for “check” and “drynrun” modes to the migration generate command.

Fixes typeorm#3037
Refs typeorm#6978

* chore: typescript version upgrade (typeorm#7422)

* chore: dependencies update (typeorm#7424)

* typescript version upgrade

* fixing linting

* fixing mongo query runner issues

* fixing linting

* updated all dependencies

* fixes typeorm#7418

* fixes typeorm#7418

* adding missing ILike operator docs (took from next branch)

* fix: mongodb connectionurl parse options (#1)

* fix: mongodb connectionurl parse options

- Loop every options in mongodb connection url and turn it as object to merge with connection url object before return of method "parseMongoDBConnectionUrl"
- unit test of mongodb replicaset parse connectionurl of typeorm#7401
- unit test of mongodb options parse connectionurl of typeorm#7437

* fix: add semicolon by lint suggestion

/home/circleci/typeorm/src/driver/DriverUtils.ts
  192:39  error  Missing semicolon  @typescript-eslint/semi

* chore: @beamdev package scope (#2)

* chore: update master (typeorm#3)

* fix: fixed all known enum issues (typeorm#7419)

* fix typeorm#5371

* fix typeorm#6471;
fix: `enumName` changes not handled;
fix: `enumName` does not handle table schema;

* fixed falling test;

* added test for typeorm#7217

* fix typeorm#6047, typeorm#7283;

* fix typeorm#5871

* added support for `enumName` in `joinColumns` (typeorm#5729)

* fix typeorm#5478

* fixed falling test;
updated `postgres-enum` test;

* added column `array` property change detection (typeorm#5882);
updated `postgres-enum` test;

* fix typeorm#5275

* added validation for `enum` property (typeorm#2233)

* fix typeorm#5648

* improved missing "enum" or "enumName" properties validation;

* fix typeorm#4897, typeorm#6376

* lint fix;

* fixed falling tests;

* fixed falling tests;

* removed .only

* fix typeorm#6115

* refactor: improve README.md and DEVLOPER.md code examples formatting (typeorm#7436)

* fix: correctly get referenceColumn value in `getEntityValueMap` (typeorm#7005)

* test: add test case (typeorm#7002)

* fix: correctly get referenceColumn value in `getEntityValueMap`

* test: reproduction for issue typeorm#3246 (typeorm#3247)

* Add reproduction for issue 3246

* Update test/github-issues/3246/issue-3246.ts

Co-authored-by: Json Choi <1890mah@gmail.com>

Co-authored-by: Dan Imbrogno <dan.imbrogno@gmail.com>
Co-authored-by: AlexMesser <dmzt08@gmail.com>
Co-authored-by: Json Choi <1890mah@gmail.com>

* code refactoring in test;

* added test for typeorm#2758

* feat: allow to pass the given table name as string in RelationDecorators (typeorm#7448)

* feat(RelationDecorators): allow to pass the given table name as string

* Update EntityMetadataBuilder.ts

added parentheses;

Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>

* feat: add option for installing package using CLI (typeorm#6889)

* init cli: add options for installing package

* yarg choice, add await, revert formatter changes

* init flag - set default to npm

Co-authored-by: AlexMesser <dmzt08@gmail.com>
Co-authored-by: Henry Boisdequin <boisdequinhenry19@gmail.com>
Co-authored-by: Json Choi <1890mah@gmail.com>
Co-authored-by: Dan Imbrogno <41128441+danimbrogno-pml@users.noreply.github.com>
Co-authored-by: Dan Imbrogno <dan.imbrogno@gmail.com>
Co-authored-by: Emily Marigold Klassen <forivall@gmail.com>
Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>
Co-authored-by: Gaurav Sharma <gtpan77@gmail.com>

* chore: update master typeorm/typeorm (typeorm#5)

* fix: fixed all known enum issues (typeorm#7419)

* fix typeorm#5371

* fix typeorm#6471;
fix: `enumName` changes not handled;
fix: `enumName` does not handle table schema;

* fixed falling test;

* added test for typeorm#7217

* fix typeorm#6047, typeorm#7283;

* fix typeorm#5871

* added support for `enumName` in `joinColumns` (typeorm#5729)

* fix typeorm#5478

* fixed falling test;
updated `postgres-enum` test;

* added column `array` property change detection (typeorm#5882);
updated `postgres-enum` test;

* fix typeorm#5275

* added validation for `enum` property (typeorm#2233)

* fix typeorm#5648

* improved missing "enum" or "enumName" properties validation;

* fix typeorm#4897, typeorm#6376

* lint fix;

* fixed falling tests;

* fixed falling tests;

* removed .only

* fix typeorm#6115

* refactor: improve README.md and DEVLOPER.md code examples formatting (typeorm#7436)

* fix: correctly get referenceColumn value in `getEntityValueMap` (typeorm#7005)

* test: add test case (typeorm#7002)

* fix: correctly get referenceColumn value in `getEntityValueMap`

* test: reproduction for issue typeorm#3246 (typeorm#3247)

* Add reproduction for issue 3246

* Update test/github-issues/3246/issue-3246.ts

Co-authored-by: Json Choi <1890mah@gmail.com>

Co-authored-by: Dan Imbrogno <dan.imbrogno@gmail.com>
Co-authored-by: AlexMesser <dmzt08@gmail.com>
Co-authored-by: Json Choi <1890mah@gmail.com>

* code refactoring in test;

* added test for typeorm#2758

* feat: allow to pass the given table name as string in RelationDecorators (typeorm#7448)

* feat(RelationDecorators): allow to pass the given table name as string

* Update EntityMetadataBuilder.ts

added parentheses;

Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>

* feat: add option for installing package using CLI (typeorm#6889)

* init cli: add options for installing package

* yarg choice, add await, revert formatter changes

* init flag - set default to npm

Co-authored-by: AlexMesser <dmzt08@gmail.com>
Co-authored-by: Henry Boisdequin <boisdequinhenry19@gmail.com>
Co-authored-by: Json Choi <1890mah@gmail.com>
Co-authored-by: Dan Imbrogno <41128441+danimbrogno-pml@users.noreply.github.com>
Co-authored-by: Dan Imbrogno <dan.imbrogno@gmail.com>
Co-authored-by: Emily Marigold Klassen <forivall@gmail.com>
Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>
Co-authored-by: Gaurav Sharma <gtpan77@gmail.com>

Co-authored-by: rccursach <rccursach@gmail.com>
Co-authored-by: Jorge Luis Vargas <Jorge.Vargas@albelli.com>
Co-authored-by: Anthony Rosequist <arosequist@users.noreply.github.com>
Co-authored-by: Tomas Zaluckij <mrtomaszal@gmail.com>
Co-authored-by: MG <m@sudo.eu>
Co-authored-by: Ed Mitchell <edeesis@gmail.com>
Co-authored-by: AlexMesser <dmzt08@gmail.com>
Co-authored-by: Christian Holm <cho@cubitech.dk>
Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
Co-authored-by: Henry Boisdequin <boisdequinhenry19@gmail.com>
Co-authored-by: Json Choi <1890mah@gmail.com>
Co-authored-by: Dan Imbrogno <41128441+danimbrogno-pml@users.noreply.github.com>
Co-authored-by: Dan Imbrogno <dan.imbrogno@gmail.com>
Co-authored-by: Emily Marigold Klassen <forivall@gmail.com>
Co-authored-by: Emily Marigold Klassen <forivall@users.noreply.github.com>
Co-authored-by: Gaurav Sharma <gtpan77@gmail.com>
  • Loading branch information
17 people committed Mar 17, 2021
1 parent 19391ad commit 5f1ebbf
Show file tree
Hide file tree
Showing 99 changed files with 3,211 additions and 1,581 deletions.
6 changes: 3 additions & 3 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ Most tests will benefit from using this template as a starting point:

```ts
import "reflect-metadata";
import {createTestingConnections, closeTestingConnections, reloadTestingDatabases} from "../../utils/test-utils";
import {Connection} from "../../../src/connection/Connection";
import {expect} from "chai";
import { createTestingConnections, closeTestingConnections, reloadTestingDatabases } from "../../utils/test-utils";
import { Connection } from "../../../src/connection/Connection";
import { expect } from "chai";

describe("github issues > #<issue number> <issue title>", () => {

Expand Down
90 changes: 45 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ And more...
With TypeORM your models look like this:

```typescript
import {Entity, PrimaryGeneratedColumn, Column} from "typeorm";
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";

@Entity()
export class User {
Expand Down Expand Up @@ -124,7 +124,7 @@ await repository.remove(timber);
Alternatively, if you prefer to use the `ActiveRecord` implementation, you can use it as well:

```typescript
import {Entity, PrimaryGeneratedColumn, Column, BaseEntity} from "typeorm";
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm";

@Entity()
export class User extends BaseEntity {
Expand Down Expand Up @@ -373,7 +373,7 @@ You can load/insert/update/remove and perform other operations with them.
Let's make our `Photo` model as an entity:

```typescript
import {Entity} from "typeorm";
import { Entity } from "typeorm";

@Entity()
export class Photo {
Expand All @@ -396,7 +396,7 @@ To add database columns, you simply need to decorate an entity's properties you
with a `@Column` decorator.

```typescript
import {Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";

@Entity()
export class Photo {
Expand Down Expand Up @@ -436,7 +436,7 @@ This is a requirement and you can't avoid it.
To make a column a primary key, you need to use `@PrimaryColumn` decorator.

```typescript
import {Entity, Column, PrimaryColumn} from "typeorm";
import { Entity, Column, PrimaryColumn } from "typeorm";

@Entity()
export class Photo {
Expand Down Expand Up @@ -467,7 +467,7 @@ Now, let's say you want your id column to be auto-generated (this is known as au
To do that, you need to change the `@PrimaryColumn` decorator to a `@PrimaryGeneratedColumn` decorator:

```typescript
import {Entity, Column, PrimaryGeneratedColumn} from "typeorm";
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";

@Entity()
export class Photo {
Expand Down Expand Up @@ -500,7 +500,7 @@ We don't want all our columns to be limited varchars or integers.
Let's setup correct data types:

```typescript
import {Entity, Column, PrimaryGeneratedColumn} from "typeorm";
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";

@Entity()
export class Photo {
Expand Down Expand Up @@ -537,8 +537,8 @@ Now, when our entity is created, let's create an `index.ts` (or `app.ts` whateve

```typescript
import "reflect-metadata";
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection({
type: "mysql",
Expand Down Expand Up @@ -574,7 +574,7 @@ Later, when we create more entities we need to add them to the entities in our c
This is not very convenient, so instead we can set up the whole directory, from where all entities will be connected and used in our connection:

```typescript
import {createConnection} from "typeorm";
import { createConnection } from "typeorm";

createConnection({
type: "mysql",
Expand Down Expand Up @@ -622,8 +622,8 @@ Now if you run your `index.ts`, a connection with database will be initialized a
Now let's create a new photo to save it in the database:

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection(/*...*/).then(connection => {

Expand Down Expand Up @@ -652,8 +652,8 @@ It's not a new copy of the object, it modifies its "id" and returns it.
Let's take advantage of the latest ES8 (ES2017) features and use async/await syntax instead:

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection(/*...*/).then(async connection => {

Expand All @@ -678,8 +678,8 @@ Using entity manager you can manipulate any entity in your app.
For example, let's load our saved entity:

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection(/*...*/).then(async connection => {

Expand All @@ -702,8 +702,8 @@ When you deal with entities a lot, Repositories are more convenient to use than


```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection(/*...*/).then(async connection => {

Expand Down Expand Up @@ -732,8 +732,8 @@ Learn more about Repository [here](./docs/working-with-repository.md).
Let's try more load operations using the Repository:

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection(/*...*/).then(async connection => {

Expand Down Expand Up @@ -765,8 +765,8 @@ createConnection(/*...*/).then(async connection => {
Now let's load a single photo from the database, update it and save it:

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection(/*...*/).then(async connection => {

Expand All @@ -785,8 +785,8 @@ Now photo with `id = 1` will be updated in the database.
Now let's remove our photo from the database:

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";

createConnection(/*...*/).then(async connection => {

Expand All @@ -805,8 +805,8 @@ Let's create a one-to-one relation with another class.
Let's create a new class in `PhotoMetadata.ts`. This PhotoMetadata class is supposed to contain our photo's additional meta-information:

```typescript
import {Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn} from "typeorm";
import {Photo} from "./Photo";
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn } from "typeorm";
import { Photo } from "./Photo";

@Entity()
export class PhotoMetadata {
Expand Down Expand Up @@ -867,9 +867,9 @@ If you run the app, you'll see a newly generated table, and it will contain a co
Now let's save a photo, its metadata and attach them to each other.

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import {PhotoMetadata} from "./entity/PhotoMetadata";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";
import { PhotoMetadata } from "./entity/PhotoMetadata";

createConnection(/*...*/).then(async connection => {

Expand Down Expand Up @@ -915,8 +915,8 @@ To fix this issue we should add an inverse relation, and make relations between
Let's modify our entities:

```typescript
import {Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn} from "typeorm";
import {Photo} from "./Photo";
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn } from "typeorm";
import { Photo } from "./Photo";

@Entity()
export class PhotoMetadata {
Expand All @@ -930,8 +930,8 @@ export class PhotoMetadata {
```

```typescript
import {Entity, Column, PrimaryGeneratedColumn, OneToOne} from "typeorm";
import {PhotoMetadata} from "./PhotoMetadata";
import { Entity, Column, PrimaryGeneratedColumn, OneToOne } from "typeorm";
import { PhotoMetadata } from "./PhotoMetadata";

@Entity()
export class Photo {
Expand Down Expand Up @@ -960,9 +960,9 @@ Let's use `find*` methods first.
`find*` methods allow you to specify an object with the `FindOneOptions` / `FindManyOptions` interface.

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import {PhotoMetadata} from "./entity/PhotoMetadata";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";
import { PhotoMetadata } from "./entity/PhotoMetadata";

createConnection(/*...*/).then(async connection => {

Expand All @@ -980,9 +980,9 @@ Using find options is good and dead simple, but if you need a more complex query
`QueryBuilder` allows more complex queries to be used in an elegant way:

```typescript
import {createConnection} from "typeorm";
import {Photo} from "./entity/Photo";
import {PhotoMetadata} from "./entity/PhotoMetadata";
import { createConnection } from "typeorm";
import { Photo } from "./entity/Photo";
import { PhotoMetadata } from "./entity/PhotoMetadata";

createConnection(/*...*/).then(async connection => {

Expand Down Expand Up @@ -1061,8 +1061,8 @@ Let's say a photo has one author, and each author can have many photos.
First, let's create an `Author` class:

```typescript
import {Entity, Column, PrimaryGeneratedColumn, OneToMany, JoinColumn} from "typeorm";
import {Photo} from "./Photo";
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, JoinColumn } from "typeorm";
import { Photo } from "./Photo";

@Entity()
export class Author {
Expand All @@ -1084,9 +1084,9 @@ export class Author {
Now let's add the owner side of the relation into the Photo entity:

```typescript
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from "typeorm";
import {PhotoMetadata} from "./PhotoMetadata";
import {Author} from "./Author";
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from "typeorm";
import { PhotoMetadata } from "./PhotoMetadata";
import { Author } from "./Author";

@Entity()
export class Photo {
Expand Down Expand Up @@ -1135,7 +1135,7 @@ Let's say a photo can be in many albums, and each album can contain many photos.
Let's create an `Album` class:

```typescript
import {Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable} from "typeorm";
import { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable } from "typeorm";

@Entity()
export class Album {
Expand Down
16 changes: 16 additions & 0 deletions docs/find-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,22 @@ will execute following query:
SELECT * FROM "post" WHERE "title" LIKE '%out #%'
```

* `ILike`

```ts
import {ILike} from "typeorm";

const loadedPosts = await connection.getRepository(Post).find({
title: ILike("%out #%")
});
```

will execute following query:

```sql
SELECT * FROM "post" WHERE "title" ILIKE '%out #%'
```

* `Between`

```ts
Expand Down
21 changes: 19 additions & 2 deletions docs/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Once you have a migration to run on production, you can run them using a CLI com
typeorm migration:run
```

**`typeorm migration:create` and `typeorm migration:generate` will create `.ts` files. The `migration:run` and `migration:revert` commands only work on `.js` files. Thus the typescript files need to be compiled before running the commands.** Alternatively you can use `ts-node` in conjunction with `typeorm` to run `.ts` migration files.
**`typeorm migration:create` and `typeorm migration:generate` will create `.ts` files, unless you use the `o` flag (see more in [Generating migrations](#generating-migrations)). The `migration:run` and `migration:revert` commands only work on `.js` files. Thus the typescript files need to be compiled before running the commands.** Alternatively you can use `ts-node` in conjunction with `typeorm` to run `.ts` migration files.

Example with `ts-node`:
```
Expand Down Expand Up @@ -194,8 +194,25 @@ export class PostRefactoringTIMESTAMP implements MigrationInterface {
}
```

Alternatively you can also output your migrations as Javascript files using the `o` (alias for `--outputJs`) flag. This is useful for Javascript only projects in which TypeScript additional packages are not installed. This command, will generate a new migration file `{TIMESTAMP}-PostRefactoring.js` with the following content:

```javascript
const { MigrationInterface, QueryRunner } = require("typeorm");

module.exports = class PostRefactoringTIMESTAMP {

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "post" ALTER COLUMN "title" RENAME TO "name"`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "post" ALTER COLUMN "title" RENAME TO "name"`);
}
}
```

See, you don't need to write the queries on your own.
The rule of thumb for generating migrations is that you generate them after "each" change you made to your models. To apply multi-line formatting to your generated migration queries, use the `p` (alias for `--pretty`) flag.
The rule of thumb for generating migrations is that you generate them after **each** change you made to your models. To apply multi-line formatting to your generated migration queries, use the `p` (alias for `--pretty`) flag.

## Connection option
If you need to run/revert your migrations for another connection rather than the default, use the `-c` (alias for `--connection`) and pass the config name as an argument
Expand Down
2 changes: 1 addition & 1 deletion docs/using-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ npm install -g ts-node

Add typeorm command under scripts section in package.json
```
"scripts" {
"scripts": {
...
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js"
}
Expand Down
16 changes: 16 additions & 0 deletions docs/zh_CN/find-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@ const loadedPosts = await connection.getRepository(Post).find({
SELECT * FROM "post" WHERE "title" LIKE '%out #%'
```

- `ILike`

```ts
import { ILike } from "typeorm";

const loadedPosts = await connection.getRepository(Post).find({
title: ILike("%out #%")
});
```

将执行以下查询:

```sql
SELECT * FROM "post" WHERE "title" ILIKE '%out #%'
```

- `Between`

```ts
Expand Down

0 comments on commit 5f1ebbf

Please sign in to comment.