Skip to content

Commit

Permalink
Merge branch 'master' into fix-sqlite-dateobject-queries
Browse files Browse the repository at this point in the history
  • Loading branch information
imnotjames committed Jul 9, 2021
2 parents 22f94c4 + dcdaaca commit 7ef1ee7
Show file tree
Hide file tree
Showing 387 changed files with 11,764 additions and 5,376 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ workflows:
matrix:
parameters:
node-version:
- "10"
- "12"
- "13"
- "14"
- test:
name: test (cockroachdb) - Node v12
requires:
Expand Down
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
## [0.2.34](https://github.com/typeorm/typeorm/compare/0.2.33...0.2.34) (2021-06-03)

### Bug Fixes

* restored `buildColumnAlias` for backward compatibility ([#7706](https://github.com/typeorm/typeorm/issues/7706)) ([36ceefa](https://github.com/typeorm/typeorm/commit/36ceefa710c0994e054c8e267a1fb1bdf4b25c39))

## [0.2.33](https://github.com/typeorm/typeorm/compare/0.2.32...0.2.33) (2021-06-01)

### Bug Fixes

* @Unique constraint is not created with specified name ([beea2e1](https://github.com/typeorm/typeorm/commit/beea2e1e4429d13d7864ebc23aa6e58fa01647ea))
* `MATERIALIZED VIEW` is treated as a regular `VIEW` which causes issues on sync ([#7592](https://github.com/typeorm/typeorm/issues/7592)) ([f85f436](https://github.com/typeorm/typeorm/commit/f85f436f51fb000cd9959b44e8d7a79bf0cd10ab))
* added error handler for slave connections in MySQL and AuroraDataApi drivers ([#7641](https://github.com/typeorm/typeorm/issues/7641)) ([882a740](https://github.com/typeorm/typeorm/commit/882a7409e5bd018fad6c04925ff5ccaa7e9e7db2))
* call listeners for array embeddeds in MongoDB ([#4260](https://github.com/typeorm/typeorm/issues/4260)) ([2dc355b](https://github.com/typeorm/typeorm/commit/2dc355b50179a18fe690924797f5c69f2fe23c1f))
* closing pool incorrectly works on Postgres ([#7596](https://github.com/typeorm/typeorm/issues/7596)) ([1310c97](https://github.com/typeorm/typeorm/commit/1310c97ff3092b9ff23b2fe83d6b7763beb4316b)), closes [#6958](https://github.com/typeorm/typeorm/issues/6958) [#6958](https://github.com/typeorm/typeorm/issues/6958) [#6958](https://github.com/typeorm/typeorm/issues/6958)
* column name with empty spaces causes bug in Index/Unique decorators [#7534](https://github.com/typeorm/typeorm/issues/7534) ([a3a6e06](https://github.com/typeorm/typeorm/commit/a3a6e063a37fbe1444ffd0c8b1d93bf3ea90e75d))
* correctly strip type conversion in postgres for default values ([#7681](https://github.com/typeorm/typeorm/issues/7681)) ([069b8b6](https://github.com/typeorm/typeorm/commit/069b8b6888c389d93ff44ca6ed964fb5913d9840)), closes [#1532](https://github.com/typeorm/typeorm/issues/1532) [#7647](https://github.com/typeorm/typeorm/issues/7647) [#5132](https://github.com/typeorm/typeorm/issues/5132)
* datetime functions in column "default" leads to unnecessary queries during synchronization ([#7517](https://github.com/typeorm/typeorm/issues/7517)) ([03f3285](https://github.com/typeorm/typeorm/commit/03f328583750ed08272fc1a640adcd13e82f09af)), closes [#3991](https://github.com/typeorm/typeorm/issues/3991) [#3991](https://github.com/typeorm/typeorm/issues/3991) [#2737](https://github.com/typeorm/typeorm/issues/2737) [#2737](https://github.com/typeorm/typeorm/issues/2737) [#6412](https://github.com/typeorm/typeorm/issues/6412) [#4281](https://github.com/typeorm/typeorm/issues/4281) [#4658](https://github.com/typeorm/typeorm/issues/4658) [#3991](https://github.com/typeorm/typeorm/issues/3991) [#2333](https://github.com/typeorm/typeorm/issues/2333) [#7381](https://github.com/typeorm/typeorm/issues/7381) [#4658](https://github.com/typeorm/typeorm/issues/4658) [#3991](https://github.com/typeorm/typeorm/issues/3991) [#3991](https://github.com/typeorm/typeorm/issues/3991) [#3991](https://github.com/typeorm/typeorm/issues/3991) [#3991](https://github.com/typeorm/typeorm/issues/3991)
* default `schema` defined in entity/connection leads to unnecessary queries during schema sync ([#7575](https://github.com/typeorm/typeorm/issues/7575)) ([7eb0327](https://github.com/typeorm/typeorm/commit/7eb032705912cbf4ee340ed9e49970d0f6e23714)), closes [#7276](https://github.com/typeorm/typeorm/issues/7276) [#7276](https://github.com/typeorm/typeorm/issues/7276)
* do a deep comparison to see if the default value has changed for `json` types in Postgres ([#7650](https://github.com/typeorm/typeorm/issues/7650)) ([a471c1b](https://github.com/typeorm/typeorm/commit/a471c1b689848e7cd9203dcef5edd192019ea456))
* Incorrect migration generated when multiple views are updated in a single migration ([#7587](https://github.com/typeorm/typeorm/issues/7587)) ([0b103dd](https://github.com/typeorm/typeorm/commit/0b103dd0347737c91510c7ed4719a289dacf8d3b)), closes [#7586](https://github.com/typeorm/typeorm/issues/7586)
* issues with custom enum name in Postgres ([#7661](https://github.com/typeorm/typeorm/issues/7661)) ([ad0262a](https://github.com/typeorm/typeorm/commit/ad0262a116e5366b562e70a1bbc60246add78d83)), closes [#7614](https://github.com/typeorm/typeorm/issues/7614) [#7541](https://github.com/typeorm/typeorm/issues/7541) [#7647](https://github.com/typeorm/typeorm/issues/7647) [#6540](https://github.com/typeorm/typeorm/issues/6540)
* mongodb connectionURL parse options ([#7560](https://github.com/typeorm/typeorm/issues/7560)) ([b2ac41a](https://github.com/typeorm/typeorm/commit/b2ac41a706635aba37b204eaf7ebf52aaee91104))
* mongodb typings for Cursor ([#7526](https://github.com/typeorm/typeorm/issues/7526)) ([daf3991](https://github.com/typeorm/typeorm/commit/daf399171996d578f0607dd0631647bed59ff212))
* only first \0 is removed in comments, only first \\ is escaped etc. ([#7532](https://github.com/typeorm/typeorm/issues/7532)) ([36b14cb](https://github.com/typeorm/typeorm/commit/36b14cbd808d73c61c9308d66291cf06e860419a))
* pass `ManyToMany` `onUpdate` option to foreign key metadata ([#5714](https://github.com/typeorm/typeorm/issues/5714)) ([198d2c5](https://github.com/typeorm/typeorm/commit/198d2c50acab9d0d748194506970415866247da4)), closes [#4980](https://github.com/typeorm/typeorm/issues/4980)
* Postgres identifier exceeds limit on eager relations ([#7508](https://github.com/typeorm/typeorm/issues/7508)) ([#7509](https://github.com/typeorm/typeorm/issues/7509)) ([e4ec429](https://github.com/typeorm/typeorm/commit/e4ec429fe518c26f4c95175a482bde143d508254))
* remove `enableExtension` for slave connections in Postgres ([#7693](https://github.com/typeorm/typeorm/issues/7693)) ([620aac9](https://github.com/typeorm/typeorm/commit/620aac9e0f2c089f78c7a055b2fb844a475a7eb5)), closes [#7691](https://github.com/typeorm/typeorm/issues/7691)
* replaced deprecated `insert` method with `insertOne` for MongoDriver in MigrationExecutor. ([#7594](https://github.com/typeorm/typeorm/issues/7594)) ([83fed60](https://github.com/typeorm/typeorm/commit/83fed60cccc498d1c5776c05a5aa3ad47c50453e))
* resolve issue when enum that has functions is used in entity ([#7653](https://github.com/typeorm/typeorm/issues/7653)) ([dba327d](https://github.com/typeorm/typeorm/commit/dba327d426f591317f8210302107b95be1a5b420)), closes [#7651](https://github.com/typeorm/typeorm/issues/7651)
* Silent failure in createDatabase and dropDatabase with Postgres ([#7590](https://github.com/typeorm/typeorm/issues/7590)) ([974d2d4](https://github.com/typeorm/typeorm/commit/974d2d4efb0bdcf57e0522b4da3c94ab2937427b)), closes [#6867](https://github.com/typeorm/typeorm/issues/6867)
* STI types on children in joins ([#3160](https://github.com/typeorm/typeorm/issues/3160)) ([60a6c5d](https://github.com/typeorm/typeorm/commit/60a6c5d9607e06bfb2ff842d733ff90ce8b279ea))
* use `host` if `hostReplicaSet` is not provided in MongoDriver ([#7559](https://github.com/typeorm/typeorm/issues/7559)) ([9b6d7bc](https://github.com/typeorm/typeorm/commit/9b6d7bc4189f7741f0f823d65fc5c8ba4fbc2d94))
* use migrationsTransactionMode while running migration from cli ([#7576](https://github.com/typeorm/typeorm/issues/7576)) ([7953ebb](https://github.com/typeorm/typeorm/commit/7953ebb40f2b685f3d578bcf2be403f61e544205))
* use most specific matching relation type ([#2967](https://github.com/typeorm/typeorm/issues/2967)) ([ee3c00a](https://github.com/typeorm/typeorm/commit/ee3c00a686f1296bbe3bc3d0b7e1bd29333b358f))


### Features

* add `orphanedRowAction` option to EntitySchemaRelationOptions ([#7625](https://github.com/typeorm/typeorm/issues/7625)) ([a8eb49a](https://github.com/typeorm/typeorm/commit/a8eb49a3647d601531a6c3cb8404e1941a9d1f9c)), closes [#7417](https://github.com/typeorm/typeorm/issues/7417)
* add `set` datatype support for aurora-data-api ([#7665](https://github.com/typeorm/typeorm/issues/7665)) ([b6c1836](https://github.com/typeorm/typeorm/commit/b6c18366c3fe294f864ab4cd97c0bfc91e9d1f9d))
* add support for specifying `ioredis` cache with a URL ([#7689](https://github.com/typeorm/typeorm/issues/7689)) ([e017f9b](https://github.com/typeorm/typeorm/commit/e017f9b4683e12feb485b878ab002c42c1d63ffb)), closes [#7631](https://github.com/typeorm/typeorm/issues/7631)
* add tree entities update and delete logic ([#7156](https://github.com/typeorm/typeorm/issues/7156)) ([9c8a3fb](https://github.com/typeorm/typeorm/commit/9c8a3fbad7cf737ee514924ed8871a703768fddc)), closes [#7155](https://github.com/typeorm/typeorm/issues/7155)
* added Capacitor driver ([#7695](https://github.com/typeorm/typeorm/issues/7695)) ([0f7a778](https://github.com/typeorm/typeorm/commit/0f7a7783984c680350dd7560f47b78733a3ff3c5))
* cache option to ignore errors ([#7630](https://github.com/typeorm/typeorm/issues/7630)) ([5fde0ea](https://github.com/typeorm/typeorm/commit/5fde0ea89fb7c4942d7bbbe21f6bfbbe620347e5)), closes [#926](https://github.com/typeorm/typeorm/issues/926)
* define class properties for QueryFailedError to allow users to access a typed error ([#7529](https://github.com/typeorm/typeorm/issues/7529)) ([b43dcba](https://github.com/typeorm/typeorm/commit/b43dcba84e5bfa55baa7426a5059448207437f2d))
* support `MAX_EXECUTION_TIME ` for MySQL driver. ([#7638](https://github.com/typeorm/typeorm/issues/7638)) ([0564c34](https://github.com/typeorm/typeorm/commit/0564c348b9bd779e9f24cbf340ea48b6badc9f7e))

## [0.2.32](https://github.com/typeorm/typeorm/compare/0.2.31...0.2.32) (2021-03-30)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Anyone can file an expense. If the expense makes sense for the development of th
### Contributors

Thank you to all the people who have already contributed to typeorm!
<a href="graphs/contributors"><img src="https://opencollective.com/typeorm/contributors.svg?width=890" /></a>
<a href="../../graphs/contributors"><img src="https://opencollective.com/typeorm/contributors.svg?width=890" /></a>


### Backers
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ It will also modify the `photo` table, adding a new `author` column and creating

### Creating a many-to-many relation

Let's create a many-to-one / many-to-many relation.
Let's create a many-to-many relation.
Let's say a photo can be in many albums, and each album can contain many photos.
Let's create an `Album` class:

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ services:

# cockroachdb
cockroachdb:
image: "cockroachdb/cockroach:v19.2.9"
image: "cockroachdb/cockroach:latest-v21.1"
container_name: "typeorm-cockroachdb"
command: start --insecure
command: start-single-node --insecure --cache=.25 --store=type=mem,size=.25 --logtostderr=NONE --log-dir=""
ports:
- "26257:26257"

Expand Down
20 changes: 20 additions & 0 deletions docs/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,24 @@ class CustomQueryResultCache implements QueryResultCache {
}
```

If you wish to ignore cache errors and want the queries to pass through to database in case of cache errors, you can use ignoreErrors option.
Example:

```typescript
{
type: "mysql",
host: "localhost",
username: "test",
...
cache: {
type: "redis",
options: {
host: "localhost",
port: 6379
},
ignoreErrors: true
}
}
```

You can use `typeorm cache:clear` to clear everything stored in the cache.
19 changes: 17 additions & 2 deletions docs/connection-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [`postgres` / `cockroachdb` connection options](#postgres--cockroachdb-connection-options)
* [`sqlite` connection options](#sqlite-connection-options)
* [`better-sqlite3` connection options](#better-sqlite3-connection-options)
* [`capacitor` connection options](#capacitor-connection-options)
* [`cordova` connection options](#cordova-connection-options)
* [`react-native` connection options](#react-native-connection-options)
* [`nativescript` connection options](#nativescript-connection-options)
Expand All @@ -23,8 +24,8 @@ Connection options is a connection configuration you pass to `createConnection`
## Common connection options

* `type` - Database type. You must specify what database engine you use.
Possible values are "mysql", "postgres", "cockroachdb", "mariadb", "sqlite", "better-sqlite3", "cordova", "nativescript",
"oracle", "mssql", "mongodb", "sqljs", "react-native".
Possible values are "mysql", "postgres", "cockroachdb", "mariadb", "sqlite", "better-sqlite3", "capacitor", "cordova",
"nativescript", "oracle", "mssql", "mongodb", "sqljs", "react-native".
This option is **required**.

* `name` - Connection name. You'll use it to get connection you need using `getConnection(name: string)`
Expand Down Expand Up @@ -71,6 +72,10 @@ Learn more about [Naming strategies](./naming-strategy.md).

* `entityPrefix` - Prefixes with the given string all tables (or collections) on this database connection.

* `entitySkipConstructor` - Indicates if TypeORM should skip constructors when deserializing entities
from the database. Note that when you do not call the constructor both private properties and default
properties will not operate as expected.

* `dropSchema` - Drops the schema each time connection is being established.
Be careful with this option and don't use this in production - otherwise you'll lose all production data.
This option is useful during debug and development.
Expand Down Expand Up @@ -184,6 +189,8 @@ See [SSL options](https://github.com/mysqljs/mysql#ssl-options).

* `logNotifications` - A boolean to determine whether postgres server [notice messages](https://www.postgresql.org/docs/current/plpgsql-errors-and-messages.html) and [notification events](https://www.postgresql.org/docs/current/sql-notify.html) should be included in client's logs with `info` level (default: `false`).

* `installExtensions` - A boolean to control whether to install necessary postgres extensions automatically or not (default: `true`)

## `sqlite` connection options

* `database` - Database path. For example "./mydb.sql"
Expand All @@ -196,6 +203,14 @@ See [SSL options](https://github.com/mysqljs/mysql#ssl-options).

* `prepareDatabase` - Function to run before a database is used in typeorm. You can access original better-sqlite3 Database object here.

## `capacitor` connection options

* `database` - Database name (capacitor-sqlite will add the suffix `SQLite.db`)

* `driver` - The capacitor-sqlite instance. For example, `new SQLiteConnection(CapacitorSQLite)`.

* `journalMode` - The SQLite journal mode (optional)

## `cordova` connection options

* `database` - Database name
Expand Down
1 change: 1 addition & 0 deletions docs/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ You can change it by specifying your own name.
* `charset: string` - Defines a column character set. Not supported by all database types.
* `collation: string` - Defines a column collation.
* `enum: string[]|AnyEnum` - Used in `enum` column type to specify list of allowed enum values. You can specify array of values or specify a enum class.
* `enumName: string` - Defines the name for the used enum.
* `asExpression: string` - Generated column expression. Used only in [MySQL](https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html).
* `generatedType: "VIRTUAL"|"STORED"` - Generated column type. Used only in [MySQL](https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html).
* `hstoreType: "object"|"string"` - Return type of `HSTORE` column. Returns value as string or as object. Used only in [Postgres](https://www.postgresql.org/docs/9.6/static/hstore.html).
Expand Down
7 changes: 5 additions & 2 deletions docs/find-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ userRepository.find({
relations: ["profile", "photos", "videos"],
where: {
firstName: "Timber",
lastName: "Saw"
lastName: "Saw",
profile: {
userName: "tshaw"
}
},
order: {
name: "ASC",
Expand Down Expand Up @@ -408,7 +411,7 @@ If you need to provide user input, you should not include the user input directl
import {Raw} from "typeorm";

const loadedPosts = await connection.getRepository(Post).find({
currentDate: Raw(alias =>`${alias} > ':date'`, { date: "2020-10-06" })
currentDate: Raw(alias =>`${alias} > :date`, { date: "2020-10-06" })
});
```

Expand Down
2 changes: 1 addition & 1 deletion docs/many-to-one-one-to-many-relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ photo2.user = user;
await connection.manager.save(photo2);
```

With [cascades](https://github.com/typeorm/typeorm/blob/master/docs/relations.md#cascades) enabled you can save this relation with only one `save` call.
With [cascades](./relations.md#cascades) enabled you can save this relation with only one `save` call.

To load a user with photos inside you must specify the relation in `FindOptions`:

Expand Down
7 changes: 6 additions & 1 deletion docs/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ typeorm migration:run

Example with `ts-node`:
```
ts-node ./node_modules/typeorm/cli.js migration:run
ts-node --transpile-only ./node_modules/typeorm/cli.js migration:run
```

Example `ts-node` not using `node_modules` directly:
```
ts-node $(yarn bin typeorm) migration:run
```

This command will execute all pending migrations and run them in a sequence ordered by their timestamps.
Expand Down
2 changes: 1 addition & 1 deletion docs/multiple-connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ If you want to use `slave` in raw queries, you also need to explicitly specify t

const slaveQueryRunner = connection.createQueryRunner("slave");
try {
const userFromSlave = await connection.query('SELECT * FROM users WHERE id = $1', [userId], slaveQueryRunner);
const userFromSlave = await slaveQueryRunner.query('SELECT * FROM users WHERE id = $1', [userId], slaveQueryRunner);
} finally {
return slaveQueryRunner.release();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/one-to-one-relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ user.profile = profile;
await connection.manager.save(user);
```

With [cascades](https://github.com/typeorm/typeorm/blob/master/docs/relations.md#cascades) enabled you can save this relation with only one `save` call.
With [cascades](./relations.md#cascades) enabled you can save this relation with only one `save` call.

To load user with profile inside you must specify relation in `FindOptions`:

Expand Down
2 changes: 1 addition & 1 deletion docs/relational-query-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ post.categories = await getConnection()

post.author = await getConnection()
.createQueryBuilder()
.relation(User, "user")
.relation(Post, "user")
.of(post) // you can use just post id as well
.loadOne();
```

0 comments on commit 7ef1ee7

Please sign in to comment.