A feature request

I want to search for attachments in Joplin Tools-Note attachments, and I want to add a search function. I can easily delete files that are not useful.

What do you mean by "I want to add a search function".

I'm sure Laurent would welcome a PR.

For searching attachments, can you add this feature?

You have to be a bit more specific than that.

How exactly do you want to da a seach? Title, Size, ID? Please note that many attachments can have non-descriptive names. There's no reference to notes in the attachment window.

I could imagine a search input field that allows to do a live search. But I currently don't have the to do this myself. First we need Laurent's ok and then we have to find someone, who will be implementing it...

1 Like

Related to this issue I noticed that the sorting order in Tools->Note Attachments... is a bit... off when sorting via filename.

I had a look in the resources table and didn't realise that case sensitive sorting is a thing in SQLite (only really used Oracle and MSSQL but entirely possible I've never come across data that has a mixed case starting character) and to me this doesn't make a huge amount of sense when searching in a list such as this.

In terms of SQL this:

SELECT *
FROM resources
ORDER BY title ASC;

Will return A.xyz, B.xyz, C.xyz, a.xyz, b.xyz, c.xyz.

Whereas:

SELECT *
FROM resources
ORDER BY title COLLATE NOCASE ASC;

Will return A.xyz, a.xyz, B.xyz, b.xyz, C.xyz, c.xyz

The latter of the two is what I would normally expect when sorting a column in something like that tool.

Unfortunately I'm not a programmer beyond some VBA macros and some SQL wrangling (although I'm doing a small amount of learning in my own time) but I've had a dig around the code and whilst I've not been able to find exactly how the application is accessing the database (I'm guessing something other that straight up embedding the queries...) I did find the following in joplin/packages/app-desktop/gui/ResourceScreen.tsx - async reloadResources:

order: [{
	by: getSortingOrderColumn(sorting.order),
	dir: sorting.type,

In a completely different file I found something similar but with an extra argument (assuming 'caseInsensitive: true' equates to 'COLLATE NOCASE'):

return [{
	by: orderBy,
	dir: orderDir,
	caseInsensitive: true,

Is anyone able to tell me if

  1. I'm barking up the wrong tree entirely,
  2. if this is a bug and if so does it need to be created or is this as intended and
  3. would adding in the 'CaseInsensitive: true' argument to that function actually do what I hope - or if not could you point me in the right direction - i.e. where the the query is actually being constructed

I'd love to collaborate and help one day in the future but this is about the limit of my ability at the moment.

Sorting is always case-sensitive in SQL unless specified otherwise.

But you brought up a good point. IMO a change like this would be good.
Not sure, if Laurent is ok with this, but I don't see why not.

You can open a PR. Just add the caseInsensitive: true, and you are good to go.

I can also create a PR, but the code change, if accepted, should be attributed to you. Thus it's better you open it.

P.S.: I have to rephrase my first sentence. I think it was too imprecise. The sorting depends on the collating sequence, which is almost always case-sensitive.

Thanks, I'll do that, not opened a PR before so let me know if I balls it up.

Interesting about the collating sequence, I'll have to have a look to see how we have it set up in Oracle, not an issue I've ever encountered before.

The PR looks good. Since you don't have to rebase or do some other stuff, it's ok, but in the future I would ceate a new branch. It is never a good idea to commit directly to the dev/master/main branch.
But for now all is good. Let's see what Laurent says and then we can merge.

Interesting about the collating sequence,

It depends on the RDBMS. Most of the time you specify the code page and collating sequence during database creation. Sometimes there's is a way to specify certain attributes on a table level.

As a hint for someone who would like to implement this. Something similar was done in the Keyboard Shortcuts Editor preference pane.

I see what you mean, this is new to me, in my normal life I just send a word document with the problem to our product PMO who does all the hard work, I don't have to get my hands dirty.
From looking at other PRs I would need to make a new branch on my forked repo and commit to Joplin:dev from there?
Apologies, I'm not really up to speed with dev workflows, I'm not IT by trade and qualification, just a humble scientist.

No, you don't have permission to push to the Joplin repo. This is how it works:

  • make sure you are at the latest commit on the dev branch: git pull
  • create a new branch locally git checkout -b feature/whatever (this will already switch to that branch)
  • do the changes
  • commit git add <filename> and git commit
  • push to your fork git push -u origin feature/whatever
  • create the PR by going to https://github.com/laurent22/joplin/pulls (it should show you that you pushed a new branch and a button to compare branches and create a PR...)

There are also a lot of git UIs available (Source Tree, GitHub Desktop, plugins for VS Code, ...). Maybe someone can recommend one. I use git exclusively on the command line.

But don't worry about this for now. Your PR is fine. It's just something to keep in mind. Creating your own branches will help you avoid a lot of headaches.

No worries. These workflows also depend on the project, so they might differ in certain areas. Usually they should be in the CONTRIBUTING.md, although not necessarily in that detail. In above case they would say: create a new branch for every PR you submit.

I think my terminology was off, didn't mean commit as in merge, just as in creating the PR.
I still need to set up some kind of dev environment somewhere, still very much learning as it is.
Thank you for the info and insight, I'll be aware of that going fowards, lots of the terminology and 'best practice' as a whole is still foreign to me but I'll get there.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.