remult 0.14.6 → 0.14.7
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/assign.js +5 -1
- package/classType.js +2 -1
- package/graphql.js +146 -84
- package/index.js +73 -25
- package/inputTypes.js +16 -9
- package/package.json +1 -2
- package/postgres/index.js +4 -1
- package/postgres/postgres-data-provider.d.ts +4 -1
- package/postgres/postgres-data-provider.js +364 -165
- package/postgres/postgresColumnSyntax.d.ts +1 -1
- package/postgres/postgresColumnSyntax.js +8 -4
- package/remult-express.js +10 -6
- package/remult-knex/index.d.ts +5 -2
- package/remult-knex/index.js +720 -300
- package/remult-middleware.js +29 -24
- package/remult-mongo.js +406 -172
- package/server/JsonEntityFileStorage.js +15 -10
- package/server/expressBridge.d.ts +4 -2
- package/server/expressBridge.js +570 -383
- package/server/index.js +11 -4
- package/server/register-actions-on-server.js +38 -12
- package/server/register-entities-on-server.js +13 -9
- package/src/__EntityValueProvider.js +2 -1
- package/src/__RowsOfDataForTesting.js +2 -1
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +190 -72
- package/src/backend-tests/my-test.backend-spec.js +114 -45
- package/src/column-interfaces.js +6 -2
- package/src/column.js +113 -71
- package/src/context.js +330 -174
- package/src/data-api.js +326 -162
- package/src/data-interfaces.js +11 -7
- package/src/data-providers/array-entity-data-provider.js +286 -171
- package/src/data-providers/in-memory-database.js +27 -12
- package/src/data-providers/json-data-provider.js +77 -41
- package/src/data-providers/rest-data-provider.js +189 -102
- package/src/data-providers/sql-database.js +403 -223
- package/src/data-providers/web-sql-data-provider.js +139 -78
- package/src/entity.js +2 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +1 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.js +248 -106
- package/src/filter/filter-consumer-bridge-to-url-builder.js +2 -1
- package/src/filter/filter-interfaces.js +440 -277
- package/src/id-entity.js +17 -8
- package/src/remult3/RepositoryImplementation.js +2367 -1191
- package/src/remult3/index.js +5 -2
- package/src/remult3/remult3.js +2 -1
- package/src/server-action.js +528 -294
- package/src/shared-tests/db-tests-setup.js +153 -49
- package/src/shared-tests/db-tests.db-tests.js +1566 -660
- package/src/shared-tests/deleteAll.js +20 -3
- package/src/shared-tests/entityWithValidations.js +79 -52
- package/src/shared-tests/index.js +6 -4
- package/src/shared-tests/test-custom-id-column.spec.js +85 -37
- package/src/shared-tests/test-special-value.spec.js +104 -64
- package/src/shared-tests/test-update-with-null.spec.js +49 -28
- package/src/sort.js +95 -38
- package/src/sql-command.js +2 -1
- package/src/tests/Done.js +13 -7
- package/src/tests/TestDataApiResponse.js +22 -15
- package/src/tests/c.js +27 -21
- package/src/tests/createData.js +48 -20
- package/src/tests/d.js +27 -19
- package/src/tests/dWithPrefilter.js +44 -31
- package/src/tests/entityForCustomFilter.js +66 -42
- package/src/tests/entityWithValidationsOnColumn.js +29 -21
- package/src/tests/frontend-database-tests-setup.spec.js +98 -35
- package/src/tests/h.js +44 -35
- package/src/tests/remult-3-entities.js +80 -71
- package/src/tests/tasks.js +29 -23
- package/src/tests/testHelper.spec.js +322 -170
- package/src/tests/testModel/models.js +33 -25
- package/src/validators.js +59 -32
- package/urlBuilder.js +14 -8
- package/valueConverters.js +160 -161
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteAll = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
function deleteAll(r) {
|
|
6
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
return tslib_1.__generator(this, function (_c) {
|
|
9
|
+
switch (_c.label) {
|
|
10
|
+
case 0:
|
|
11
|
+
_b = (_a = Promise).all;
|
|
12
|
+
return [4 /*yield*/, r.find()];
|
|
13
|
+
case 1: return [4 /*yield*/, _b.apply(_a, [(_c.sent()).map(function (x) { return r.delete(x); })])];
|
|
14
|
+
case 2:
|
|
15
|
+
_c.sent();
|
|
16
|
+
return [2 /*return*/, r];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
4
20
|
}
|
|
21
|
+
exports.deleteAll = deleteAll;
|
|
@@ -1,53 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entityWithValidations = exports.testConfiguration = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var context_1 = require("../context");
|
|
6
|
+
var remult3_1 = require("../remult3");
|
|
7
|
+
exports.testConfiguration = { restDbRunningOnServer: false };
|
|
8
|
+
var entityWithValidations = /** @class */ (function (_super) {
|
|
9
|
+
tslib_1.__extends(entityWithValidations, _super);
|
|
10
|
+
function entityWithValidations(remult) {
|
|
11
|
+
var _this = _super.call(this) || this;
|
|
12
|
+
_this.remult = remult;
|
|
13
|
+
return _this;
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
15
|
+
entityWithValidations_1 = entityWithValidations;
|
|
16
|
+
entityWithValidations.create4RowsInDp = function (createEntity) {
|
|
17
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
18
|
+
var s, c;
|
|
19
|
+
return tslib_1.__generator(this, function (_a) {
|
|
20
|
+
switch (_a.label) {
|
|
21
|
+
case 0: return [4 /*yield*/, createEntity(entityWithValidations_1)];
|
|
22
|
+
case 1:
|
|
23
|
+
s = _a.sent();
|
|
24
|
+
c = s.create();
|
|
25
|
+
c.myId = 1;
|
|
26
|
+
c.name = 'noam';
|
|
27
|
+
return [4 /*yield*/, c._.save()];
|
|
28
|
+
case 2:
|
|
29
|
+
_a.sent();
|
|
30
|
+
c = s.create();
|
|
31
|
+
c.myId = 2;
|
|
32
|
+
c.name = 'yael';
|
|
33
|
+
return [4 /*yield*/, c._.save()];
|
|
34
|
+
case 3:
|
|
35
|
+
_a.sent();
|
|
36
|
+
c = s.create();
|
|
37
|
+
c.myId = 3;
|
|
38
|
+
c.name = 'yoni';
|
|
39
|
+
return [4 /*yield*/, c._.save()];
|
|
40
|
+
case 4:
|
|
41
|
+
_a.sent();
|
|
42
|
+
c = s.create();
|
|
43
|
+
c.myId = 4;
|
|
44
|
+
c.name = 'maayan';
|
|
45
|
+
return [4 /*yield*/, c._.save()];
|
|
46
|
+
case 5:
|
|
47
|
+
_a.sent();
|
|
48
|
+
return [2 /*return*/, s];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
var entityWithValidations_1;
|
|
54
|
+
entityWithValidations.savingRowCount = 0;
|
|
55
|
+
tslib_1.__decorate([
|
|
56
|
+
remult3_1.Fields.integer(),
|
|
57
|
+
tslib_1.__metadata("design:type", Number)
|
|
58
|
+
], entityWithValidations.prototype, "myId", void 0);
|
|
59
|
+
tslib_1.__decorate([
|
|
60
|
+
remult3_1.Fields.string(),
|
|
61
|
+
tslib_1.__metadata("design:type", String)
|
|
62
|
+
], entityWithValidations.prototype, "name", void 0);
|
|
63
|
+
entityWithValidations = entityWithValidations_1 = tslib_1.__decorate([
|
|
64
|
+
remult3_1.Entity('', {
|
|
65
|
+
allowApiCrud: true,
|
|
66
|
+
saving: function (t) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
67
|
+
return tslib_1.__generator(this, function (_a) {
|
|
68
|
+
if (!t.name || t.name.length < 3)
|
|
69
|
+
t._.fields.name.error = 'invalid';
|
|
70
|
+
if (!exports.testConfiguration.restDbRunningOnServer)
|
|
71
|
+
entityWithValidations_1.savingRowCount++;
|
|
72
|
+
return [2 /*return*/];
|
|
73
|
+
});
|
|
74
|
+
}); }
|
|
75
|
+
}),
|
|
76
|
+
tslib_1.__metadata("design:paramtypes", [context_1.Remult])
|
|
77
|
+
], entityWithValidations);
|
|
78
|
+
return entityWithValidations;
|
|
79
|
+
}(remult3_1.EntityBase));
|
|
80
|
+
exports.entityWithValidations = entityWithValidations;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("./db-tests.db-tests");
|
|
4
|
+
require("./test-custom-id-column.spec");
|
|
5
|
+
require("./test-special-value.spec");
|
|
6
|
+
require("./test-update-with-null.spec");
|
|
@@ -1,41 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var remult3_1 = require("../remult3");
|
|
5
|
+
var db_tests_setup_1 = require("./db-tests-setup");
|
|
6
|
+
describe("custom id column", function () {
|
|
7
|
+
db_tests_setup_1.testAll("basic test", function (_a) {
|
|
8
|
+
var createEntity = _a.createEntity;
|
|
9
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
10
|
+
var type, c, r;
|
|
11
|
+
return tslib_1.__generator(this, function (_b) {
|
|
12
|
+
switch (_b.label) {
|
|
13
|
+
case 0:
|
|
14
|
+
type = /** @class */ (function (_super) {
|
|
15
|
+
tslib_1.__extends(class_1, _super);
|
|
16
|
+
function class_1() {
|
|
17
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
18
|
+
}
|
|
19
|
+
return class_1;
|
|
20
|
+
}(remult3_1.EntityBase));
|
|
21
|
+
remult3_1.BuildEntity(type, 'custom', {
|
|
22
|
+
a: remult3_1.Fields.number(),
|
|
23
|
+
b: remult3_1.Fields.number()
|
|
24
|
+
}, { allowApiCrud: true });
|
|
25
|
+
return [4 /*yield*/, createEntity(type)];
|
|
26
|
+
case 1:
|
|
27
|
+
c = _b.sent();
|
|
28
|
+
r = c.create();
|
|
29
|
+
r.a = 1;
|
|
30
|
+
r.b = 1;
|
|
31
|
+
return [4 /*yield*/, r._.save()];
|
|
32
|
+
case 2:
|
|
33
|
+
_b.sent();
|
|
34
|
+
r = c.create();
|
|
35
|
+
r.a = 2;
|
|
36
|
+
r.b = 2;
|
|
37
|
+
return [4 /*yield*/, r._.save()];
|
|
38
|
+
case 3:
|
|
39
|
+
_b.sent();
|
|
40
|
+
expect(c.metadata.idMetadata.field.key).toBe(c.metadata.fields.a.key);
|
|
41
|
+
return [2 /*return*/];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
21
45
|
});
|
|
22
|
-
testAll("basic test id column not first column",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
db_tests_setup_1.testAll("basic test id column not first column", function (_a) {
|
|
47
|
+
var createEntity = _a.createEntity;
|
|
48
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
49
|
+
var type, c, r, _b;
|
|
50
|
+
return tslib_1.__generator(this, function (_c) {
|
|
51
|
+
switch (_c.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
type = /** @class */ (function (_super) {
|
|
54
|
+
tslib_1.__extends(class_2, _super);
|
|
55
|
+
function class_2() {
|
|
56
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
57
|
+
}
|
|
58
|
+
return class_2;
|
|
59
|
+
}(remult3_1.EntityBase));
|
|
60
|
+
remult3_1.Entity('custom2', { allowApiCrud: true })(type);
|
|
61
|
+
remult3_1.Fields.number()(type.prototype, 'a');
|
|
62
|
+
remult3_1.Fields.number()(type.prototype, 'id');
|
|
63
|
+
return [4 /*yield*/, createEntity(type)];
|
|
64
|
+
case 1:
|
|
65
|
+
c = _c.sent();
|
|
66
|
+
r = c.create();
|
|
67
|
+
r.a = 1;
|
|
68
|
+
r.id = 5;
|
|
69
|
+
return [4 /*yield*/, r._.save()];
|
|
70
|
+
case 2:
|
|
71
|
+
_c.sent();
|
|
72
|
+
r = c.create();
|
|
73
|
+
r.a = 2;
|
|
74
|
+
r.id = 6;
|
|
75
|
+
return [4 /*yield*/, r._.save()];
|
|
76
|
+
case 3:
|
|
77
|
+
_c.sent();
|
|
78
|
+
expect(r._.repository.metadata.idMetadata.field.key).toBe(r._.fields.id.metadata.key);
|
|
79
|
+
_b = expect;
|
|
80
|
+
return [4 /*yield*/, c.findId(6)];
|
|
81
|
+
case 4:
|
|
82
|
+
_b.apply(void 0, [(_c.sent()).a]).toBe(2);
|
|
83
|
+
return [2 /*return*/];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
39
87
|
});
|
|
40
88
|
});
|
|
41
89
|
//typing game
|
|
@@ -1,88 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupsValue = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var remult3_1 = require("../remult3");
|
|
6
|
+
var db_tests_setup_1 = require("./db-tests-setup");
|
|
7
|
+
var GroupsValue = /** @class */ (function () {
|
|
8
|
+
function GroupsValue(value) {
|
|
7
9
|
this.value = value;
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
GroupsValue_1 = GroupsValue;
|
|
12
|
+
GroupsValue.prototype.hasAny = function () {
|
|
10
13
|
return this.value != '';
|
|
11
|
-
}
|
|
12
|
-
evilGet() {
|
|
14
|
+
};
|
|
15
|
+
GroupsValue.prototype.evilGet = function () {
|
|
13
16
|
return this.value;
|
|
14
|
-
}
|
|
15
|
-
listGroups() {
|
|
17
|
+
};
|
|
18
|
+
GroupsValue.prototype.listGroups = function () {
|
|
16
19
|
if (!this.value)
|
|
17
20
|
return [];
|
|
18
21
|
return this.value.split(',');
|
|
19
|
-
}
|
|
20
|
-
removeGroup(group) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
};
|
|
23
|
+
GroupsValue.prototype.removeGroup = function (group) {
|
|
24
|
+
var groups = this.value.split(",").map(function (x) { return x.trim(); });
|
|
25
|
+
var index = groups.indexOf(group);
|
|
26
|
+
var result = '';
|
|
24
27
|
if (index >= 0) {
|
|
25
28
|
groups.splice(index, 1);
|
|
26
29
|
result = groups.join(", ");
|
|
27
30
|
}
|
|
28
31
|
return new GroupsValue_1(result);
|
|
29
|
-
}
|
|
30
|
-
addGroup(group) {
|
|
31
|
-
|
|
32
|
+
};
|
|
33
|
+
GroupsValue.prototype.addGroup = function (group) {
|
|
34
|
+
var r = this.value;
|
|
32
35
|
if (r)
|
|
33
36
|
r += ', ';
|
|
34
37
|
else
|
|
35
38
|
r = '';
|
|
36
39
|
r += group;
|
|
37
40
|
return new GroupsValue_1(r);
|
|
38
|
-
}
|
|
39
|
-
selected(group) {
|
|
41
|
+
};
|
|
42
|
+
GroupsValue.prototype.selected = function (group) {
|
|
40
43
|
if (!this.value)
|
|
41
44
|
return false;
|
|
42
45
|
return this.value.indexOf(group) >= 0;
|
|
46
|
+
};
|
|
47
|
+
var GroupsValue_1;
|
|
48
|
+
GroupsValue = GroupsValue_1 = tslib_1.__decorate([
|
|
49
|
+
remult3_1.FieldType({
|
|
50
|
+
valueConverter: {
|
|
51
|
+
toJson: function (x) { return x ? x.value : ''; },
|
|
52
|
+
fromJson: function (x) { return new GroupsValue_1(x); },
|
|
53
|
+
displayValue: function (x) { return x.value; }
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
tslib_1.__metadata("design:paramtypes", [String])
|
|
57
|
+
], GroupsValue);
|
|
58
|
+
return GroupsValue;
|
|
59
|
+
}());
|
|
60
|
+
exports.GroupsValue = GroupsValue;
|
|
61
|
+
var testGroups = /** @class */ (function (_super) {
|
|
62
|
+
tslib_1.__extends(testGroups, _super);
|
|
63
|
+
function testGroups() {
|
|
64
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
65
|
+
_this.id = 0;
|
|
66
|
+
return _this;
|
|
43
67
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
],
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
remult3_1.Fields.integer(),
|
|
70
|
+
tslib_1.__metadata("design:type", Number)
|
|
71
|
+
], testGroups.prototype, "id", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
remult3_1.Field(function () { return GroupsValue; }),
|
|
74
|
+
tslib_1.__metadata("design:type", GroupsValue)
|
|
75
|
+
], testGroups.prototype, "g", void 0);
|
|
76
|
+
testGroups = tslib_1.__decorate([
|
|
77
|
+
remult3_1.Entity("testGroups", { allowApiCrud: true })
|
|
78
|
+
], testGroups);
|
|
79
|
+
return testGroups;
|
|
80
|
+
}(remult3_1.EntityBase));
|
|
81
|
+
db_tests_setup_1.testAll("test save and load", function (_a) {
|
|
82
|
+
var createEntity = _a.createEntity;
|
|
83
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
84
|
+
var re, x;
|
|
85
|
+
return tslib_1.__generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0: return [4 /*yield*/, createEntity(testGroups)];
|
|
88
|
+
case 1:
|
|
89
|
+
re = _b.sent();
|
|
90
|
+
return [4 /*yield*/, re.create({ id: 1 }).save()];
|
|
91
|
+
case 2:
|
|
92
|
+
_b.sent();
|
|
93
|
+
return [4 /*yield*/, re.findFirst()];
|
|
94
|
+
case 3:
|
|
95
|
+
x = _b.sent();
|
|
96
|
+
expect(x.g.evilGet()).toBe('');
|
|
97
|
+
x.g = x.g.addGroup("xx");
|
|
98
|
+
expect(x.$.g.valueChanged()).toBe(true);
|
|
99
|
+
return [4 /*yield*/, x.save()];
|
|
100
|
+
case 4:
|
|
101
|
+
_b.sent();
|
|
102
|
+
expect(x.g.evilGet()).toBe('xx');
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
82
107
|
});
|
|
83
|
-
testAll("test2 save and load",
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
108
|
+
db_tests_setup_1.testAll("test2 save and load", function (_a) {
|
|
109
|
+
var createEntity = _a.createEntity;
|
|
110
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
111
|
+
var re, x;
|
|
112
|
+
return tslib_1.__generator(this, function (_b) {
|
|
113
|
+
switch (_b.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, createEntity(testGroups)];
|
|
115
|
+
case 1:
|
|
116
|
+
re = _b.sent();
|
|
117
|
+
return [4 /*yield*/, re.create({ id: 1, g: new GroupsValue(undefined) }).save()];
|
|
118
|
+
case 2:
|
|
119
|
+
_b.sent();
|
|
120
|
+
return [4 /*yield*/, re.findFirst()];
|
|
121
|
+
case 3:
|
|
122
|
+
x = _b.sent();
|
|
123
|
+
expect(x.g.evilGet()).toBe('');
|
|
124
|
+
return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
88
128
|
});
|
|
@@ -1,30 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var remult3_1 = require("../remult3");
|
|
5
|
+
var db_tests_setup_1 = require("./db-tests-setup");
|
|
6
|
+
var testNull = /** @class */ (function (_super) {
|
|
7
|
+
tslib_1.__extends(testNull, _super);
|
|
8
|
+
function testNull() {
|
|
9
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
10
|
+
_this.id = 0;
|
|
11
|
+
return _this;
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
testNull
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
tslib_1.__decorate([
|
|
14
|
+
remult3_1.Fields.integer(),
|
|
15
|
+
tslib_1.__metadata("design:type", Number)
|
|
16
|
+
], testNull.prototype, "id", void 0);
|
|
17
|
+
tslib_1.__decorate([
|
|
18
|
+
remult3_1.Field(undefined, { allowNull: true }),
|
|
19
|
+
tslib_1.__metadata("design:type", Object)
|
|
20
|
+
], testNull.prototype, "myCol", void 0);
|
|
21
|
+
testNull = tslib_1.__decorate([
|
|
22
|
+
remult3_1.Entity('testNull', { allowApiCrud: true })
|
|
23
|
+
], testNull);
|
|
24
|
+
return testNull;
|
|
25
|
+
}(remult3_1.EntityBase));
|
|
26
|
+
db_tests_setup_1.testAll("test that update null works", function (_a) {
|
|
27
|
+
var createEntity = _a.createEntity;
|
|
28
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
29
|
+
var r, i;
|
|
30
|
+
var _b;
|
|
31
|
+
return tslib_1.__generator(this, function (_c) {
|
|
32
|
+
switch (_c.label) {
|
|
33
|
+
case 0: return [4 /*yield*/, createEntity(testNull)];
|
|
34
|
+
case 1:
|
|
35
|
+
r = _c.sent();
|
|
36
|
+
i = r.create({ id: 1, myCol: { value: 'abc' } });
|
|
37
|
+
return [4 /*yield*/, i.save()];
|
|
38
|
+
case 2:
|
|
39
|
+
_c.sent();
|
|
40
|
+
expect((_b = i.myCol) === null || _b === void 0 ? void 0 : _b.value).toBe("abc");
|
|
41
|
+
i.myCol = null;
|
|
42
|
+
expect(i.myCol).toBe(null);
|
|
43
|
+
return [4 /*yield*/, i.save()];
|
|
44
|
+
case 3:
|
|
45
|
+
_c.sent();
|
|
46
|
+
expect(i.myCol).toBe(null);
|
|
47
|
+
return [2 /*return*/];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
30
51
|
}, false);
|