remult 3.4.1 → 3.4.2
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/esm/remult-knex/index.js +2 -2
- package/esm/remult-mongo.js +2 -2
- package/esm/src/data-providers/sql-database.js +1 -1
- package/esm/src/filter/entityDbName.js +6 -10
- package/esm/src/filter/fieldDbName.js +8 -14
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +4 -4
- package/esm/src/filter/sqlExpressionInProgress.js +14 -0
- package/esm/src/remult3/QueryResultImpl.js +2 -0
- package/esm/src/remult3/RepositoryImplementation.js +2 -1
- package/package.json +1 -1
- package/remult-knex/index.js +2 -2
- package/remult-mongo.js +1 -1
- package/src/data-providers/sql-database.js +1 -3
- package/src/filter/entityDbName.d.ts +1 -1
- package/src/filter/entityDbName.js +14 -16
- package/src/filter/fieldDbName.js +19 -25
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +1 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.js +7 -5
- package/src/filter/sqlExpressionInProgress.d.ts +2 -0
- package/src/filter/sqlExpressionInProgress.js +27 -0
- package/src/remult3/QueryResultImpl.js +2 -0
- package/src/remult3/RepositoryImplementation.js +11 -9
package/esm/remult-knex/index.js
CHANGED
|
@@ -102,7 +102,7 @@ class KnexEntityDataProvider {
|
|
|
102
102
|
this.dp = dp;
|
|
103
103
|
}
|
|
104
104
|
async groupBy(options) {
|
|
105
|
-
return groupByImpl(options, await
|
|
105
|
+
return groupByImpl(options, await dbNamesOfWithForceSqlExpression(this.entity, this.dp.wrapIdentifier, true), this.dp.createCommand(), false, (limit, offset) => this.knex.client.config.client?.includes('mssql')
|
|
106
106
|
? ' offset ' + offset + ' rows fetch next ' + limit + ' rows only'
|
|
107
107
|
: ' limit ' + limit + ' offset ' + offset, this.dp.jsonColumnStorage);
|
|
108
108
|
}
|
|
@@ -183,7 +183,7 @@ class KnexEntityDataProvider {
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
async init() {
|
|
186
|
-
const r = (await dbNamesOfWithForceSqlExpression(this.entity, (x) => x));
|
|
186
|
+
const r = (await dbNamesOfWithForceSqlExpression(this.entity, (x) => x, true));
|
|
187
187
|
return {
|
|
188
188
|
$dbNameOf: (f) => {
|
|
189
189
|
let fm = f;
|
package/esm/remult-mongo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ObjectId, } from 'mongodb';
|
|
2
2
|
import { Filter } from './index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { dbNamesOfWithForceSqlExpression, } from './src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
4
4
|
import { remult as remultContext } from './src/remult-proxy.js';
|
|
5
5
|
import { getRepository } from './src/remult3/RepositoryImplementation.js';
|
|
6
6
|
import { getRepositoryInternals } from './src/remult3/repository-internals.js';
|
|
@@ -295,7 +295,7 @@ class MongoEntityDataProvider {
|
|
|
295
295
|
return result;
|
|
296
296
|
}
|
|
297
297
|
async collection() {
|
|
298
|
-
const e = await
|
|
298
|
+
const e = await dbNamesOfWithForceSqlExpression(this.entity, undefined, true);
|
|
299
299
|
const collection = this.db.collection(e.$entityName);
|
|
300
300
|
return { e, collection };
|
|
301
301
|
}
|
|
@@ -324,7 +324,7 @@ class ActualSQLEntityDataProvider {
|
|
|
324
324
|
this.strategy = strategy;
|
|
325
325
|
}
|
|
326
326
|
async init() {
|
|
327
|
-
let dbNameProvider = await dbNamesOfWithForceSqlExpression(this.entity, (x) => this.sql.wrapIdentifier(x));
|
|
327
|
+
let dbNameProvider = await dbNamesOfWithForceSqlExpression(this.entity, (x) => this.sql.wrapIdentifier(x), true);
|
|
328
328
|
await this.iAmUsed(dbNameProvider);
|
|
329
329
|
return dbNameProvider;
|
|
330
330
|
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { isSqlExpressionInProgress, runSqlExpression, } from './sqlExpressionInProgress.js';
|
|
2
|
+
export async function entityDbName(metadata, wrapIdentifier = (x) => x, forceSqlExpression = false) {
|
|
2
3
|
if (metadata.options.sqlExpression) {
|
|
3
4
|
if (typeof metadata.options.sqlExpression === 'string')
|
|
4
5
|
return metadata.options.sqlExpression;
|
|
5
6
|
else if (typeof metadata.options.sqlExpression === 'function') {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return await prev(metadata);
|
|
11
|
-
}
|
|
12
|
-
finally {
|
|
13
|
-
metadata.options.sqlExpression = prev;
|
|
14
|
-
}
|
|
7
|
+
if (isSqlExpressionInProgress(metadata) && !forceSqlExpression)
|
|
8
|
+
return "recursive sqlExpression call for entity '" + metadata.key + "'. ";
|
|
9
|
+
const { sqlExpression } = metadata.options;
|
|
10
|
+
return await runSqlExpression(metadata, () => sqlExpression(metadata));
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
13
|
return wrapIdentifier(metadata.dbName);
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { getRelationFieldInfo } from '../remult3/relationInfoMember.js';
|
|
2
|
-
|
|
2
|
+
import { isSqlExpressionInProgress, runSqlExpression, } from './sqlExpressionInProgress.js';
|
|
3
3
|
export const originalSqlExpressionKey = Symbol.for(`originalSqlExpressionKey`);
|
|
4
4
|
export async function fieldDbName(f, meta, wrapIdentifier = (x) => x, forceSqlExpression = false) {
|
|
5
5
|
try {
|
|
6
6
|
if (f.options.sqlExpression) {
|
|
7
7
|
let result;
|
|
8
8
|
if (typeof f.options.sqlExpression === 'function') {
|
|
9
|
-
if (f
|
|
9
|
+
if (isSqlExpressionInProgress(f) && !forceSqlExpression) {
|
|
10
10
|
return "recursive sqlExpression call for field '" + f.key + "'. \0";
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
f[
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!result.includes('\0'))
|
|
19
|
-
f.options.sqlExpression = () => result;
|
|
20
|
-
}
|
|
21
|
-
finally {
|
|
22
|
-
delete f[sqlExpressionInProgressKey];
|
|
23
|
-
}
|
|
12
|
+
const { sqlExpression } = f.options;
|
|
13
|
+
if (!f[originalSqlExpressionKey])
|
|
14
|
+
f[originalSqlExpressionKey] = sqlExpression;
|
|
15
|
+
result = await runSqlExpression(f, () => sqlExpression(meta, undefined, undefined));
|
|
16
|
+
if (!result.includes('\0'))
|
|
17
|
+
f.options.sqlExpression = () => result;
|
|
24
18
|
}
|
|
25
19
|
else
|
|
26
20
|
result = f.options.sqlExpression;
|
|
@@ -223,10 +223,10 @@ export function shouldCreateEntity(entity, e) {
|
|
|
223
223
|
export async function dbNamesOf(repo, wrapIdentifierOrOptions) {
|
|
224
224
|
return internalDbNamesOf(repo, wrapIdentifierOrOptions);
|
|
225
225
|
}
|
|
226
|
-
export async function dbNamesOfWithForceSqlExpression(repo, wrapIdentifierOrOptions) {
|
|
227
|
-
return internalDbNamesOf(repo, wrapIdentifierOrOptions, true);
|
|
226
|
+
export async function dbNamesOfWithForceSqlExpression(repo, wrapIdentifierOrOptions, forceEntitySqlExpression = false) {
|
|
227
|
+
return internalDbNamesOf(repo, wrapIdentifierOrOptions, true, forceEntitySqlExpression);
|
|
228
228
|
}
|
|
229
|
-
async function internalDbNamesOf(repo, wrapIdentifierOrOptions, forceSqlExpression = false) {
|
|
229
|
+
async function internalDbNamesOf(repo, wrapIdentifierOrOptions, forceSqlExpression = false, forceEntitySqlExpression = false) {
|
|
230
230
|
let options = typeof wrapIdentifierOrOptions === 'function'
|
|
231
231
|
? { wrapIdentifier: wrapIdentifierOrOptions }
|
|
232
232
|
: wrapIdentifierOrOptions || {};
|
|
@@ -237,7 +237,7 @@ async function internalDbNamesOf(repo, wrapIdentifierOrOptions, forceSqlExpressi
|
|
|
237
237
|
if (!options.wrapIdentifier)
|
|
238
238
|
options.wrapIdentifier = (x) => x;
|
|
239
239
|
const result = {
|
|
240
|
-
$entityName: await entityDbName(meta, options.wrapIdentifier),
|
|
240
|
+
$entityName: await entityDbName(meta, options.wrapIdentifier, forceEntitySqlExpression),
|
|
241
241
|
toString: () => result.$entityName,
|
|
242
242
|
$dbNameOf: (field) => {
|
|
243
243
|
var key;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const sqlExpressionInProgressKey = Symbol.for(`sqlExpressionInProgressKey`);
|
|
2
|
+
export function isSqlExpressionInProgress(owner) {
|
|
3
|
+
return owner[sqlExpressionInProgressKey];
|
|
4
|
+
}
|
|
5
|
+
export async function runSqlExpression(owner, sqlExpression) {
|
|
6
|
+
try {
|
|
7
|
+
;
|
|
8
|
+
owner[sqlExpressionInProgressKey] = true;
|
|
9
|
+
return await sqlExpression();
|
|
10
|
+
}
|
|
11
|
+
finally {
|
|
12
|
+
delete owner[sqlExpressionInProgressKey];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -26,6 +26,7 @@ export class QueryResultImpl {
|
|
|
26
26
|
page: page,
|
|
27
27
|
load: this.options.load,
|
|
28
28
|
include: this.options.include,
|
|
29
|
+
args: this.options.args,
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
async count() {
|
|
@@ -51,6 +52,7 @@ export class QueryResultImpl {
|
|
|
51
52
|
limit: this.options.pageSize,
|
|
52
53
|
load: this.options.load,
|
|
53
54
|
include: this.options.include,
|
|
55
|
+
args: this.options.args,
|
|
54
56
|
};
|
|
55
57
|
let getItems = () => this.repo.find(options);
|
|
56
58
|
if (this._aggregates === undefined &&
|
|
@@ -1799,7 +1799,8 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1799
1799
|
if (!this.repo._dataProvider.isProxy)
|
|
1800
1800
|
//y2 should be changed to be based on data provider - consider naming
|
|
1801
1801
|
for (const col of this.info.fieldsMetadata) {
|
|
1802
|
-
if (col.options.serverExpression
|
|
1802
|
+
if (col.options.serverExpression &&
|
|
1803
|
+
!this._fieldsExcludedBySelect?.has(col.key)) {
|
|
1803
1804
|
const result = (await col.options.serverExpression(this.instance));
|
|
1804
1805
|
if (result !== undefined)
|
|
1805
1806
|
this.instance[col.key] = result;
|
package/package.json
CHANGED
package/remult-knex/index.js
CHANGED
|
@@ -185,7 +185,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
185
185
|
case 0:
|
|
186
186
|
_a = sql_database_js_1.groupByImpl;
|
|
187
187
|
_b = [options];
|
|
188
|
-
return [4 /*yield*/, (0,
|
|
188
|
+
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, this.dp.wrapIdentifier, true)];
|
|
189
189
|
case 1: return [2 /*return*/, _a.apply(void 0, _b.concat([_c.sent(), this.dp.createCommand(),
|
|
190
190
|
false,
|
|
191
191
|
function (limit, offset) {
|
|
@@ -320,7 +320,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
320
320
|
var _this = this;
|
|
321
321
|
return tslib_1.__generator(this, function (_a) {
|
|
322
322
|
switch (_a.label) {
|
|
323
|
-
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, function (x) { return x; })];
|
|
323
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, function (x) { return x; }, true)];
|
|
324
324
|
case 1:
|
|
325
325
|
r = (_a.sent());
|
|
326
326
|
return [2 /*return*/, {
|
package/remult-mongo.js
CHANGED
|
@@ -619,7 +619,7 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
619
619
|
var e, collection;
|
|
620
620
|
return tslib_1.__generator(this, function (_a) {
|
|
621
621
|
switch (_a.label) {
|
|
622
|
-
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.
|
|
622
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, undefined, true)];
|
|
623
623
|
case 1:
|
|
624
624
|
e = _a.sent();
|
|
625
625
|
collection = this.db.collection(e.$entityName);
|
|
@@ -475,9 +475,7 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
|
|
|
475
475
|
var _this = this;
|
|
476
476
|
return tslib_1.__generator(this, function (_a) {
|
|
477
477
|
switch (_a.label) {
|
|
478
|
-
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, function (x) {
|
|
479
|
-
return _this.sql.wrapIdentifier(x);
|
|
480
|
-
})];
|
|
478
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, function (x) { return _this.sql.wrapIdentifier(x); }, true)];
|
|
481
479
|
case 1:
|
|
482
480
|
dbNameProvider = _a.sent();
|
|
483
481
|
return [4 /*yield*/, this.iAmUsed(dbNameProvider)];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { EntityMetadata } from '../remult3/remult3.js';
|
|
2
|
-
export declare function entityDbName(metadata: EntityMetadata, wrapIdentifier?: (name: string) => string): Promise<string>;
|
|
2
|
+
export declare function entityDbName(metadata: EntityMetadata, wrapIdentifier?: (name: string) => string, forceSqlExpression?: boolean): Promise<string>;
|
|
@@ -2,30 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.entityDbName = entityDbName;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var sqlExpressionInProgress_js_1 = require("./sqlExpressionInProgress.js");
|
|
5
6
|
function entityDbName(metadata_1) {
|
|
6
|
-
return tslib_1.__awaiter(this, arguments, void 0, function (metadata, wrapIdentifier) {
|
|
7
|
-
var
|
|
7
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (metadata, wrapIdentifier, forceSqlExpression) {
|
|
8
|
+
var sqlExpression_1;
|
|
8
9
|
if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }
|
|
10
|
+
if (forceSqlExpression === void 0) { forceSqlExpression = false; }
|
|
9
11
|
return tslib_1.__generator(this, function (_a) {
|
|
10
12
|
switch (_a.label) {
|
|
11
13
|
case 0:
|
|
12
|
-
if (!metadata.options.sqlExpression) return [3 /*break*/,
|
|
14
|
+
if (!metadata.options.sqlExpression) return [3 /*break*/, 3];
|
|
13
15
|
if (!(typeof metadata.options.sqlExpression === 'string')) return [3 /*break*/, 1];
|
|
14
16
|
return [2 /*return*/, metadata.options.sqlExpression];
|
|
15
17
|
case 1:
|
|
16
|
-
if (!(typeof metadata.options.sqlExpression === 'function')) return [3 /*break*/,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
case 3: return [2 /*return*/,
|
|
25
|
-
case 4:
|
|
26
|
-
metadata.options.sqlExpression = prev;
|
|
27
|
-
return [7 /*endfinally*/];
|
|
28
|
-
case 5: return [2 /*return*/, wrapIdentifier(metadata.dbName)];
|
|
18
|
+
if (!(typeof metadata.options.sqlExpression === 'function')) return [3 /*break*/, 3];
|
|
19
|
+
if ((0, sqlExpressionInProgress_js_1.isSqlExpressionInProgress)(metadata) && !forceSqlExpression)
|
|
20
|
+
return [2 /*return*/, "recursive sqlExpression call for entity '" + metadata.key + "'. "];
|
|
21
|
+
sqlExpression_1 = metadata.options.sqlExpression;
|
|
22
|
+
return [4 /*yield*/, (0, sqlExpressionInProgress_js_1.runSqlExpression)(metadata, function () {
|
|
23
|
+
return sqlExpression_1(metadata);
|
|
24
|
+
})];
|
|
25
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
26
|
+
case 3: return [2 /*return*/, wrapIdentifier(metadata.dbName)];
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
});
|
|
@@ -4,47 +4,41 @@ exports.originalSqlExpressionKey = void 0;
|
|
|
4
4
|
exports.fieldDbName = fieldDbName;
|
|
5
5
|
var tslib_1 = require("tslib");
|
|
6
6
|
var relationInfoMember_js_1 = require("../remult3/relationInfoMember.js");
|
|
7
|
-
var
|
|
7
|
+
var sqlExpressionInProgress_js_1 = require("./sqlExpressionInProgress.js");
|
|
8
8
|
exports.originalSqlExpressionKey = Symbol.for("originalSqlExpressionKey");
|
|
9
9
|
function fieldDbName(f_1, meta_1) {
|
|
10
10
|
return tslib_1.__awaiter(this, arguments, void 0, function (f, meta, wrapIdentifier, forceSqlExpression) {
|
|
11
|
-
var result_1, rel, field, fInfo;
|
|
11
|
+
var result_1, sqlExpression_1, rel, field, fInfo;
|
|
12
12
|
if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }
|
|
13
13
|
if (forceSqlExpression === void 0) { forceSqlExpression = false; }
|
|
14
14
|
return tslib_1.__generator(this, function (_a) {
|
|
15
15
|
switch (_a.label) {
|
|
16
16
|
case 0:
|
|
17
|
-
_a.trys.push([0, ,
|
|
18
|
-
if (!f.options.sqlExpression) return [3 /*break*/,
|
|
19
|
-
if (!(typeof f.options.sqlExpression === 'function')) return [3 /*break*/,
|
|
20
|
-
if (f
|
|
17
|
+
_a.trys.push([0, , 5, 6]);
|
|
18
|
+
if (!f.options.sqlExpression) return [3 /*break*/, 4];
|
|
19
|
+
if (!(typeof f.options.sqlExpression === 'function')) return [3 /*break*/, 2];
|
|
20
|
+
if ((0, sqlExpressionInProgress_js_1.isSqlExpressionInProgress)(f) && !forceSqlExpression) {
|
|
21
21
|
return [2 /*return*/, "recursive sqlExpression call for field '" + f.key + "'. \0"];
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
case 1:
|
|
25
|
-
_a.trys.push([1, , 3, 4]);
|
|
26
|
-
;
|
|
27
|
-
f[sqlExpressionInProgressKey] = true;
|
|
23
|
+
sqlExpression_1 = f.options.sqlExpression;
|
|
28
24
|
if (!f[exports.originalSqlExpressionKey])
|
|
29
|
-
f[exports.originalSqlExpressionKey] =
|
|
30
|
-
return [4 /*yield*/,
|
|
31
|
-
|
|
25
|
+
f[exports.originalSqlExpressionKey] = sqlExpression_1;
|
|
26
|
+
return [4 /*yield*/, (0, sqlExpressionInProgress_js_1.runSqlExpression)(f, function () {
|
|
27
|
+
return sqlExpression_1(meta, undefined, undefined);
|
|
28
|
+
})];
|
|
29
|
+
case 1:
|
|
32
30
|
result_1 = _a.sent();
|
|
33
31
|
if (!result_1.includes('\0'))
|
|
34
32
|
f.options.sqlExpression = function () { return result_1; };
|
|
35
|
-
return [3 /*break*/,
|
|
36
|
-
case
|
|
37
|
-
delete f[sqlExpressionInProgressKey];
|
|
38
|
-
return [7 /*endfinally*/];
|
|
39
|
-
case 4: return [3 /*break*/, 6];
|
|
40
|
-
case 5:
|
|
33
|
+
return [3 /*break*/, 3];
|
|
34
|
+
case 2:
|
|
41
35
|
result_1 = f.options.sqlExpression;
|
|
42
|
-
_a.label =
|
|
43
|
-
case
|
|
36
|
+
_a.label = 3;
|
|
37
|
+
case 3:
|
|
44
38
|
if (!result_1)
|
|
45
39
|
return [2 /*return*/, f.dbName];
|
|
46
40
|
return [2 /*return*/, result_1];
|
|
47
|
-
case
|
|
41
|
+
case 4:
|
|
48
42
|
rel = (0, relationInfoMember_js_1.getRelationFieldInfo)(f);
|
|
49
43
|
field = (rel === null || rel === void 0 ? void 0 : rel.type) === 'toOne' &&
|
|
50
44
|
f.options.field;
|
|
@@ -54,8 +48,8 @@ function fieldDbName(f_1, meta_1) {
|
|
|
54
48
|
return [2 /*return*/, fieldDbName(fInfo, meta, wrapIdentifier, forceSqlExpression)];
|
|
55
49
|
}
|
|
56
50
|
return [2 /*return*/, wrapIdentifier(f.dbName)];
|
|
57
|
-
case
|
|
58
|
-
case
|
|
51
|
+
case 5: return [7 /*endfinally*/];
|
|
52
|
+
case 6: return [2 /*return*/];
|
|
59
53
|
}
|
|
60
54
|
});
|
|
61
55
|
});
|
|
@@ -88,5 +88,5 @@ export interface dbNamesOfOptions {
|
|
|
88
88
|
tableName?: boolean | string;
|
|
89
89
|
}
|
|
90
90
|
export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions): Promise<EntityDbNames<entityType>>;
|
|
91
|
-
export declare function dbNamesOfWithForceSqlExpression<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions): Promise<EntityDbNames<entityType>>;
|
|
91
|
+
export declare function dbNamesOfWithForceSqlExpression<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions, forceEntitySqlExpression?: boolean): Promise<EntityDbNames<entityType>>;
|
|
92
92
|
export declare function toDbSql(r: SqlCommandWithParameters, field: FieldMetadata, val: any): string;
|
|
@@ -347,18 +347,20 @@ function dbNamesOf(repo, wrapIdentifierOrOptions) {
|
|
|
347
347
|
});
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
|
-
function dbNamesOfWithForceSqlExpression(
|
|
351
|
-
return tslib_1.__awaiter(this,
|
|
350
|
+
function dbNamesOfWithForceSqlExpression(repo_1, wrapIdentifierOrOptions_1) {
|
|
351
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (repo, wrapIdentifierOrOptions, forceEntitySqlExpression) {
|
|
352
|
+
if (forceEntitySqlExpression === void 0) { forceEntitySqlExpression = false; }
|
|
352
353
|
return tslib_1.__generator(this, function (_a) {
|
|
353
|
-
return [2 /*return*/, internalDbNamesOf(repo, wrapIdentifierOrOptions, true)];
|
|
354
|
+
return [2 /*return*/, internalDbNamesOf(repo, wrapIdentifierOrOptions, true, forceEntitySqlExpression)];
|
|
354
355
|
});
|
|
355
356
|
});
|
|
356
357
|
}
|
|
357
358
|
function internalDbNamesOf(repo_1, wrapIdentifierOrOptions_1) {
|
|
358
|
-
return tslib_1.__awaiter(this, arguments, void 0, function (repo, wrapIdentifierOrOptions, forceSqlExpression) {
|
|
359
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (repo, wrapIdentifierOrOptions, forceSqlExpression, forceEntitySqlExpression) {
|
|
359
360
|
var options, meta, result, _a, _b, field, r, e_3_1;
|
|
360
361
|
var _c, e_3, _d;
|
|
361
362
|
if (forceSqlExpression === void 0) { forceSqlExpression = false; }
|
|
363
|
+
if (forceEntitySqlExpression === void 0) { forceEntitySqlExpression = false; }
|
|
362
364
|
return tslib_1.__generator(this, function (_e) {
|
|
363
365
|
switch (_e.label) {
|
|
364
366
|
case 0:
|
|
@@ -372,7 +374,7 @@ function internalDbNamesOf(repo_1, wrapIdentifierOrOptions_1) {
|
|
|
372
374
|
if (!options.wrapIdentifier)
|
|
373
375
|
options.wrapIdentifier = function (x) { return x; };
|
|
374
376
|
_c = {};
|
|
375
|
-
return [4 /*yield*/, (0, entityDbName_js_1.entityDbName)(meta, options.wrapIdentifier)];
|
|
377
|
+
return [4 /*yield*/, (0, entityDbName_js_1.entityDbName)(meta, options.wrapIdentifier, forceEntitySqlExpression)];
|
|
376
378
|
case 1:
|
|
377
379
|
result = (_c.$entityName = _e.sent(),
|
|
378
380
|
_c.toString = function () { return result.$entityName; },
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSqlExpressionInProgress = isSqlExpressionInProgress;
|
|
4
|
+
exports.runSqlExpression = runSqlExpression;
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
6
|
+
var sqlExpressionInProgressKey = Symbol.for("sqlExpressionInProgressKey");
|
|
7
|
+
function isSqlExpressionInProgress(owner) {
|
|
8
|
+
return owner[sqlExpressionInProgressKey];
|
|
9
|
+
}
|
|
10
|
+
function runSqlExpression(owner, sqlExpression) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
12
|
+
return tslib_1.__generator(this, function (_a) {
|
|
13
|
+
switch (_a.label) {
|
|
14
|
+
case 0:
|
|
15
|
+
_a.trys.push([0, , 2, 3]);
|
|
16
|
+
;
|
|
17
|
+
owner[sqlExpressionInProgressKey] = true;
|
|
18
|
+
return [4 /*yield*/, sqlExpression()];
|
|
19
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
20
|
+
case 2:
|
|
21
|
+
delete owner[sqlExpressionInProgressKey];
|
|
22
|
+
return [7 /*endfinally*/];
|
|
23
|
+
case 3: return [2 /*return*/];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -29,6 +29,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
29
29
|
page: page,
|
|
30
30
|
load: this.options.load,
|
|
31
31
|
include: this.options.include,
|
|
32
|
+
args: this.options.args,
|
|
32
33
|
})];
|
|
33
34
|
});
|
|
34
35
|
});
|
|
@@ -115,6 +116,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
115
116
|
limit: this.options.pageSize,
|
|
116
117
|
load: this.options.load,
|
|
117
118
|
include: this.options.include,
|
|
119
|
+
args: this.options.args,
|
|
118
120
|
};
|
|
119
121
|
getItems = function () { return _this.repo.find(options); };
|
|
120
122
|
if (this._aggregates === undefined &&
|
|
@@ -3092,31 +3092,33 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
3092
3092
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3093
3093
|
var _a, _b, col, result, e_46_1;
|
|
3094
3094
|
var e_46, _c;
|
|
3095
|
-
|
|
3096
|
-
|
|
3095
|
+
var _d;
|
|
3096
|
+
return tslib_1.__generator(this, function (_e) {
|
|
3097
|
+
switch (_e.label) {
|
|
3097
3098
|
case 0:
|
|
3098
3099
|
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 8];
|
|
3099
|
-
|
|
3100
|
+
_e.label = 1;
|
|
3100
3101
|
case 1:
|
|
3101
|
-
|
|
3102
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
3102
3103
|
_a = tslib_1.__values(this.info.fieldsMetadata), _b = _a.next();
|
|
3103
|
-
|
|
3104
|
+
_e.label = 2;
|
|
3104
3105
|
case 2:
|
|
3105
3106
|
if (!!_b.done) return [3 /*break*/, 5];
|
|
3106
3107
|
col = _b.value;
|
|
3107
|
-
if (!col.options.serverExpression
|
|
3108
|
+
if (!(col.options.serverExpression &&
|
|
3109
|
+
!((_d = this._fieldsExcludedBySelect) === null || _d === void 0 ? void 0 : _d.has(col.key)))) return [3 /*break*/, 4];
|
|
3108
3110
|
return [4 /*yield*/, col.options.serverExpression(this.instance)];
|
|
3109
3111
|
case 3:
|
|
3110
|
-
result = (
|
|
3112
|
+
result = (_e.sent());
|
|
3111
3113
|
if (result !== undefined)
|
|
3112
3114
|
this.instance[col.key] = result;
|
|
3113
|
-
|
|
3115
|
+
_e.label = 4;
|
|
3114
3116
|
case 4:
|
|
3115
3117
|
_b = _a.next();
|
|
3116
3118
|
return [3 /*break*/, 2];
|
|
3117
3119
|
case 5: return [3 /*break*/, 8];
|
|
3118
3120
|
case 6:
|
|
3119
|
-
e_46_1 =
|
|
3121
|
+
e_46_1 = _e.sent();
|
|
3120
3122
|
e_46 = { error: e_46_1 };
|
|
3121
3123
|
return [3 /*break*/, 8];
|
|
3122
3124
|
case 7:
|