tspace-mysql 1.1.0 → 1.1.1
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.
|
@@ -187,7 +187,7 @@ var Database = /** @class */ (function (_super) {
|
|
|
187
187
|
}
|
|
188
188
|
var select = '*';
|
|
189
189
|
if (columns === null || columns === void 0 ? void 0 : columns.length)
|
|
190
|
-
select = columns.join(',');
|
|
190
|
+
select = columns.join(', ');
|
|
191
191
|
this.$db.set('SELECT', "".concat(this.$constants('SELECT'), " ").concat(select));
|
|
192
192
|
return this;
|
|
193
193
|
};
|
|
@@ -485,11 +485,11 @@ declare class Model extends AbstractModel {
|
|
|
485
485
|
*/
|
|
486
486
|
faker(rows?: number): Promise<any>;
|
|
487
487
|
/**
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
*
|
|
489
|
+
* @override Method
|
|
490
|
+
* @param {number} id
|
|
491
|
+
* @return {this}
|
|
492
|
+
*/
|
|
493
493
|
whereUser(id: number): this;
|
|
494
494
|
private _queryStatementModel;
|
|
495
495
|
private _actionStatementModel;
|
package/dist/lib/tspace/Model.js
CHANGED
|
@@ -1519,11 +1519,11 @@ var Model = /** @class */ (function (_super) {
|
|
|
1519
1519
|
});
|
|
1520
1520
|
};
|
|
1521
1521
|
/**
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1522
|
+
*
|
|
1523
|
+
* @override Method
|
|
1524
|
+
* @param {number} id
|
|
1525
|
+
* @return {this}
|
|
1526
|
+
*/
|
|
1527
1527
|
Model.prototype.whereUser = function (id) {
|
|
1528
1528
|
var column = this._valuePattern('userId');
|
|
1529
1529
|
id = this.$utils.escape(id);
|
|
@@ -1918,6 +1918,7 @@ var Model = /** @class */ (function (_super) {
|
|
|
1918
1918
|
var _a;
|
|
1919
1919
|
return __awaiter(this, void 0, void 0, function () {
|
|
1920
1920
|
var _b, localKey, foreignKey, localKeyId, dataPerentId, query, dataFromRelation;
|
|
1921
|
+
var _this = this;
|
|
1921
1922
|
return __generator(this, function (_c) {
|
|
1922
1923
|
switch (_c.label) {
|
|
1923
1924
|
case 0:
|
|
@@ -1925,12 +1926,15 @@ var Model = /** @class */ (function (_super) {
|
|
|
1925
1926
|
return [2 /*return*/, []];
|
|
1926
1927
|
_b = this._valueInRelation(relation), localKey = _b.localKey, foreignKey = _b.foreignKey;
|
|
1927
1928
|
localKeyId = parents.map(function (parent) {
|
|
1928
|
-
|
|
1929
|
+
var data = parent[localKey];
|
|
1930
|
+
if (!parent.hasOwnProperty(localKey)) {
|
|
1931
|
+
_this._assertError(data == null, "unknown relationship without primary or foreign key");
|
|
1932
|
+
}
|
|
1933
|
+
return data;
|
|
1929
1934
|
}).filter(function (data) { return data != null; });
|
|
1930
1935
|
dataPerentId = Array.from(new Set(localKeyId)) || [];
|
|
1931
1936
|
if (!dataPerentId.length && this.$db.get('WITH_EXISTS'))
|
|
1932
1937
|
return [2 /*return*/, []];
|
|
1933
|
-
this._assertError(!dataPerentId.length, "unknown relationship without primary or foreign key");
|
|
1934
1938
|
return [4 /*yield*/, relation.query];
|
|
1935
1939
|
case 1:
|
|
1936
1940
|
query = _c.sent();
|
|
@@ -1950,15 +1954,21 @@ var Model = /** @class */ (function (_super) {
|
|
|
1950
1954
|
Model.prototype._handleBelongsToMany = function (dataFromParent, relation, pivotTable) {
|
|
1951
1955
|
return __awaiter(this, void 0, void 0, function () {
|
|
1952
1956
|
var _a, name, localKey, foreignKey, localKeyId, dataPerentId, modelOther, other, otherlocalKey, otherforeignKey, sqldataChilds, dataChilds, otherId, otherArrId, otherdataChilds;
|
|
1957
|
+
var _this = this;
|
|
1953
1958
|
return __generator(this, function (_b) {
|
|
1954
1959
|
switch (_b.label) {
|
|
1955
1960
|
case 0:
|
|
1956
1961
|
_a = this._valueInRelation(relation), name = _a.name, localKey = _a.localKey, foreignKey = _a.foreignKey;
|
|
1957
|
-
localKeyId = dataFromParent.map(function (
|
|
1958
|
-
|
|
1962
|
+
localKeyId = dataFromParent.map(function (parent) {
|
|
1963
|
+
var data = parent[localKey];
|
|
1964
|
+
if (!parent.hasOwnProperty(localKey)) {
|
|
1965
|
+
_this._assertError(data == null, "unknown relationship without primary or foreign key");
|
|
1966
|
+
}
|
|
1967
|
+
return data;
|
|
1959
1968
|
}).filter(function (data) { return data != null; });
|
|
1960
1969
|
dataPerentId = Array.from(new Set(localKeyId)).join(',') || [];
|
|
1961
|
-
|
|
1970
|
+
if (!dataPerentId.length && this.$db.get('WITH_EXISTS'))
|
|
1971
|
+
return [2 /*return*/, []];
|
|
1962
1972
|
modelOther = new relation.model();
|
|
1963
1973
|
other = this._classToTableName(modelOther.constructor.name, { singular: true });
|
|
1964
1974
|
otherlocalKey = 'id';
|