Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ekg-note-delete-by-id: remove title as well #112

Closed
qingshuizheng opened this issue Oct 22, 2023 · 2 comments
Closed

ekg-note-delete-by-id: remove title as well #112

qingshuizheng opened this issue Oct 22, 2023 · 2 comments

Comments

@qingshuizheng
Copy link
Contributor

qingshuizheng commented Oct 22, 2023

Hello @ahyatt ,

ekg/ekg.el

Line 439 in d2f0e54

(cl-loop for type in '(tagged text time-tracked) do

While inspecting db, I found some TITLE-related records remained in db after note deletion:

-- Loading resources from /Users/z/.sqliterc
SQLite version 3.42.0 2023-05-16 12:36:15
Enter ".help" for usage hints.
sqlite> select * from triples where subject is 33359085393;
subject      predicate     object      properties
-----------  ------------  ----------  ----------
33359085393  base/type     titled      ()        
33359085393  titled/title  "westlife"  (:index 0)
sqlite> 

I think 'titled types should be taken care as well here:

(defun ekg-note-delete-by-id (id)
  "Delete all note data associated with ID."
  (ekg-connect)
  (run-hook-with-args 'ekg-note-pre-delete-hook id)
  (triples-with-transaction
    ekg-db
    ;; (cl-loop for type in '(tagged text time-tracked) do
    (cl-loop for type in '(tagged text time-tracked titled) do     ; <- TITLED should be included
             (triples-remove-type ekg-db id type))
    (cl-loop for inline-id in (triples-subjects-with-predicate-object
                               ekg-db 'inline/for-text id)
             do (triples-remove-type ekg-db inline-id 'inline))
    (run-hook-with-args 'ekg-note-delete-hook id)))

With this↑ change, the titled-related records will also be deleted.

Note: The remaining titled-related items of all previous note deletions need to be cleaned up. (I found 74 remaining records in my db.)

Zheng

ahyatt added a commit that referenced this issue Oct 23, 2023
In general, this is a hard problem to solve - this current solution is
temporary. What really needs to happen (I think) is that the triples package
needs to encode type dependency information, which it then can use automatically
to make sure various things are deleted when necessary.

This fixes #112.
@ahyatt
Copy link
Owner

ahyatt commented Oct 23, 2023

Thanks for reporting this. I've checked in a change (and a way to do the cleanup), but it isn't quite right in theory. What should happen is that we should encode dependency information into types in the triples package, and then have it just delete orphan types. That's something I'll look to add in a subsequent change in that package.

@ahyatt ahyatt closed this as completed Oct 23, 2023
@qingshuizheng
Copy link
Contributor Author

Thanks for the fix! 😃

ahyatt added a commit that referenced this issue Nov 11, 2023
In general, this is a hard problem to solve - this current solution is
temporary. What really needs to happen (I think) is that the triples package
needs to encode type dependency information, which it then can use automatically
to make sure various things are deleted when necessary.

This fixes #112.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants