xenodium / sqlite-mode-extras

Emacs sqlite-mode extras
GNU General Public License v3.0
40 stars 4 forks source link

Unable to update field value #5

Open slackline opened 1 week ago

slackline commented 1 week ago

Hi,

Thanks for writing and sharing this really neat way to work with SQLite3 databases.

Context : I've rename a Git repository but Magit Forge is still using the old name and I can't get Issues/Pull Requests updated so I thought I'd just update the names directly in the .config/emacs/forge-database.sql

The following is the relevant row from the repository table...

repository                           26 
  rowid  class   id                                                  forge_id                            forge         owner                         name                                         apihost              githost       remote      condition  created                     updated                     pushed  parent                                                             description                                                                                          homepage                                                             default_branch  archived_p  fork_p  locked_p  mirror_p  private_p  issues_p  wiki_p  stars  watchers  assignees      forks          issues         labels         revnotes       pullreqs       selective_p  worktree                                                                                    milestones     issues_until                pullreqs_until              
...
      27 github  "Z2l0aHViLmNvbTpSX2tnRE9OQklxcWc="                  "R_kgDONBIqqg"                      "github.com"  "sudlab"                      "SLAMSeq"                                    "api.github.com"     "github.com"  "origin"    :tracked   "2024-10-16T12:56:56Z"      "2024-10-17T09:02:53Z"                                                                                                                                                                                                                                                           "main"                                                  t          t                      0         4 eieio-unbound  eieio-unbound  eieio-unbound  eieio-unbound  eieio-unbound  eieio-unbound               "/home/neil/work/git/hub/sudlab/SLAMSeq/"                                                   eieio-unbound  "2024-10-17T09:02:44Z"      "2024-10-17T09:02:43Z"      

If I move the cursor to "SLAMSeq" and hit RET the mini-buffer pops up with...

1/1    name: "SLAMSeq"
"SLAMSeq"

I can edit this and it changes to...

*/0    name: "IsoSLAM"

Hit RET...

name: "SLAMSeq"

I edit this again to the desired rename...

name: "IsoSLAM"

Hit RET...

First row mus be 'id'

I see the same behaviour if with cursor on "SLAMSeq" I try using sqlite-mode-extras-edit-row-field.

You mentioned on Mastodon that this should read First column should be id and have fixed that but needed more context on the schema so I thought adding it here would be appropriate.

In this instance the third column is id so I wonder if that is the cause of the problem?

If I can provide any more information please do let me know.

xenodium commented 1 week ago

In this instance the third column is id so I wonder if that is the cause of the problem?

Quite likely. It's been a while since I've looked into the code.

What I would typically do is set an edebug breakpoint and step through the code to see what's happening. In this case, you can set a breakpoint in sqlite-mode-extras-edit-row-field.

The error you're seeing is a safety measure. You may be able to bypass by removing the check (⚠️ do backup your db ⚠️).

If I can provide any more information please do let me know.

Attaching a failing db makes things easier for me to reproduce.

slackline commented 1 week ago

Thanks, I'm working on a copy of the database so I don't cock things up (I've learnt the hard way in the past!).

I had a go at disabling the check as suggested and that allowed me to edit the two fields I needed to.

Now to carefully switch databases!

I'll see if I can make a reproducible example later and attach it.

Thanks so much for your prompt assistance @xenodium very much appreciated :+1:

xenodium commented 1 week ago

Thanks so much for your prompt assistance @xenodium very much appreciated 👍

Glad to hear that helped!

If you find my projects useful, consider making the projects and their maintenance/support sustainable by supporting them.