remult 0.27.8 → 0.27.9
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 +1 -1
- package/esm/src/data-providers/sql-database.js +3 -0
- package/esm/src/remult3/RepositoryImplementation.js +3 -3
- package/package.json +1 -1
- package/remult-knex/index.js +1 -1
- package/src/data-providers/sql-database.js +4 -1
- package/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/src/remult3/RepositoryImplementation.js +3 -3
package/esm/remult-knex/index.js
CHANGED
|
@@ -118,7 +118,7 @@ class KnexEntityDataProvider {
|
|
|
118
118
|
this.dp = dp;
|
|
119
119
|
}
|
|
120
120
|
async groupBy(options) {
|
|
121
|
-
return groupByImpl(options, await this.
|
|
121
|
+
return groupByImpl(options, await dbNamesOf(this.entity, this.dp.wrapIdentifier), this.dp.createCommand(), false, (limit, offset) => ' limit ' + limit + ' offset ' + offset);
|
|
122
122
|
}
|
|
123
123
|
async count(where) {
|
|
124
124
|
const e = await this.init();
|
|
@@ -576,7 +576,10 @@ export async function groupByImpl(options, e, r, orderByNullFirst, limitSyntax)
|
|
|
576
576
|
const dbName = await e.$dbNameOf(x);
|
|
577
577
|
select += `, ${aggregateSqlSyntax(operator, dbName)} as ${x.key}_${operator}`;
|
|
578
578
|
}
|
|
579
|
+
const turnToNumber = x.valueType === Number || operator == 'distinctCount';
|
|
579
580
|
processResultRow.push((sqlResult, theResult) => {
|
|
581
|
+
if (turnToNumber)
|
|
582
|
+
sqlResult = Number(sqlResult);
|
|
580
583
|
theResult[x.key] = { ...theResult[x.key], [operator]: sqlResult };
|
|
581
584
|
});
|
|
582
585
|
}
|
|
@@ -195,7 +195,7 @@ export class RepositoryImplementation {
|
|
|
195
195
|
loaderOptions.include[key] = true;
|
|
196
196
|
}
|
|
197
197
|
const loader = new RelationLoader();
|
|
198
|
-
await this.
|
|
198
|
+
await this._populateRelationsForFields(dpOptions.group, loaderOptions, result, loader);
|
|
199
199
|
await loader.resolveAll();
|
|
200
200
|
}
|
|
201
201
|
return result;
|
|
@@ -553,10 +553,10 @@ export class RepositoryImplementation {
|
|
|
553
553
|
}
|
|
554
554
|
let result = await promiseAll(rawRows, async (r) => await this._mapRawDataToResult(r, loadFields));
|
|
555
555
|
const fields = this.metadata.fields.toArray();
|
|
556
|
-
this.
|
|
556
|
+
this._populateRelationsForFields(fields, loadOptions, result, loader);
|
|
557
557
|
return result;
|
|
558
558
|
}
|
|
559
|
-
|
|
559
|
+
_populateRelationsForFields(fields, loadOptions, result, loader) {
|
|
560
560
|
for (const col of fields) {
|
|
561
561
|
let rel = getRelationFieldInfo(col);
|
|
562
562
|
let incl = col.options
|
package/package.json
CHANGED
package/remult-knex/index.js
CHANGED
|
@@ -210,7 +210,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
210
210
|
case 0:
|
|
211
211
|
_a = sql_database_js_1.groupByImpl;
|
|
212
212
|
_b = [options];
|
|
213
|
-
return [4 /*yield*/, this.
|
|
213
|
+
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(this.entity, this.dp.wrapIdentifier)];
|
|
214
214
|
case 1: return [2 /*return*/, _a.apply(void 0, _b.concat([_c.sent(), this.dp.createCommand(),
|
|
215
215
|
false,
|
|
216
216
|
function (limit, offset) { return ' limit ' + limit + ' offset ' + offset; }]))];
|
|
@@ -884,7 +884,7 @@ function groupByImpl(options, e, r, orderByNullFirst, limitSyntax) {
|
|
|
884
884
|
fields = options === null || options === void 0 ? void 0 : options[operator];
|
|
885
885
|
if (!fields) return [3 /*break*/, 8];
|
|
886
886
|
_loop_4 = function (x) {
|
|
887
|
-
var dbName;
|
|
887
|
+
var dbName, turnToNumber;
|
|
888
888
|
return tslib_1.__generator(this, function (_o) {
|
|
889
889
|
switch (_o.label) {
|
|
890
890
|
case 0:
|
|
@@ -896,8 +896,11 @@ function groupByImpl(options, e, r, orderByNullFirst, limitSyntax) {
|
|
|
896
896
|
select += ", ".concat(aggregateSqlSyntax(operator, dbName), " as ").concat(x.key, "_").concat(operator);
|
|
897
897
|
_o.label = 3;
|
|
898
898
|
case 3:
|
|
899
|
+
turnToNumber = x.valueType === Number || operator == 'distinctCount';
|
|
899
900
|
processResultRow.push(function (sqlResult, theResult) {
|
|
900
901
|
var _a;
|
|
902
|
+
if (turnToNumber)
|
|
903
|
+
sqlResult = Number(sqlResult);
|
|
901
904
|
theResult[x.key] = tslib_1.__assign(tslib_1.__assign({}, theResult[x.key]), (_a = {}, _a[operator] = sqlResult, _a));
|
|
902
905
|
});
|
|
903
906
|
return [2 /*return*/];
|
|
@@ -65,7 +65,7 @@ export declare class RepositoryImplementation<entityType> implements Repository<
|
|
|
65
65
|
_buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
|
|
66
66
|
_fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<entityType[]>;
|
|
67
67
|
private _loadManyToOneForManyRows;
|
|
68
|
-
private
|
|
68
|
+
private _populateRelationsForFields;
|
|
69
69
|
private _mapRawDataToResult;
|
|
70
70
|
toJson(item: entityType | entityType[] | Promise<entityType> | Promise<entityType[]>): any;
|
|
71
71
|
fromJson(x: any[], isNew?: boolean): entityType[];
|
|
@@ -276,7 +276,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
276
276
|
finally { if (e_4) throw e_4.error; }
|
|
277
277
|
}
|
|
278
278
|
loader = new relation_loader_js_1.RelationLoader();
|
|
279
|
-
return [4 /*yield*/, this.
|
|
279
|
+
return [4 /*yield*/, this._populateRelationsForFields(dpOptions.group, loaderOptions, result, loader)];
|
|
280
280
|
case 3:
|
|
281
281
|
_k.sent();
|
|
282
282
|
return [4 /*yield*/, loader.resolveAll()];
|
|
@@ -966,13 +966,13 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
966
966
|
case 9:
|
|
967
967
|
result = _e.sent();
|
|
968
968
|
fields = this.metadata.fields.toArray();
|
|
969
|
-
this.
|
|
969
|
+
this._populateRelationsForFields(fields, loadOptions, result, loader);
|
|
970
970
|
return [2 /*return*/, result];
|
|
971
971
|
}
|
|
972
972
|
});
|
|
973
973
|
});
|
|
974
974
|
};
|
|
975
|
-
RepositoryImplementation.prototype.
|
|
975
|
+
RepositoryImplementation.prototype._populateRelationsForFields = function (fields, loadOptions, result, loader) {
|
|
976
976
|
var e_14, _a;
|
|
977
977
|
var _b;
|
|
978
978
|
var _loop_1 = function (col) {
|