@@ -7746,6 +7746,17 @@ function takeWhile(array, predicate) {
77467746}
77477747function removeSymbols(input) {
77487748 return JSON.parse(JSON.stringify(input));
7749+ }
7750+ /**
7751+ * Converts the argument into a number.
7752+ */
7753+ function toNumber(input) {
7754+ if (input === null)
7755+ return 0;
7756+ if (typeof input === "string" && input.startsWith("$uid")) {
7757+ return input;
7758+ }
7759+ return parseInt(input.toString(), 10);
77497760}
77507761
77517762/**
@@ -7901,8 +7912,8 @@ var Model = /** @class */ (function () {
79017912 if (!field)
79027913 return false;
79037914 var context = Context.getInstance();
7904- // Remove UID cause it must be a string
7905- return field instanceof context.components.Number ;
7915+ return field instanceof context.components.Number ||
7916+ field instanceof context.components.Uid ;
79067917 };
79077918 /**
79087919 * Tells if a field is a attribute (and thus not a relation)
@@ -8058,14 +8069,14 @@ var Model = /** @class */ (function () {
80588069 };
80598070 /**
80608071 * Returns a record of this model with the given ID.
8061- * @param {string} id
8072+ * @param {number| string} id
80628073 * @returns {any}
80638074 */
80648075 Model.prototype.getRecordWithId = function (id) {
80658076 return this.baseModel
80668077 .query()
80678078 .withAllRecursive()
8068- .where("id", id )
8079+ .where("id", toNumber(id) )
80698080 .first();
80708081 };
80718082 /**
@@ -15338,7 +15349,7 @@ var Action = /** @class */ (function () {
1533815349 if (!(name !== context.adapter.getNameForDestroy(model))) return [3 /*break*/, 4];
1533915350 newData = newData[Object.keys(newData)[0]];
1534015351 // IDs as String cause terrible issues, so we convert them to integers.
15341- newData.id = parseInt (newData.id, 10 );
15352+ newData.id = toNumber (newData.id);
1534215353 return [4 /*yield*/, Store.insertData((_a = {}, _a[model.pluralName] = newData, _a), dispatch)];
1534315354 case 3:
1534415355 insertedData = _b.sent();
@@ -15423,7 +15434,7 @@ var Destroy = /** @class */ (function (_super) {
1542315434 /**
1542415435 * @param {State} state The Vuex state
1542515436 * @param {DispatchFunction} dispatch Vuex Dispatch method for the model
15426- * @param {string } id ID of the record to delete
15437+ * @param {number } id ID of the record to delete
1542715438 * @returns {Promise<any>} true
1542815439 */
1542915440 Destroy.call = function (_a, _b) {
@@ -15575,7 +15586,7 @@ var Persist = /** @class */ (function (_super) {
1557515586 /**
1557615587 * @param {any} state The Vuex state
1557715588 * @param {DispatchFunction} dispatch Vuex Dispatch method for the model
15578- * @param {string} id ID of the record to persist
15589+ * @param {number| string} id ID of the record to persist
1557915590 * @returns {Promise<Data>} The saved record
1558015591 */
1558115592 Persist.call = function (_a, _b) {
@@ -15591,7 +15602,7 @@ var Persist = /** @class */ (function (_super) {
1559115602 mutationName = Context.getInstance().adapter.getNameForPersist(model);
1559215603 oldRecord = model.getRecordWithId(id);
1559315604 mockReturnValue = model.$mockHook("persist", {
15594- id: id ,
15605+ id: toNumber(id) ,
1559515606 args: args || {}
1559615607 });
1559715608 if (!mockReturnValue) return [3 /*break*/, 3];
@@ -15922,7 +15933,7 @@ var VuexORMGraphQL = /** @class */ (function () {
1592215933 return __generator(this, function (_b) {
1592315934 args = args || {};
1592415935 if (!args["id"])
15925- args["id"] = this.$id;
15936+ args["id"] = toNumber( this.$id) ;
1592615937 return [2 /*return*/, this.$dispatch("mutate", { name: name, args: args, multiple: multiple })];
1592715938 });
1592815939 });
@@ -15933,7 +15944,7 @@ var VuexORMGraphQL = /** @class */ (function () {
1593315944 return __generator(this, function (_b) {
1593415945 filter = filter || {};
1593515946 if (!filter["id"])
15936- filter["id"] = this.$id;
15947+ filter["id"] = toNumber( this.$id) ;
1593715948 return [2 /*return*/, this.$dispatch("query", { name: name, filter: filter, multiple: multiple, bypassCache: bypassCache })];
1593815949 });
1593915950 });
@@ -15955,7 +15966,7 @@ var VuexORMGraphQL = /** @class */ (function () {
1595515966 model.$destroy = function () {
1595615967 return __awaiter(this, void 0, void 0, function () {
1595715968 return __generator(this, function (_a) {
15958- return [2 /*return*/, this.$dispatch("destroy", { id: this.$id })];
15969+ return [2 /*return*/, this.$dispatch("destroy", { id: toNumber( this.$id) })];
1595915970 });
1596015971 });
1596115972 };
0 commit comments