typeorm 0.3.23 → 0.3.24-dev.1198dc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/data-source/DataSource.d.ts +8 -0
- package/browser/data-source/DataSource.js +16 -0
- package/browser/data-source/DataSource.js.map +1 -1
- package/browser/driver/mongodb/MongoQueryRunner.d.ts +4 -0
- package/browser/driver/mongodb/MongoQueryRunner.js +6 -0
- package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/browser/entity-manager/EntityManager.d.ts +8 -0
- package/browser/entity-manager/EntityManager.js +16 -0
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/error/index.d.ts +0 -1
- package/browser/error/index.js +0 -1
- package/browser/error/index.js.map +1 -1
- package/browser/persistence/SubjectDatabaseEntityLoader.d.ts +0 -8
- package/browser/persistence/SubjectDatabaseEntityLoader.js +11 -26
- package/browser/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.d.ts +8 -0
- package/browser/query-runner/BaseQueryRunner.js +16 -0
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/browser/query-runner/QueryResult.d.ts +2 -2
- package/browser/query-runner/QueryResult.js.map +1 -1
- package/browser/query-runner/QueryRunner.d.ts +8 -0
- package/browser/query-runner/QueryRunner.js.map +1 -1
- package/browser/repository/Repository.d.ts +9 -1
- package/browser/repository/Repository.js +16 -0
- package/browser/repository/Repository.js.map +1 -1
- package/browser/util/SqlTagUtils.d.ts +11 -0
- package/browser/util/SqlTagUtils.js +39 -0
- package/browser/util/SqlTagUtils.js.map +1 -0
- package/data-source/DataSource.d.ts +8 -0
- package/data-source/DataSource.js +16 -0
- package/data-source/DataSource.js.map +1 -1
- package/driver/mongodb/MongoQueryRunner.d.ts +4 -0
- package/driver/mongodb/MongoQueryRunner.js +6 -0
- package/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/entity-manager/EntityManager.d.ts +8 -0
- package/entity-manager/EntityManager.js +16 -0
- package/entity-manager/EntityManager.js.map +1 -1
- package/error/index.d.ts +0 -1
- package/error/index.js +0 -1
- package/error/index.js.map +1 -1
- package/index.mjs +0 -2
- package/package.json +1 -262
- package/persistence/SubjectDatabaseEntityLoader.d.ts +0 -8
- package/persistence/SubjectDatabaseEntityLoader.js +11 -26
- package/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/query-runner/BaseQueryRunner.d.ts +8 -0
- package/query-runner/BaseQueryRunner.js +16 -0
- package/query-runner/BaseQueryRunner.js.map +1 -1
- package/query-runner/QueryResult.d.ts +2 -2
- package/query-runner/QueryResult.js.map +1 -1
- package/query-runner/QueryRunner.d.ts +8 -0
- package/query-runner/QueryRunner.js.map +1 -1
- package/repository/Repository.d.ts +9 -1
- package/repository/Repository.js +16 -0
- package/repository/Repository.js.map +1 -1
- package/util/SqlTagUtils.d.ts +11 -0
- package/util/SqlTagUtils.js +43 -0
- package/util/SqlTagUtils.js.map +1 -0
- package/browser/error/NamingStrategyNotFoundError.d.ts +0 -7
- package/browser/error/NamingStrategyNotFoundError.js +0 -17
- package/browser/error/NamingStrategyNotFoundError.js.map +0 -1
- package/error/NamingStrategyNotFoundError.d.ts +0 -7
- package/error/NamingStrategyNotFoundError.js +0 -21
- package/error/NamingStrategyNotFoundError.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,262 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "typeorm",
|
|
3
|
-
"version": "0.3.23",
|
|
4
|
-
"description": "Data-Mapper ORM for TypeScript and ES2021+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.",
|
|
5
|
-
"homepage": "https://typeorm.io",
|
|
6
|
-
"bugs": {
|
|
7
|
-
"url": "https://github.com/typeorm/typeorm/issues"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/typeorm/typeorm.git"
|
|
12
|
-
},
|
|
13
|
-
"funding": "https://opencollective.com/typeorm",
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"author": {
|
|
16
|
-
"name": "Umed Khudoiberdiev",
|
|
17
|
-
"email": "pleerock.me@gmail.com"
|
|
18
|
-
},
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"types": "./index.d.ts",
|
|
22
|
-
"node": {
|
|
23
|
-
"import": "./index.mjs",
|
|
24
|
-
"require": "./index.js",
|
|
25
|
-
"types": "./index.d.ts"
|
|
26
|
-
},
|
|
27
|
-
"browser": {
|
|
28
|
-
"require": "./index.js",
|
|
29
|
-
"import": "./browser/index.js",
|
|
30
|
-
"default": "./index.js"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"./browser": {
|
|
34
|
-
"types": "./index.d.ts",
|
|
35
|
-
"default": "./browser/index.js"
|
|
36
|
-
},
|
|
37
|
-
"./*.js": "./*.js",
|
|
38
|
-
"./*": {
|
|
39
|
-
"require": "./*.js",
|
|
40
|
-
"import": "./*"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"main": "./index.js",
|
|
44
|
-
"module": "./index.mjs",
|
|
45
|
-
"browser": {
|
|
46
|
-
"./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
|
|
47
|
-
"./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
|
|
48
|
-
"./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
|
|
49
|
-
"./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
50
|
-
"./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
51
|
-
"./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
52
|
-
"./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
53
|
-
"./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
54
|
-
"./browser/driver/mongodb/bson.typings.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
55
|
-
"./browser/driver/mongodb/typings.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
56
|
-
"./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
57
|
-
"./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
58
|
-
"./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
59
|
-
"./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
60
|
-
"./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
61
|
-
"./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
62
|
-
"./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
63
|
-
"./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js",
|
|
64
|
-
"./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js",
|
|
65
|
-
"./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
66
|
-
"./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js",
|
|
67
|
-
"./index.js": "./browser/index.js",
|
|
68
|
-
"./index.mjs": "./browser/index.js"
|
|
69
|
-
},
|
|
70
|
-
"types": "./index.d.ts",
|
|
71
|
-
"bin": {
|
|
72
|
-
"typeorm": "./cli.js",
|
|
73
|
-
"typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js",
|
|
74
|
-
"typeorm-ts-node-esm": "./cli-ts-node-esm.js"
|
|
75
|
-
},
|
|
76
|
-
"scripts": {
|
|
77
|
-
"changelog": "standard-changelog",
|
|
78
|
-
"compile": "rimraf ./build && tsc",
|
|
79
|
-
"format": "prettier --cache --write \"./**/*.ts\"",
|
|
80
|
-
"format:ci": "prettier --check \"./**/*.ts\"",
|
|
81
|
-
"lint": "eslint .",
|
|
82
|
-
"pack": "gulp pack",
|
|
83
|
-
"package": "gulp package",
|
|
84
|
-
"test": "npm run compile && npm run test:fast --",
|
|
85
|
-
"test:ci": "mocha --bail",
|
|
86
|
-
"test:fast": "mocha",
|
|
87
|
-
"watch": "tsc --watch"
|
|
88
|
-
},
|
|
89
|
-
"dependencies": {
|
|
90
|
-
"@sqltools/formatter": "^1.2.5",
|
|
91
|
-
"ansis": "^3.17.0",
|
|
92
|
-
"app-root-path": "^3.1.0",
|
|
93
|
-
"buffer": "^6.0.3",
|
|
94
|
-
"dayjs": "^1.11.13",
|
|
95
|
-
"debug": "^4.4.0",
|
|
96
|
-
"dotenv": "^16.4.7",
|
|
97
|
-
"glob": "^10.4.5",
|
|
98
|
-
"sha.js": "^2.4.11",
|
|
99
|
-
"sql-highlight": "^6.0.0",
|
|
100
|
-
"tslib": "^2.8.1",
|
|
101
|
-
"uuid": "^11.1.0",
|
|
102
|
-
"yargs": "^17.7.2"
|
|
103
|
-
},
|
|
104
|
-
"devDependencies": {
|
|
105
|
-
"@eslint/js": "^9.22.0",
|
|
106
|
-
"@sap/hana-client": "^2.24.21",
|
|
107
|
-
"@tsconfig/node16": "^16.1.3",
|
|
108
|
-
"@types/chai": "^4.3.20",
|
|
109
|
-
"@types/chai-as-promised": "^7.1.8",
|
|
110
|
-
"@types/debug": "^4.1.12",
|
|
111
|
-
"@types/gulp-rename": "^2.0.6",
|
|
112
|
-
"@types/gulp-sourcemaps": "^0.0.38",
|
|
113
|
-
"@types/mocha": "^10.0.10",
|
|
114
|
-
"@types/node": "^16.18.126",
|
|
115
|
-
"@types/sha.js": "^2.4.4",
|
|
116
|
-
"@types/sinon": "^10.0.20",
|
|
117
|
-
"@types/sinon-chai": "^4.0.0",
|
|
118
|
-
"@types/source-map-support": "^0.5.10",
|
|
119
|
-
"@types/yargs": "^17.0.33",
|
|
120
|
-
"better-sqlite3": "^8.7.0",
|
|
121
|
-
"chai": "^4.5.0",
|
|
122
|
-
"chai-as-promised": "^7.1.2",
|
|
123
|
-
"class-transformer": "^0.5.1",
|
|
124
|
-
"eslint": "^9.22.0",
|
|
125
|
-
"globals": "^16.0.0",
|
|
126
|
-
"gulp": "^4.0.2",
|
|
127
|
-
"gulp-rename": "^2.0.0",
|
|
128
|
-
"gulp-replace": "^1.1.4",
|
|
129
|
-
"gulp-shell": "^0.8.0",
|
|
130
|
-
"gulp-sourcemaps": "^3.0.0",
|
|
131
|
-
"gulp-typescript": "^6.0.0-alpha.1",
|
|
132
|
-
"gulpclass": "^0.2.0",
|
|
133
|
-
"hdb-pool": "^0.1.6",
|
|
134
|
-
"mocha": "^10.8.2",
|
|
135
|
-
"mongodb": "^6.15.0",
|
|
136
|
-
"mssql": "^11.0.1",
|
|
137
|
-
"mysql": "^2.18.1",
|
|
138
|
-
"mysql2": "^3.14.0",
|
|
139
|
-
"nyc": "^17.1.0",
|
|
140
|
-
"oracledb": "^6.8.0",
|
|
141
|
-
"pg": "^8.14.1",
|
|
142
|
-
"pg-query-stream": "^4.8.1",
|
|
143
|
-
"pkg-pr-new": "^0.0.43",
|
|
144
|
-
"prettier": "^2.8.8",
|
|
145
|
-
"redis": "^4.7.0",
|
|
146
|
-
"remap-istanbul": "^0.13.0",
|
|
147
|
-
"rimraf": "^5.0.10",
|
|
148
|
-
"sinon": "^15.2.0",
|
|
149
|
-
"sinon-chai": "^3.7.0",
|
|
150
|
-
"source-map-support": "^0.5.21",
|
|
151
|
-
"sql.js": "^1.13.0",
|
|
152
|
-
"sqlite3": "^5.1.7",
|
|
153
|
-
"standard-changelog": "^6.0.0",
|
|
154
|
-
"ts-node": "^10.9.2",
|
|
155
|
-
"typescript": "^5.8.2",
|
|
156
|
-
"typescript-eslint": "^8.27.0"
|
|
157
|
-
},
|
|
158
|
-
"peerDependencies": {
|
|
159
|
-
"@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0",
|
|
160
|
-
"@sap/hana-client": "^2.12.25",
|
|
161
|
-
"better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
162
|
-
"hdb-pool": "^0.1.6",
|
|
163
|
-
"ioredis": "^5.0.4",
|
|
164
|
-
"mongodb": "^5.8.0 || ^6.0.0",
|
|
165
|
-
"mssql": "^9.1.1 || ^10.0.1 || ^11.0.1",
|
|
166
|
-
"mysql2": "^2.2.5 || ^3.0.1",
|
|
167
|
-
"oracledb": "^6.3.0",
|
|
168
|
-
"pg": "^8.5.1",
|
|
169
|
-
"pg-native": "^3.0.0",
|
|
170
|
-
"pg-query-stream": "^4.0.0",
|
|
171
|
-
"redis": "^3.1.1 || ^4.0.0",
|
|
172
|
-
"reflect-metadata": "^0.1.14 || ^0.2.0",
|
|
173
|
-
"sql.js": "^1.4.0",
|
|
174
|
-
"sqlite3": "^5.0.3",
|
|
175
|
-
"ts-node": "^10.7.0",
|
|
176
|
-
"typeorm-aurora-data-api-driver": "^2.0.0 || ^3.0.0"
|
|
177
|
-
},
|
|
178
|
-
"peerDependenciesMeta": {
|
|
179
|
-
"@google-cloud/spanner": {
|
|
180
|
-
"optional": true
|
|
181
|
-
},
|
|
182
|
-
"@sap/hana-client": {
|
|
183
|
-
"optional": true
|
|
184
|
-
},
|
|
185
|
-
"better-sqlite3": {
|
|
186
|
-
"optional": true
|
|
187
|
-
},
|
|
188
|
-
"hdb-pool": {
|
|
189
|
-
"optional": true
|
|
190
|
-
},
|
|
191
|
-
"ioredis": {
|
|
192
|
-
"optional": true
|
|
193
|
-
},
|
|
194
|
-
"mongodb": {
|
|
195
|
-
"optional": true
|
|
196
|
-
},
|
|
197
|
-
"mssql": {
|
|
198
|
-
"optional": true
|
|
199
|
-
},
|
|
200
|
-
"mysql2": {
|
|
201
|
-
"optional": true
|
|
202
|
-
},
|
|
203
|
-
"oracledb": {
|
|
204
|
-
"optional": true
|
|
205
|
-
},
|
|
206
|
-
"pg": {
|
|
207
|
-
"optional": true
|
|
208
|
-
},
|
|
209
|
-
"pg-native": {
|
|
210
|
-
"optional": true
|
|
211
|
-
},
|
|
212
|
-
"pg-query-stream": {
|
|
213
|
-
"optional": true
|
|
214
|
-
},
|
|
215
|
-
"redis": {
|
|
216
|
-
"optional": true
|
|
217
|
-
},
|
|
218
|
-
"sql.js": {
|
|
219
|
-
"optional": true
|
|
220
|
-
},
|
|
221
|
-
"sqlite3": {
|
|
222
|
-
"optional": true
|
|
223
|
-
},
|
|
224
|
-
"ts-node": {
|
|
225
|
-
"optional": true
|
|
226
|
-
},
|
|
227
|
-
"typeorm-aurora-data-api-driver": {
|
|
228
|
-
"optional": true
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
"engines": {
|
|
232
|
-
"node": ">=16.13.0"
|
|
233
|
-
},
|
|
234
|
-
"collective": {
|
|
235
|
-
"type": "opencollective",
|
|
236
|
-
"url": "https://opencollective.com/typeorm",
|
|
237
|
-
"logo": "https://opencollective.com/opencollective/logo.txt"
|
|
238
|
-
},
|
|
239
|
-
"readmeFilename": "README.md",
|
|
240
|
-
"tags": [
|
|
241
|
-
"orm",
|
|
242
|
-
"typescript",
|
|
243
|
-
"typescript-orm",
|
|
244
|
-
"mariadb",
|
|
245
|
-
"mariadb-orm",
|
|
246
|
-
"mysql",
|
|
247
|
-
"mysql-orm",
|
|
248
|
-
"oracle",
|
|
249
|
-
"oracle-orm",
|
|
250
|
-
"postgresql",
|
|
251
|
-
"postgresql-orm",
|
|
252
|
-
"sap-hana",
|
|
253
|
-
"sap-hana-orm",
|
|
254
|
-
"spanner",
|
|
255
|
-
"cloud-spanner",
|
|
256
|
-
"cloud-spanner-orm",
|
|
257
|
-
"sqlite",
|
|
258
|
-
"sqlite-orm",
|
|
259
|
-
"sql-server",
|
|
260
|
-
"sql-server-orm"
|
|
261
|
-
]
|
|
262
|
-
}
|
|
1
|
+
{ "name": "typeorm", "version": "0.3.24-dev.1198dc2", "description": "Data-Mapper ORM for TypeScript and ES2021+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.", "homepage": "https://typeorm.io", "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "funding": "https://opencollective.com/typeorm", "license": "MIT", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "exports": { ".": { "types": "./index.d.ts", "node": { "import": "./index.mjs", "require": "./index.js", "types": "./index.d.ts" }, "browser": { "require": "./index.js", "import": "./browser/index.js", "default": "./index.js" } }, "./browser": { "types": "./index.d.ts", "default": "./browser/index.js" }, "./*.js": "./*.js", "./*": { "require": "./*.js", "import": "./*" } }, "main": "./index.js", "module": "./index.mjs", "browser": { "./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/bson.typings.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/typings.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js", "./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js", "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js", "./index.js": "./browser/index.js", "./index.mjs": "./browser/index.js" }, "types": "./index.d.ts", "bin": { "typeorm": "./cli.js", "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js", "typeorm-ts-node-esm": "./cli-ts-node-esm.js" }, "scripts": { "changelog": "standard-changelog", "compile": "rimraf ./build && tsc", "format": "prettier --cache --write \"./**/*.ts\"", "format:ci": "prettier --check \"./**/*.ts\"", "lint": "eslint .", "pack": "gulp pack", "package": "gulp package", "pre-commit": "lint-staged", "prepare": "husky", "test": "npm run compile && npm run test:fast --", "test:ci": "mocha --bail", "test:fast": "mocha", "watch": "tsc --watch", "publish:preview": "pkg-pr-new publish './build/package' --pnpm --template='./sample/playground'" }, "dependencies": { "@sqltools/formatter": "^1.2.5", "ansis": "^3.17.0", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "dayjs": "^1.11.13", "debug": "^4.4.0", "dedent": "^1.6.0", "dotenv": "^16.4.7", "glob": "^10.4.5", "sha.js": "^2.4.11", "sql-highlight": "^6.0.0", "tslib": "^2.8.1", "uuid": "^11.1.0", "yargs": "^17.7.2" }, "devDependencies": { "@eslint/js": "^9.22.0", "@sap/hana-client": "^2.24.21", "@tsconfig/node16": "^16.1.3", "@types/chai": "^4.3.20", "@types/chai-as-promised": "^7.1.8", "@types/debug": "^4.1.12", "@types/gulp-rename": "^2.0.6", "@types/gulp-sourcemaps": "^0.0.38", "@types/mocha": "^10.0.10", "@types/node": "^16.18.126", "@types/sha.js": "^2.4.4", "@types/sinon": "^10.0.20", "@types/sinon-chai": "^4.0.0", "@types/source-map-support": "^0.5.10", "@types/yargs": "^17.0.33", "better-sqlite3": "^8.7.0", "chai": "^4.5.0", "chai-as-promised": "^7.1.2", "class-transformer": "^0.5.1", "eslint": "^9.22.0", "globals": "^16.0.0", "gulp": "^4.0.2", "gulp-rename": "^2.0.0", "gulp-replace": "^1.1.4", "gulp-shell": "^0.8.0", "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^6.0.0-alpha.1", "gulpclass": "^0.2.0", "hdb-pool": "^0.1.6", "husky": "^9.1.7", "lint-staged": "^15.5.2", "mocha": "^10.8.2", "mongodb": "^6.15.0", "mssql": "^11.0.1", "mysql": "^2.18.1", "mysql2": "^3.14.0", "nyc": "^17.1.0", "oracledb": "^6.8.0", "pg": "^8.14.1", "pg-query-stream": "^4.8.1", "pkg-pr-new": "^0.0.43", "prettier": "^2.8.8", "redis": "^4.7.0", "remap-istanbul": "^0.13.0", "rimraf": "^5.0.10", "sinon": "^15.2.0", "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "sql.js": "^1.13.0", "sqlite3": "^5.1.7", "standard-changelog": "^6.0.0", "ts-node": "^10.9.2", "typescript": "^5.8.2", "typescript-eslint": "^8.27.0" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0", "@sap/hana-client": "^2.12.25", "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", "mongodb": "^5.8.0 || ^6.0.0", "mssql": "^9.1.1 || ^10.0.1 || ^11.0.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^6.3.0", "pg": "^8.5.1", "pg-native": "^3.0.0", "pg-query-stream": "^4.0.0", "redis": "^3.1.1 || ^4.0.0", "reflect-metadata": "^0.1.14 || ^0.2.0", "sql.js": "^1.4.0", "sqlite3": "^5.0.3", "ts-node": "^10.7.0", "typeorm-aurora-data-api-driver": "^2.0.0 || ^3.0.0" }, "peerDependenciesMeta": { "@google-cloud/spanner": { "optional": true }, "@sap/hana-client": { "optional": true }, "better-sqlite3": { "optional": true }, "hdb-pool": { "optional": true }, "ioredis": { "optional": true }, "mongodb": { "optional": true }, "mssql": { "optional": true }, "mysql2": { "optional": true }, "oracledb": { "optional": true }, "pg": { "optional": true }, "pg-native": { "optional": true }, "pg-query-stream": { "optional": true }, "redis": { "optional": true }, "sql.js": { "optional": true }, "sqlite3": { "optional": true }, "ts-node": { "optional": true }, "typeorm-aurora-data-api-driver": { "optional": true } }, "engines": { "node": ">=16.13.0" }, "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "readmeFilename": "README.md", "tags": [ "orm", "typescript", "typescript-orm", "mariadb", "mariadb-orm", "mysql", "mysql-orm", "oracle", "oracle-orm", "postgresql", "postgresql-orm", "sap-hana", "sap-hana-orm", "spanner", "cloud-spanner", "cloud-spanner-orm", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm" ] }
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Subject } from "./Subject";
|
|
2
|
-
import { ObjectLiteral } from "../common/ObjectLiteral";
|
|
3
2
|
import { QueryRunner } from "../query-runner/QueryRunner";
|
|
4
3
|
/**
|
|
5
4
|
* Loads database entities for all operate subjects which do not have database entity set.
|
|
@@ -18,13 +17,6 @@ export declare class SubjectDatabaseEntityLoader {
|
|
|
18
17
|
* This option is used for deletion.
|
|
19
18
|
*/
|
|
20
19
|
load(operationType: "save" | "remove" | "soft-remove" | "recover"): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Finds subjects where entity like given subject's entity.
|
|
23
|
-
* Comparison made by entity id.
|
|
24
|
-
* Multiple subjects may be returned if duplicates are present in the subject array.
|
|
25
|
-
* This will likely result in the same row being updated multiple times during a transaction.
|
|
26
|
-
*/
|
|
27
|
-
protected findByPersistEntityLike(entityTarget: Function | string, entity: ObjectLiteral): Subject[];
|
|
28
20
|
/**
|
|
29
21
|
* Groups given Subject objects into groups separated by entity targets.
|
|
30
22
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubjectDatabaseEntityLoader = void 0;
|
|
4
|
+
const OrmUtils_1 = require("../util/OrmUtils");
|
|
4
5
|
/**
|
|
5
6
|
* Loads database entities for all operate subjects which do not have database entity set.
|
|
6
7
|
* All entities that we load database entities for are marked as updated or inserted.
|
|
@@ -91,17 +92,17 @@ class SubjectDatabaseEntityLoader {
|
|
|
91
92
|
.whereInIds(allIds)
|
|
92
93
|
.getMany();
|
|
93
94
|
}
|
|
94
|
-
//
|
|
95
|
-
// and insert that entity into database entity of the found subjects
|
|
95
|
+
// Now when we have entities we need to find subject of each entity
|
|
96
|
+
// and insert that entity into database entity of the found subjects.
|
|
97
|
+
// A single entity can be applied to many subjects as there might be duplicates.
|
|
98
|
+
// This will likely result in the same row being updated multiple times during a transaction.
|
|
96
99
|
entities.forEach((entity) => {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
subject.databaseEntity
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
? subject.metadata.getEntityIdMap(entity)
|
|
104
|
-
: undefined;
|
|
100
|
+
const entityId = allSubjects[0].metadata.getEntityIdMap(entity);
|
|
101
|
+
allSubjects.forEach((subject) => {
|
|
102
|
+
if (subject.databaseEntity)
|
|
103
|
+
return;
|
|
104
|
+
if (OrmUtils_1.OrmUtils.compareIds(subject.identifier, entityId))
|
|
105
|
+
subject.databaseEntity = entity;
|
|
105
106
|
});
|
|
106
107
|
});
|
|
107
108
|
// this way we tell what subjects we tried to load database entities of
|
|
@@ -114,22 +115,6 @@ class SubjectDatabaseEntityLoader {
|
|
|
114
115
|
// ---------------------------------------------------------------------
|
|
115
116
|
// Protected Methods
|
|
116
117
|
// ---------------------------------------------------------------------
|
|
117
|
-
/**
|
|
118
|
-
* Finds subjects where entity like given subject's entity.
|
|
119
|
-
* Comparison made by entity id.
|
|
120
|
-
* Multiple subjects may be returned if duplicates are present in the subject array.
|
|
121
|
-
* This will likely result in the same row being updated multiple times during a transaction.
|
|
122
|
-
*/
|
|
123
|
-
findByPersistEntityLike(entityTarget, entity) {
|
|
124
|
-
return this.subjects.filter((subject) => {
|
|
125
|
-
if (!subject.entity)
|
|
126
|
-
return false;
|
|
127
|
-
if (subject.entity === entity)
|
|
128
|
-
return true;
|
|
129
|
-
return (subject.metadata.target === entityTarget &&
|
|
130
|
-
subject.metadata.compareEntities(subject.entityWithFulfilledIds, entity));
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
118
|
/**
|
|
134
119
|
* Groups given Subject objects into groups separated by entity targets.
|
|
135
120
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/persistence/SubjectDatabaseEntityLoader.ts"],"names":[],"mappings":";;;AAMA;;;;;GAKG;AACH,MAAa,2BAA2B;IACpC,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,YACc,WAAwB,EACxB,QAAmB;QADnB,gBAAW,GAAX,WAAW,CAAa;QACxB,aAAQ,GAAR,QAAQ,CAAW;IAC9B,CAAC;IAEJ,wEAAwE;IACxE,iBAAiB;IACjB,wEAAwE;IAExE;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CACN,aAA4D;QAE5D,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AG,MAAM,CAAC,IAAI,CACnB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,cAAc,CAAC,QAAQ,CAAC,MAAM,CAC7D,CAAA;YACD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,KAAK,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;gBAChE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;YACD,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YACnC,OAAO,MAAM,CAAA;QACjB,CAAC,EAAE,EAA0D,CAAC,CAAA;IAClE,CAAC;CACJ;AA5LD,kEA4LC","file":"SubjectDatabaseEntityLoader.js","sourcesContent":["import { Subject } from \"./Subject\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\n\n/**\n * Loads database entities for all operate subjects which do not have database entity set.\n * All entities that we load database entities for are marked as updated or inserted.\n * To understand which of them really needs to be inserted or updated we need to load\n * their original representations from the database.\n */\nexport class SubjectDatabaseEntityLoader {\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(\n protected queryRunner: QueryRunner,\n protected subjects: Subject[],\n ) {}\n\n // ---------------------------------------------------------------------\n // Public Methods\n // ---------------------------------------------------------------------\n\n /**\n * Loads database entities for all subjects.\n *\n * loadAllRelations flag is used to load all relation ids of the object, no matter if they present in subject entity or not.\n * This option is used for deletion.\n */\n async load(\n operationType: \"save\" | \"remove\" | \"soft-remove\" | \"recover\",\n ): Promise<void> {\n // we are grouping subjects by target to perform more optimized queries using WHERE IN operator\n // go through the groups and perform loading of database entities of each subject in the group\n const promises = this.groupByEntityTargets().map(\n async (subjectGroup) => {\n // prepare entity ids of the subjects we need to load\n const allIds: ObjectLiteral[] = []\n const allSubjects: Subject[] = []\n subjectGroup.subjects.forEach((subject) => {\n // we don't load if subject already has a database entity loaded\n if (subject.databaseEntity || !subject.identifier) return\n\n allIds.push(subject.identifier)\n allSubjects.push(subject)\n })\n\n // if there no ids found (means all entities are new and have generated ids) - then nothing to load there\n if (!allIds.length) return\n\n const loadRelationPropertyPaths: string[] = []\n\n // for the save, soft-remove and recover operation\n // extract all property paths of the relations we need to load relation ids for\n // this is for optimization purpose - this way we don't load relation ids for entities\n // whose relations are undefined, and since they are undefined its really pointless to\n // load something for them, since undefined properties are skipped by the orm\n if (\n operationType === \"save\" ||\n operationType === \"soft-remove\" ||\n operationType === \"recover\"\n ) {\n subjectGroup.subjects.forEach((subject) => {\n // gets all relation property paths that exist in the persisted entity.\n subject.metadata.relations.forEach((relation) => {\n const value = relation.getEntityValue(\n subject.entityWithFulfilledIds!,\n )\n if (value === undefined) return\n\n if (\n loadRelationPropertyPaths.indexOf(\n relation.propertyPath,\n ) === -1\n )\n loadRelationPropertyPaths.push(\n relation.propertyPath,\n )\n })\n })\n } else {\n // remove\n\n // for remove operation\n // we only need to load junction relation ids since only they are removed by cascades\n loadRelationPropertyPaths.push(\n ...subjectGroup.subjects[0].metadata.manyToManyRelations.map(\n (relation) => relation.propertyPath,\n ),\n )\n }\n\n const findOptions: FindManyOptions<any> = {\n loadEagerRelations: false,\n loadRelationIds: {\n relations: loadRelationPropertyPaths,\n disableMixedMap: true,\n },\n // the soft-deleted entities should be included in the loaded entities for recover operation\n withDeleted: true,\n }\n\n // load database entities for all given ids\n let entities: any[] = []\n if (\n this.queryRunner.connection.driver.options.type ===\n \"mongodb\"\n ) {\n const mongoRepo =\n this.queryRunner.manager.getRepository<ObjectLiteral>(\n subjectGroup.target,\n ) as MongoRepository<ObjectLiteral>\n entities = await mongoRepo.findByIds(allIds, findOptions)\n } else {\n entities = await this.queryRunner.manager\n .getRepository<ObjectLiteral>(subjectGroup.target)\n .createQueryBuilder()\n .setFindOptions(findOptions)\n .whereInIds(allIds)\n .getMany()\n }\n\n // now when we have entities we need to find subject of each entity\n // and insert that entity into database entity of the found subjects\n entities.forEach((entity) => {\n const subjects = this.findByPersistEntityLike(\n subjectGroup.target,\n entity,\n )\n subjects.forEach((subject) => {\n subject.databaseEntity = entity\n if (!subject.identifier)\n subject.identifier =\n subject.metadata.hasAllPrimaryKeys(entity)\n ? subject.metadata.getEntityIdMap(entity)\n : undefined\n })\n })\n\n // this way we tell what subjects we tried to load database entities of\n for (const subject of allSubjects) {\n subject.databaseEntityLoaded = true\n }\n },\n )\n\n await Promise.all(promises)\n }\n\n // ---------------------------------------------------------------------\n // Protected Methods\n // ---------------------------------------------------------------------\n\n /**\n * Finds subjects where entity like given subject's entity.\n * Comparison made by entity id.\n * Multiple subjects may be returned if duplicates are present in the subject array.\n * This will likely result in the same row being updated multiple times during a transaction.\n */\n protected findByPersistEntityLike(\n entityTarget: Function | string,\n entity: ObjectLiteral,\n ): Subject[] {\n return this.subjects.filter((subject) => {\n if (!subject.entity) return false\n\n if (subject.entity === entity) return true\n\n return (\n subject.metadata.target === entityTarget &&\n subject.metadata.compareEntities(\n subject.entityWithFulfilledIds!,\n entity,\n )\n )\n })\n }\n\n /**\n * Groups given Subject objects into groups separated by entity targets.\n */\n protected groupByEntityTargets(): {\n target: Function | string\n subjects: Subject[]\n }[] {\n return this.subjects.reduce((groups, operatedEntity) => {\n let group = groups.find(\n (group) => group.target === operatedEntity.metadata.target,\n )\n if (!group) {\n group = { target: operatedEntity.metadata.target, subjects: [] }\n groups.push(group)\n }\n group.subjects.push(operatedEntity)\n return groups\n }, [] as { target: Function | string; subjects: Subject[] }[])\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/persistence/SubjectDatabaseEntityLoader.ts"],"names":[],"mappings":";;;AAKA,+CAA2C;AAE3C;;;;;GAKG;AACH,MAAa,2BAA2B;IACpC,wEAAwE;IACxE,cAAc;IACd,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KAAK,CAAC,CAAA;YACtB,CAAC;YACD,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YACnC,OAAO,MAAM,CAAA;QACjB,CAAC,EAAE,EAA0D,CAAC,CAAA;IAClE,CAAC;CACJ;AAhKD,kEAgKC","file":"SubjectDatabaseEntityLoader.js","sourcesContent":["import { Subject } from \"./Subject\"\nimport { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { MongoRepository } from \"../repository/MongoRepository\"\nimport { OrmUtils } from \"../util/OrmUtils\"\n\n/**\n * Loads database entities for all operate subjects which do not have database entity set.\n * All entities that we load database entities for are marked as updated or inserted.\n * To understand which of them really needs to be inserted or updated we need to load\n * their original representations from the database.\n */\nexport class SubjectDatabaseEntityLoader {\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(\n protected queryRunner: QueryRunner,\n protected subjects: Subject[],\n ) {}\n\n // ---------------------------------------------------------------------\n // Public Methods\n // ---------------------------------------------------------------------\n\n /**\n * Loads database entities for all subjects.\n *\n * loadAllRelations flag is used to load all relation ids of the object, no matter if they present in subject entity or not.\n * This option is used for deletion.\n */\n async load(\n operationType: \"save\" | \"remove\" | \"soft-remove\" | \"recover\",\n ): Promise<void> {\n // we are grouping subjects by target to perform more optimized queries using WHERE IN operator\n // go through the groups and perform loading of database entities of each subject in the group\n const promises = this.groupByEntityTargets().map(\n async (subjectGroup) => {\n // prepare entity ids of the subjects we need to load\n const allIds: ObjectLiteral[] = []\n const allSubjects: Subject[] = []\n subjectGroup.subjects.forEach((subject) => {\n // we don't load if subject already has a database entity loaded\n if (subject.databaseEntity || !subject.identifier) return\n\n allIds.push(subject.identifier)\n allSubjects.push(subject)\n })\n\n // if there no ids found (means all entities are new and have generated ids) - then nothing to load there\n if (!allIds.length) return\n\n const loadRelationPropertyPaths: string[] = []\n\n // for the save, soft-remove and recover operation\n // extract all property paths of the relations we need to load relation ids for\n // this is for optimization purpose - this way we don't load relation ids for entities\n // whose relations are undefined, and since they are undefined its really pointless to\n // load something for them, since undefined properties are skipped by the orm\n if (\n operationType === \"save\" ||\n operationType === \"soft-remove\" ||\n operationType === \"recover\"\n ) {\n subjectGroup.subjects.forEach((subject) => {\n // gets all relation property paths that exist in the persisted entity.\n subject.metadata.relations.forEach((relation) => {\n const value = relation.getEntityValue(\n subject.entityWithFulfilledIds!,\n )\n if (value === undefined) return\n\n if (\n loadRelationPropertyPaths.indexOf(\n relation.propertyPath,\n ) === -1\n )\n loadRelationPropertyPaths.push(\n relation.propertyPath,\n )\n })\n })\n } else {\n // remove\n\n // for remove operation\n // we only need to load junction relation ids since only they are removed by cascades\n loadRelationPropertyPaths.push(\n ...subjectGroup.subjects[0].metadata.manyToManyRelations.map(\n (relation) => relation.propertyPath,\n ),\n )\n }\n\n const findOptions: FindManyOptions<any> = {\n loadEagerRelations: false,\n loadRelationIds: {\n relations: loadRelationPropertyPaths,\n disableMixedMap: true,\n },\n // the soft-deleted entities should be included in the loaded entities for recover operation\n withDeleted: true,\n }\n\n // load database entities for all given ids\n let entities: any[] = []\n if (\n this.queryRunner.connection.driver.options.type ===\n \"mongodb\"\n ) {\n const mongoRepo =\n this.queryRunner.manager.getRepository<ObjectLiteral>(\n subjectGroup.target,\n ) as MongoRepository<ObjectLiteral>\n entities = await mongoRepo.findByIds(allIds, findOptions)\n } else {\n entities = await this.queryRunner.manager\n .getRepository<ObjectLiteral>(subjectGroup.target)\n .createQueryBuilder()\n .setFindOptions(findOptions)\n .whereInIds(allIds)\n .getMany()\n }\n\n // Now when we have entities we need to find subject of each entity\n // and insert that entity into database entity of the found subjects.\n // A single entity can be applied to many subjects as there might be duplicates.\n // This will likely result in the same row being updated multiple times during a transaction.\n entities.forEach((entity) => {\n const entityId =\n allSubjects[0].metadata.getEntityIdMap(entity)\n allSubjects.forEach((subject) => {\n if (subject.databaseEntity) return\n if (OrmUtils.compareIds(subject.identifier, entityId))\n subject.databaseEntity = entity\n })\n })\n\n // this way we tell what subjects we tried to load database entities of\n for (const subject of allSubjects) {\n subject.databaseEntityLoaded = true\n }\n },\n )\n\n await Promise.all(promises)\n }\n\n // ---------------------------------------------------------------------\n // Protected Methods\n // ---------------------------------------------------------------------\n\n /**\n * Groups given Subject objects into groups separated by entity targets.\n */\n protected groupByEntityTargets(): {\n target: Function | string\n subjects: Subject[]\n }[] {\n return this.subjects.reduce((groups, operatedEntity) => {\n let group = groups.find(\n (group) => group.target === operatedEntity.metadata.target,\n )\n if (!group) {\n group = { target: operatedEntity.metadata.target, subjects: [] }\n groups.push(group)\n }\n group.subjects.push(operatedEntity)\n return groups\n }, [] as { target: Function | string; subjects: Subject[] }[])\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -74,6 +74,14 @@ export declare abstract class BaseQueryRunner {
|
|
|
74
74
|
* Executes a given SQL query.
|
|
75
75
|
*/
|
|
76
76
|
abstract query(query: string, parameters?: any[], useStructuredResult?: boolean): Promise<any>;
|
|
77
|
+
/**
|
|
78
|
+
* Tagged template function that executes raw SQL query and returns raw database results.
|
|
79
|
+
* Template expressions are automatically transformed into database parameters.
|
|
80
|
+
* Raw query execution is supported only by relational databases (MongoDB is not supported).
|
|
81
|
+
* Note: Don't call this as a regular function, it is meant to be used with backticks to tag a template literal.
|
|
82
|
+
* Example: queryRunner.sql`SELECT * FROM table_name WHERE id = ${id}`
|
|
83
|
+
*/
|
|
84
|
+
sql<T = any>(strings: TemplateStringsArray, ...values: unknown[]): Promise<T>;
|
|
77
85
|
protected abstract loadTables(tablePaths?: string[]): Promise<Table[]>;
|
|
78
86
|
protected abstract loadViews(tablePaths?: string[]): Promise<View[]>;
|
|
79
87
|
/**
|
|
@@ -6,6 +6,7 @@ const SqlInMemory_1 = require("../driver/SqlInMemory");
|
|
|
6
6
|
const TypeORMError_1 = require("../error/TypeORMError");
|
|
7
7
|
const OrmUtils_1 = require("../util/OrmUtils");
|
|
8
8
|
const InstanceChecker_1 = require("../util/InstanceChecker");
|
|
9
|
+
const SqlTagUtils_1 = require("../util/SqlTagUtils");
|
|
9
10
|
class BaseQueryRunner {
|
|
10
11
|
constructor() {
|
|
11
12
|
// -------------------------------------------------------------------------
|
|
@@ -48,6 +49,21 @@ class BaseQueryRunner {
|
|
|
48
49
|
this.transactionDepth = 0;
|
|
49
50
|
this.cachedTablePaths = {};
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Tagged template function that executes raw SQL query and returns raw database results.
|
|
54
|
+
* Template expressions are automatically transformed into database parameters.
|
|
55
|
+
* Raw query execution is supported only by relational databases (MongoDB is not supported).
|
|
56
|
+
* Note: Don't call this as a regular function, it is meant to be used with backticks to tag a template literal.
|
|
57
|
+
* Example: queryRunner.sql`SELECT * FROM table_name WHERE id = ${id}`
|
|
58
|
+
*/
|
|
59
|
+
async sql(strings, ...values) {
|
|
60
|
+
const { query, parameters } = (0, SqlTagUtils_1.buildSqlTag)({
|
|
61
|
+
driver: this.connection.driver,
|
|
62
|
+
strings: strings,
|
|
63
|
+
expressions: values,
|
|
64
|
+
});
|
|
65
|
+
return await this.query(query, parameters);
|
|
66
|
+
}
|
|
51
67
|
// -------------------------------------------------------------------------
|
|
52
68
|
// Public Methods
|
|
53
69
|
// -------------------------------------------------------------------------
|