mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
build: set TS compile target to ES2021 (#10595)
* build: set TS compile target to ES2021 * docs: update minimum supported node version * build: use @tsconfig/node16
This commit is contained in:
parent
fa86f6f6c3
commit
c22e30f1d2
@ -20,7 +20,7 @@
|
||||
<br>
|
||||
</div>
|
||||
|
||||
TypeORM 是一个 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping) 框架,它可以运行在 NodeJS、Browser、Cordova、PhoneGap、Ionic、React Native、Expo 和 Electron 平台上,可以与 TypeScript 和 JavaScript (ES5,ES6,ES7,ES8)一起使用。 它的目标是始终支持最新的 JavaScript 特性并提供额外的特性以帮助你开发任何使用数据库的(不管是只有几张表的小型应用还是拥有多数据库的大型企业应用)应用程序。
|
||||
TypeORM 是一个 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping) 框架,它可以运行在 NodeJS、Browser、Cordova、PhoneGap、Ionic、React Native、Expo 和 Electron 平台上,可以与 TypeScript 和 JavaScript (ES2021)一起使用。 它的目标是始终支持最新的 JavaScript 特性并提供额外的特性以帮助你开发任何使用数据库的(不管是只有几张表的小型应用还是拥有多数据库的大型企业应用)应用程序。
|
||||
|
||||
不同于现有的所有其他 JavaScript ORM 框架,TypeORM 支持 [Data Mapper](./docs/zh_CN/active-record-data-mapper.md#什么是data-mapper模式) 和 [Active Record](./docs/zh_CN/active-record-data-mapper.md#什么是active-record模式) 模式,这意味着你可以以最高效的方式编写高质量的、松耦合的、可扩展的、可维护的应用程序。
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
TypeORM is an [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)
|
||||
that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms
|
||||
and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8).
|
||||
and can be used with TypeScript and JavaScript (ES2021).
|
||||
Its goal is to always support the latest JavaScript features and provide additional features
|
||||
that help you to develop any kind of application that uses databases - from
|
||||
small applications with a few tables to large-scale enterprise applications
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<div align="center"> <a href="http://typeorm.io/"> <img src="https://github.com/typeorm/typeorm/raw/master/resources/logo_big.png" width="492" height="228"> </a> <br> <br> <a href="https://app.circleci.com/pipelines/github/typeorm/typeorm"> <img src="https://circleci.com/gh/typeorm/typeorm/tree/master.svg?style=shield"> </a> <a href="https://badge.fury.io/js/typeorm"> <img src="https://badge.fury.io/js/typeorm.svg"> </a> <a href="https://codecov.io/gh/typeorm/typeorm"> <img src="https://img.shields.io/codecov/c/github/typeorm/typeorm.svg" alt="Codecov"> </a> <a href="https://join.slack.com/t/typeorm/shared_invite/zt-uu12ljeb-OH_0086I379fUDApYJHNuw"> <img src="https://img.shields.io/badge/chat-on%20slack-blue.svg"> </a> <br> <br>
|
||||
</div>
|
||||
|
||||
TypeORM은 NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo 및 Electron 플랫폼에서 실행할 수 있는 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)이며 TypeScript 및 JavaScript(ES5, ES6, ES7, ES8)와 함께 사용할 수 있다. TypeORM의 목표는 항상 최신 JavaScript 기능을 지원하고 몇 개의 테이블이 있는 작은 응용 프로그램에서 여러 데이터베이스가 있는 대규모 엔터프라이즈 응용 프로그램에 이르기까지 데이터베이스를 사용하는 모든 종류의 응용 프로그램을 개발하는 데 도움이 되는 추가 기능을 제공하는 것이다.
|
||||
TypeORM은 NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo 및 Electron 플랫폼에서 실행할 수 있는 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)이며 TypeScript 및 JavaScript(ES2021)와 함께 사용할 수 있다. TypeORM의 목표는 항상 최신 JavaScript 기능을 지원하고 몇 개의 테이블이 있는 작은 응용 프로그램에서 여러 데이터베이스가 있는 대규모 엔터프라이즈 응용 프로그램에 이르기까지 데이터베이스를 사용하는 모든 종류의 응용 프로그램을 개발하는 데 도움이 되는 추가 기능을 제공하는 것이다.
|
||||
|
||||
TypeORM은 현재 존재하는 다른 모든 JavaScript ORM과 달리 [Active Record](./docs/active-record-data-mapper.md#what-is-the-active-record-pattern) 및 [Data Mapper](./docs/active-record-data-mapper.md#what-is-the-data-mapper-pattern) 패턴을 모두 지원한다. 즉, 고품질의 느슨하게 결합된 확장 가능하고 유지 관리 가능한 애플리케이션을 가장 생산적인 방식으로 작성할 수 있다.
|
||||
|
||||
|
||||
48
gulpfile.ts
48
gulpfile.ts
@ -1,17 +1,13 @@
|
||||
///<reference path="node_modules/@types/node/index.d.ts"/>
|
||||
///<reference path="node_modules/@types/chai/index.d.ts"/>
|
||||
///<reference path="node_modules/@types/mocha/index.d.ts"/>
|
||||
import { Gulpclass, Task, SequenceTask, MergedTask } from "gulpclass";
|
||||
|
||||
import {Gulpclass, Task, SequenceTask, MergedTask} from "gulpclass";
|
||||
|
||||
const fs = require("fs");
|
||||
const gulp = require("gulp");
|
||||
const del = require("del");
|
||||
const shell = require("gulp-shell");
|
||||
const replace = require("gulp-replace");
|
||||
const rename = require("gulp-rename");
|
||||
const sourcemaps = require("gulp-sourcemaps");
|
||||
const ts = require("gulp-typescript");
|
||||
import fs from "fs";
|
||||
import gulp from "gulp";
|
||||
import del from "del";
|
||||
import shell from "gulp-shell";
|
||||
import replace from "gulp-replace";
|
||||
import rename from "gulp-rename";
|
||||
import sourcemaps from "gulp-sourcemaps";
|
||||
import ts from "gulp-typescript";
|
||||
|
||||
@Gulpclass()
|
||||
export class Gulpfile {
|
||||
@ -20,20 +16,12 @@ export class Gulpfile {
|
||||
// General tasks
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a delay and resolves after 15 seconds.
|
||||
*/
|
||||
@Task()
|
||||
wait(cb: Function) {
|
||||
setTimeout(() => cb(), 15000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans build folder.
|
||||
*/
|
||||
@Task()
|
||||
clean(cb: Function) {
|
||||
return del(["./build/**"], cb);
|
||||
async clean() {
|
||||
return del(["./build/**"]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,15 +58,15 @@ export class Gulpfile {
|
||||
@Task()
|
||||
browserCopyTemplates() {
|
||||
return gulp.src("./src/platform/*.template")
|
||||
.pipe(rename((p: any) => { p.extname = '.ts'; }))
|
||||
.pipe(rename((p) => { p.extname = '.ts'; }))
|
||||
.pipe(gulp.dest("./build/browser/src/platform"));
|
||||
}
|
||||
|
||||
@MergedTask()
|
||||
browserCompile() {
|
||||
const tsProject = ts.createProject("tsconfig.json", {
|
||||
module: "es2015",
|
||||
"lib": ["es5", "es6", "dom"],
|
||||
module: "es2020",
|
||||
lib: ["es2021", "dom"],
|
||||
typescript: require("typescript")
|
||||
});
|
||||
const tsResult = gulp.src([
|
||||
@ -97,7 +85,7 @@ export class Gulpfile {
|
||||
}
|
||||
|
||||
@Task()
|
||||
browserClearPackageDirectory(cb: Function) {
|
||||
async browserClearPackageDirectory() {
|
||||
return del([
|
||||
"./build/browser/**"
|
||||
]);
|
||||
@ -117,7 +105,7 @@ export class Gulpfile {
|
||||
"cd ./build/package && npm publish"
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Packs a .tgz from ./build/package directory.
|
||||
*/
|
||||
@ -204,10 +192,10 @@ export class Gulpfile {
|
||||
* Moves all compiled files to the final package directory.
|
||||
*/
|
||||
@Task()
|
||||
packageClearPackageDirectory(cb: Function) {
|
||||
async packageClearPackageDirectory() {
|
||||
return del([
|
||||
"build/package/src/**"
|
||||
], cb);
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
63
package-lock.json
generated
63
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "typeorm",
|
||||
"version": "0.3.18",
|
||||
"version": "0.3.19",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "typeorm",
|
||||
"version": "0.3.18",
|
||||
"version": "0.3.19",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@sqltools/formatter": "^1.2.5",
|
||||
@ -19,7 +19,7 @@
|
||||
"dotenv": "^16.0.3",
|
||||
"glob": "^10.3.10",
|
||||
"mkdirp": "^2.1.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"reflect-metadata": "^0.2.1",
|
||||
"sha.js": "^2.4.11",
|
||||
"tslib": "^2.5.0",
|
||||
"uuid": "^9.0.0",
|
||||
@ -31,10 +31,13 @@
|
||||
"typeorm-ts-node-esm": "cli-ts-node-esm.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node16": "^16.1.1",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/chai": "^4.3.4",
|
||||
"@types/chai-as-promised": "^7.1.5",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/gulp-rename": "^2.0.6",
|
||||
"@types/gulp-sourcemaps": "^0.0.38",
|
||||
"@types/mkdirp": "^1.0.2",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "^18.13.0",
|
||||
@ -43,7 +46,7 @@
|
||||
"@types/source-map-support": "^0.5.6",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"@types/yargs": "^17.0.22",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
||||
"better-sqlite3": "^8.1.0",
|
||||
"chai": "^4.3.7",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
@ -78,12 +81,12 @@
|
||||
"source-map-support": "^0.5.21",
|
||||
"sql.js": "^1.8.0",
|
||||
"sqlite3": "^5.1.4",
|
||||
"ts-node": "^10.9.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typeorm-aurora-data-api-driver": "^2.4.4",
|
||||
"typescript": "^4.9.5"
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.9.0"
|
||||
"node": ">=16.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/typeorm"
|
||||
@ -1297,9 +1300,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@tsconfig/node16": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
|
||||
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
|
||||
"version": "16.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-16.1.1.tgz",
|
||||
"integrity": "sha512-+pio93ejHN4nINX4pXqfnR/fPLRtJBaT4ORaa5RH0Oc1zoYmo2B2koG+M328CQhHKn1Wj6FcOxCDFXAot9NhvA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/app-root-path": {
|
||||
@ -1361,6 +1364,26 @@
|
||||
"chokidar": "^3.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/gulp-rename": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/gulp-rename/-/gulp-rename-2.0.6.tgz",
|
||||
"integrity": "sha512-pvZdJ004TpC4Ohk9l0CxEXzS9E0L72b5n6lkIEIaWUIy/RlqnkDMHVtEC6InDjd4rt0jZKcvTrDKxeT96WUYnw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/vinyl": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/gulp-sourcemaps": {
|
||||
"version": "0.0.38",
|
||||
"resolved": "https://registry.npmjs.org/@types/gulp-sourcemaps/-/gulp-sourcemaps-0.0.38.tgz",
|
||||
"integrity": "sha512-9wm+P44eM/VKZSYwGDwalOH6rnvNckwfPgz0gEUlTzjKH1OsSbexdvE8aKBt+8syEkq827Fu+4gV17/EyUtH9w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/vinyl": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/gulp/node_modules/anymatch": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
|
||||
@ -11715,9 +11738,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/reflect-metadata": {
|
||||
"version": "0.1.14",
|
||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz",
|
||||
"integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A=="
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.1.tgz",
|
||||
"integrity": "sha512-i5lLI6iw9AU3Uu4szRNPPEkomnkjRTaVt9hy/bn5g/oSzekBSMeLZblcjP74AW0vBabqERLLIrz+gR8QYR54Tw=="
|
||||
},
|
||||
"node_modules/regex-not": {
|
||||
"version": "1.0.2",
|
||||
@ -13713,6 +13736,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/ts-node/node_modules/@tsconfig/node16": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
|
||||
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ts-node/node_modules/diff": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||
@ -13862,16 +13891,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"version": "5.3.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
|
||||
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/uglify-js": {
|
||||
|
||||
13
package.json
13
package.json
@ -10,7 +10,7 @@
|
||||
"email": "pleerock.me@gmail.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.9.0"
|
||||
"node": ">=16.13.0"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
@ -93,10 +93,13 @@
|
||||
"cloud-spanner-orm"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@tsconfig/node16": "^16.1.1",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/chai": "^4.3.4",
|
||||
"@types/chai-as-promised": "^7.1.5",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/gulp-rename": "^2.0.6",
|
||||
"@types/gulp-sourcemaps": "^0.0.38",
|
||||
"@types/mkdirp": "^1.0.2",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "^18.13.0",
|
||||
@ -105,7 +108,7 @@
|
||||
"@types/source-map-support": "^0.5.6",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"@types/yargs": "^17.0.22",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
||||
"better-sqlite3": "^8.1.0",
|
||||
"chai": "^4.3.7",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
@ -140,9 +143,9 @@
|
||||
"source-map-support": "^0.5.21",
|
||||
"sql.js": "^1.8.0",
|
||||
"sqlite3": "^5.1.4",
|
||||
"ts-node": "^10.9.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typeorm-aurora-data-api-driver": "^2.4.4",
|
||||
"typescript": "^4.9.5"
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@google-cloud/spanner": "^5.18.0",
|
||||
@ -227,7 +230,7 @@
|
||||
"dotenv": "^16.0.3",
|
||||
"glob": "^10.3.10",
|
||||
"mkdirp": "^2.1.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"reflect-metadata": "^0.2.1",
|
||||
"sha.js": "^2.4.11",
|
||||
"tslib": "^2.5.0",
|
||||
"uuid": "^9.0.0",
|
||||
|
||||
@ -5,6 +5,6 @@ export const PostRepository = Sample33CustomRepositoryConnection.getRepository(
|
||||
Post,
|
||||
).extend({
|
||||
findMyPost() {
|
||||
return this.findOne()
|
||||
return this.findOne({})
|
||||
},
|
||||
})
|
||||
|
||||
@ -88,7 +88,8 @@ export class SqliteQueryRunner extends AbstractSqliteQueryRunner {
|
||||
}
|
||||
}
|
||||
|
||||
const handler = function (err: any, rows: any) {
|
||||
const self = this;
|
||||
const handler = function (this: any, err: any, rows: any) {
|
||||
if (err && err.toString().indexOf("SQLITE_BUSY:") !== -1) {
|
||||
if (
|
||||
typeof options.busyErrorRetry === "number" &&
|
||||
@ -110,7 +111,7 @@ export class SqliteQueryRunner extends AbstractSqliteQueryRunner {
|
||||
queryExecutionTime,
|
||||
query,
|
||||
parameters,
|
||||
this,
|
||||
self,
|
||||
)
|
||||
|
||||
if (err) {
|
||||
@ -118,7 +119,7 @@ export class SqliteQueryRunner extends AbstractSqliteQueryRunner {
|
||||
err,
|
||||
query,
|
||||
parameters,
|
||||
this,
|
||||
self,
|
||||
)
|
||||
broadcaster.broadcastAfterQueryEvent(
|
||||
broadcasterResult,
|
||||
|
||||
@ -4224,22 +4224,24 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
) {
|
||||
let condition: string = ""
|
||||
// let parameterIndex = Object.keys(this.expressionMap.nativeParameters).length;
|
||||
if (Array.isArray(where) && where.length) {
|
||||
condition =
|
||||
"(" +
|
||||
where
|
||||
.map((whereItem) => {
|
||||
return this.buildWhere(
|
||||
whereItem,
|
||||
metadata,
|
||||
alias,
|
||||
embedPrefix,
|
||||
)
|
||||
})
|
||||
.filter((condition) => !!condition)
|
||||
.map((condition) => "(" + condition + ")")
|
||||
.join(" OR ") +
|
||||
")"
|
||||
if (Array.isArray(where)) {
|
||||
if (where.length) {
|
||||
condition =
|
||||
"(" +
|
||||
where
|
||||
.map((whereItem) => {
|
||||
return this.buildWhere(
|
||||
whereItem,
|
||||
metadata,
|
||||
alias,
|
||||
embedPrefix,
|
||||
)
|
||||
})
|
||||
.filter((condition) => !!condition)
|
||||
.map((condition) => "(" + condition + ")")
|
||||
.join(" OR ") +
|
||||
")"
|
||||
}
|
||||
} else {
|
||||
let andConditions: string[] = []
|
||||
for (let key in where) {
|
||||
|
||||
@ -79,11 +79,11 @@ export class DepGraph {
|
||||
edgeList,
|
||||
) {
|
||||
Object.keys(edgeList).forEach(function (key: any) {
|
||||
let idx = edgeList[key].indexOf(node)
|
||||
const idx = edgeList[key].indexOf(node)
|
||||
if (idx >= 0) {
|
||||
edgeList[key].splice(idx, 1)
|
||||
}
|
||||
}, this)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ export default {
|
||||
nullable: false,
|
||||
},
|
||||
},
|
||||
target: function Question() {
|
||||
target: function Question(this: any) {
|
||||
this.type = "question"
|
||||
},
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import {
|
||||
OptimisticLockCanNotBeUsedError,
|
||||
OptimisticLockVersionMismatchError,
|
||||
PessimisticLockTransactionRequiredError,
|
||||
QueryRunner,
|
||||
} from "../../../../src"
|
||||
import { PostWithVersion } from "./entity/PostWithVersion"
|
||||
import { expect } from "chai"
|
||||
@ -135,7 +136,7 @@ describe("repository > find options > locking", () => {
|
||||
const originalQuery = entityManager.queryRunner!.query.bind(
|
||||
entityManager.queryRunner,
|
||||
)
|
||||
entityManager.queryRunner!.query = (...args: any[]) => {
|
||||
entityManager.queryRunner!.query = (...args: Parameters<QueryRunner['query']>) => {
|
||||
executedSql.push(args[0])
|
||||
return originalQuery(...args)
|
||||
}
|
||||
@ -175,7 +176,7 @@ describe("repository > find options > locking", () => {
|
||||
const originalQuery = entityManager.queryRunner!.query.bind(
|
||||
entityManager.queryRunner,
|
||||
)
|
||||
entityManager.queryRunner!.query = (...args: any[]) => {
|
||||
entityManager.queryRunner!.query = (...args: Parameters<QueryRunner['query']>) => {
|
||||
executedSql.push(args[0])
|
||||
return originalQuery(...args)
|
||||
}
|
||||
@ -204,7 +205,7 @@ describe("repository > find options > locking", () => {
|
||||
const originalQuery = entityManager.queryRunner!.query.bind(
|
||||
entityManager.queryRunner,
|
||||
)
|
||||
entityManager.queryRunner!.query = (...args: any[]) => {
|
||||
entityManager.queryRunner!.query = (...args: Parameters<QueryRunner['query']>) => {
|
||||
executedSql.push(args[0])
|
||||
return originalQuery(...args)
|
||||
}
|
||||
@ -243,7 +244,7 @@ describe("repository > find options > locking", () => {
|
||||
const originalQuery = entityManager.queryRunner!.query.bind(
|
||||
entityManager.queryRunner,
|
||||
)
|
||||
entityManager.queryRunner!.query = (...args: any[]) => {
|
||||
entityManager.queryRunner!.query = (...args: Parameters<QueryRunner['query']>) => {
|
||||
executedSql.push(args[0])
|
||||
return originalQuery(...args)
|
||||
}
|
||||
@ -285,7 +286,7 @@ describe("repository > find options > locking", () => {
|
||||
const originalQuery = entityManager.queryRunner!.query.bind(
|
||||
entityManager.queryRunner,
|
||||
)
|
||||
entityManager.queryRunner!.query = (...args: any[]) => {
|
||||
entityManager.queryRunner!.query = (...args: Parameters<QueryRunner['query']>) => {
|
||||
executedSql.push(args[0])
|
||||
return originalQuery(...args)
|
||||
}
|
||||
@ -322,7 +323,7 @@ describe("repository > find options > locking", () => {
|
||||
const originalQuery = entityManager.queryRunner!.query.bind(
|
||||
entityManager.queryRunner,
|
||||
)
|
||||
entityManager.queryRunner!.query = (...args: any[]) => {
|
||||
entityManager.queryRunner!.query = (...args: Parameters<QueryRunner['query']>) => {
|
||||
executedSql.push(args[0])
|
||||
return originalQuery(...args)
|
||||
}
|
||||
@ -360,7 +361,7 @@ describe("repository > find options > locking", () => {
|
||||
const originalQuery = entityManager.queryRunner!.query.bind(
|
||||
entityManager.queryRunner,
|
||||
)
|
||||
entityManager.queryRunner!.query = (...args: any[]) => {
|
||||
entityManager.queryRunner!.query = (...args: Parameters<QueryRunner['query']>) => {
|
||||
executedSql.push(args[0])
|
||||
return originalQuery(...args)
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import { DataSource } from "../../../src/data-source/DataSource"
|
||||
import { expect } from "chai"
|
||||
import { Product } from "./entity/product"
|
||||
import { Category } from "./entity/category"
|
||||
import { FindManyOptions } from "../../../src"
|
||||
|
||||
describe("github issues > #9988 RelationIdLoader reuses the same queryplanner within a transaction", () => {
|
||||
let dataSources: DataSource[]
|
||||
@ -40,20 +41,20 @@ describe("github issues > #9988 RelationIdLoader reuses the same queryplanner wi
|
||||
await categoryRepo.save(categoryTwo)
|
||||
const options = (id: number) => ({
|
||||
relationLoadStrategy: "query",
|
||||
where: { id: productOneId },
|
||||
where: { id },
|
||||
relations: { categories: true },
|
||||
})
|
||||
} as FindManyOptions<Product>)
|
||||
|
||||
// Create a custom repository that uses a query builder without query planner
|
||||
// For both methods, relationLoadStrategy is set to "query", where the bug lies.
|
||||
const productRepo = dataSource.getRepository(Product).extend({
|
||||
async getOne(): Promise<Product> {
|
||||
async getOne() {
|
||||
return this.createQueryBuilder("product")
|
||||
.setFindOptions(options(productOneId))
|
||||
.getOne()
|
||||
},
|
||||
|
||||
async getMany(): Promise<Product[]> {
|
||||
async getMany() {
|
||||
return this.createQueryBuilder("product")
|
||||
.setFindOptions(options(productTwoId))
|
||||
.getMany()
|
||||
@ -75,7 +76,7 @@ describe("github issues > #9988 RelationIdLoader reuses the same queryplanner wi
|
||||
},
|
||||
)
|
||||
|
||||
expect(getOneProduct.categories.length).to.be.eql(1)
|
||||
expect(getOneProduct?.categories.length).to.be.eql(1)
|
||||
|
||||
const getManyProduct = await manager.transaction(
|
||||
async (txnManager) => {
|
||||
@ -83,7 +84,7 @@ describe("github issues > #9988 RelationIdLoader reuses the same queryplanner wi
|
||||
txnManager.withRepository(productRepo)
|
||||
const product = customProductRepo.create({
|
||||
id: productTwoId,
|
||||
categories: [{ id: categoryOne.id }],
|
||||
categories: [{ id: categoryOne.id }, { id: categoryTwo.id }],
|
||||
})
|
||||
|
||||
await customProductRepo.save(product)
|
||||
@ -91,7 +92,7 @@ describe("github issues > #9988 RelationIdLoader reuses the same queryplanner wi
|
||||
},
|
||||
)
|
||||
|
||||
expect(getManyProduct[0].categories.length).to.be.eql(1)
|
||||
expect(getManyProduct[0].categories.length).to.be.eql(2)
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
@ -21,9 +21,9 @@ const wrap = (
|
||||
|
||||
return new Promise<void>((ok, fail) => {
|
||||
if (fn.length > 1) {
|
||||
fn.call(context, (err: any) => (err ? fail(err) : ok()))
|
||||
(fn as Func).call(context as unknown as Context, (err: any) => (err ? fail(err) : ok()))
|
||||
} else {
|
||||
ok(fn.call(context))
|
||||
ok((fn as AsyncFunc).call(context as unknown as Context))
|
||||
}
|
||||
}).then(
|
||||
(e: any) => assert.fail("Expected this test to fail"),
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
{
|
||||
"extends": "@tsconfig/node16/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"lib": ["es5", "es6"],
|
||||
"outDir": "build/compiled",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"target": "ES2019",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"declaration": true,
|
||||
"downlevelIteration": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"declaration": true,
|
||||
"importHelpers": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"stripInternal": true,
|
||||
"pretty": true,
|
||||
"strictNullChecks": true,
|
||||
"noUnusedLocals": true,
|
||||
"downlevelIteration": true
|
||||
"outDir": "build/compiled",
|
||||
"pretty": true,
|
||||
"sourceMap": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictPropertyInitialization": false,
|
||||
"stripInternal": true,
|
||||
"useUnknownInCatchVariables": false
|
||||
},
|
||||
"include": [
|
||||
"sample",
|
||||
"src",
|
||||
"test"
|
||||
"test",
|
||||
"*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"tmp",
|
||||
"temp",
|
||||
"build",
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
"temp",
|
||||
"tmp"
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user