Skip to content

Enabling INT64 and SUID for MMEX4Desktop #6966

@whalley

Description

@whalley

From: Lisheng Guan
Hi there

I'm writing this email to discuss enabling SUID for MMEX4Desktop to improve conflict resolution in the future.

The proposal is to use SUID to fill the table's primary key instead. The SUID is composed of milliseconds and 3 random digits.
Once done, ID conflicts will be difficult. Then, merge and importers (both full and partial) would be possible. We can leverage data sync from the file level to the table/row level, and even column level.

Here are two examples for Payee from mobile

 {
   "name" : "Payee A", 
   "website" : "www.payeeA.com",
   "id" : { 
     "value" : 1731396158462442
   },  
   "pattern" : "", 
   "categoryId" : { 
     "value" : 1731396158461053
   },  
   "number" : "123456",
   "notes" : "Frequent payee",
   "active" : false
 }
 
 {
   "categoryId" : { 
     "value" : -1
   },  
   "active" : true,
   "website" : "", 
   "number" : "", 
   "notes" : "", 
   "id" : { 
     "value" : 1731396213842905
   },  
   "pattern" : "", 
   "name" : "payee from android"
 }

the change should be under control, here is some pseudo-code for table Tag_V1

--- a/src/db/DB_Table_Tag_V1.h
+++ b/src/db/DB_Table_Tag_V1.h
@@ -362,7 +362,7 @@ struct DB_Table_TAG_V1 : public DB_Table
         wxString sql = wxEmptyString;
         if (entity-id() <= 0) //  new & insert
         {
-            sql = "INSERT INTO TAG_V1(TAGNAME, ACTIVE) VALUES(?, ?)";
+            sql = "INSERT INTO TAG_V1(TAGNAME, ACTIVE, TAGID) VALUES(?, ?, ?)";
         }
         else
         {
@@ -377,6 +377,8 @@ struct DB_Table_TAG_V1 : public DB_Table
             stmt.Bind(2, entity-ACTIVE);
             if (entity-id()  0)
                 stmt.Bind(3, entity-TAGID);
+            else
+                stmt.Bind(3, SUID());

             stmt.ExecuteUpdate();
             stmt.Finalize();

Thoughts and feedback?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions