From ae7fb2e9ee152706e3c61eb7b7e21f0cd430b77b Mon Sep 17 00:00:00 2001 From: Victor Porton Date: Fri, 1 Mar 2024 03:44:00 +0200 Subject: [PATCH 1/4] added additional package versions --- mops.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mops.toml b/mops.toml index 550b89f..bbd9166 100644 --- a/mops.toml +++ b/mops.toml @@ -12,8 +12,10 @@ array = "https://github.com/aviate-labs/array.mo#v0.2.0" encoding = "https://github.com/aviate-labs/encoding.mo#v0.3.2" stable-rbtree = "https://github.com/canscale/StableRBTree#v0.6.1" stablebuffer = "https://github.com/skilesare/StableBuffer#v0.2.0" +stablebuffer_1_3_0 = "https://github.com/skilesare/StableBuffer#v2.0" map = "https://github.com/ZhenyaUsenko/motoko-hash-map#v7.0.0" -candy = "https://github.com/icdevs/candy_library#0.3.0" +map9 = "https://github.com/ZhenyaUsenko/motoko-hash-map#v9.0.0" +candy = "https://github.com/icdevs/candy_library#v0.3.0" [dev-dependencies] test = "1.0.1" \ No newline at end of file From d9508c9959d82f3595590f2ad3b15517731c4a5d Mon Sep 17 00:00:00 2001 From: Victor Porton Date: Fri, 1 Mar 2024 04:00:44 +0200 Subject: [PATCH 2/4] bug fix --- src/CanDB.mo | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CanDB.mo b/src/CanDB.mo index 4e3f4c6..0a702ef 100644 --- a/src/CanDB.mo +++ b/src/CanDB.mo @@ -274,10 +274,14 @@ module { /// See the create() and update() functions in examples/simpleDB/src/main.mo, and the tests in /// updateSuite() in test/HashTreeTest for some examples of how to use CanDB.update() public func update(db: DB, options: UpdateOptions): ?E.Entity { - let ovAttributeMap = RT.update(db.data, options.sk, options.updateAttributeMapFunction); - switch(ovAttributeMap) { + let ovAttributeMap = RT.get(db.data, options.sk); // inefficient + let nvAttributeMap = RT.update(db.data, options.sk, options.updateAttributeMapFunction); // Why does it (always?) return `?result`, where `result` is the function result? + switch(nvAttributeMap) { case null { null }; case (?map) { + if (ovAttributeMap == null) { // TODO: Correct? + db.count += 1; + }; ?{ pk = db.pk; sk = options.sk; From 561b73284e3783347858cd6b99df3c277d416850 Mon Sep 17 00:00:00 2001 From: Victor Porton Date: Fri, 1 Mar 2024 18:49:40 +0200 Subject: [PATCH 3/4] bug fix --- src/CanDB.mo | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CanDB.mo b/src/CanDB.mo index 0a702ef..b67828d 100644 --- a/src/CanDB.mo +++ b/src/CanDB.mo @@ -274,8 +274,11 @@ module { /// See the create() and update() functions in examples/simpleDB/src/main.mo, and the tests in /// updateSuite() in test/HashTreeTest for some examples of how to use CanDB.update() public func update(db: DB, options: UpdateOptions): ?E.Entity { - let ovAttributeMap = RT.get(db.data, options.sk); // inefficient - let nvAttributeMap = RT.update(db.data, options.sk, options.updateAttributeMapFunction); // Why does it (always?) return `?result`, where `result` is the function result? + // inefficient solution + let ovAttributeMap = RT.get(db.data, options.sk); + ignore RT.update(db.data, options.sk, options.updateAttributeMapFunction); // Accordingly docs it always returns `?result`, where `result` is the function result. But in practical tests it may return `null`. + let nvAttributeMap = RT.get(db.data, options.sk); + Debug.print("nvAttributeMap: " # debug_show(nvAttributeMap)); switch(nvAttributeMap) { case null { null }; case (?map) { From abf02c1f8ac4de8f10fcfa87e1c40280522bde5d Mon Sep 17 00:00:00 2001 From: Victor Porton Date: Fri, 1 Mar 2024 18:52:32 +0200 Subject: [PATCH 4/4] removed tracing --- src/CanDB.mo | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CanDB.mo b/src/CanDB.mo index b67828d..340d21d 100644 --- a/src/CanDB.mo +++ b/src/CanDB.mo @@ -278,7 +278,6 @@ module { let ovAttributeMap = RT.get(db.data, options.sk); ignore RT.update(db.data, options.sk, options.updateAttributeMapFunction); // Accordingly docs it always returns `?result`, where `result` is the function result. But in practical tests it may return `null`. let nvAttributeMap = RT.get(db.data, options.sk); - Debug.print("nvAttributeMap: " # debug_show(nvAttributeMap)); switch(nvAttributeMap) { case null { null }; case (?map) {