nsAbQueryStringToExpression::CreateBooleanConditionString does not support Exists and DoesNotExist provided by nsIAbBooleanExpression
Categories
(Thunderbird :: Address Book, enhancement)
Tracking
(Not tracked)
People
(Reporter: TbSync, Assigned: TbSync)
Details
Attachments
(1 file, 1 obsolete file)
1.12 KB,
patch
|
jorgk-bmo
:
review+
|
Details | Diff | Splinter Review |
Comment 1•7 years ago
|
||
Assignee | ||
Comment 2•7 years ago
|
||
Comment 3•7 years ago
|
||
Assignee | ||
Comment 4•6 years ago
|
||
Assignee | ||
Comment 5•6 years ago
|
||
It turns out to be a very small patch. The actual logic is already implemented here:
https://searchfox.org/comm-central/source/mailnews/addrbook/src/nsAbDirectoryQuery.cpp#464
but until now it was not possible to actually use DoesNotExist.
The attached patch is adding the "!ex" command.
How to proceed? Can I just add "review? Jorg" to this bug?
Comment 6•6 years ago
|
||
Assignee | ||
Comment 7•6 years ago
|
||
Is there a tutorial on how to create tests? This is my second patch I have send in and my first actual bugfix, this is all new to me.
I tested this patch by using the new !ex command from an AddOn.
Comment 8•6 years ago
|
||
Usually you can just extend an existing test. I had a look, but only found test_searchAddressInAb.js which is doing something else. The code you're touching here is parsing some stuff from some AB URI. I guess we'll just accept it "as is". Let's see what the reviewers say.
Comment 9•6 years ago
•
|
||
Updated•6 years ago
|
Assignee | ||
Comment 10•6 years ago
|
||
Updated the patch to also include nsIAbBooleanConditionTypes::Exists.
If it is extra work, I do not need this backported to TB60. Having it in TB68 will be enough for me. Thanks for accepting this.
Comment 11•6 years ago
|
||
Comment 12•6 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/a4a9ee36c20d
Support Exists and DoesNotExist nsAbQueryStringToExpression::CreateBooleanConditionString(). r=darktrojan
Comment 13•6 years ago
|
||
Can you please provide a complete HG header (with author's e-mail address) and a decent commit message next time.
Anyway, first patch, right? So thank you for your contribution.
This can easily be backported, just let me know.
Comment 14•6 years ago
|
||
I was hoping for the nsAbDirectoryQuery.cpp
part too. Never mind.
Comment 15•6 years ago
|
||
Oh, scratch that, it's done further down.
![]() |
||
Comment 16•6 years ago
|
||
I would welcome a test here as it seems we have none for the various query keywords.
I can look into that.
As noticed in comment 0, checking empty fields with '=' or actually any other operator does not work.
It is due to the code at https://searchfox.org/comm-central/source/mailnews/addrbook/src/nsAbDirectoryQuery.cpp#462, where an empty value in AbCard (not query) returns a match only with the operator DoesNotExist (which wasn't accessible until now). Otherwise the result is false (no match) and no further operators are tested.
It could be argued (field,=,string) [Is] or (field,!=,string) [Isnt] could return a useful result too. E.g. if a card doesn't have 'field' defined, why would it NOT match (field,!=,string) ? Right now you have to always use (or(field,!=,string),(field,!ex,)) ???
Also, if we just created the 'ex' and '!ex' query keywords right now, I wonder where all the keywords are documented and we should add the new ones to the list.
Comment 17•6 years ago
|
||
The documentation points to this part of the source code.
Assignee | ||
Comment 18•6 years ago
|
||
As noticed in comment 0, checking empty fields with '=' or actually any other operator does not work.
It is due to the code at https://searchfox.org/comm-central/source/mailnews/addrbook/src/nsAbDirectoryQuery.cpp#462, where an empty value in AbCard (not query) returns a match only with the operator DoesNotExist (which wasn't accessible until now). Otherwise the result is false (no match) and no further operators are tested.
That is correct.
It could be argued (field,=,string) [Is] or (field,!=,string) [Isnt] could return a useful result too. E.g. if a card doesn't have 'field' defined, why would it NOT match (field,!=,string) ? Right now you have to always use (or(field,!=,string),(field,!ex,)) ???
Hm, that looks also correct. I will test that. But under the assumption, that "!=" only checks existing strings, having to test for (or(field,!=,string),(field,!ex,)) is straight forward.
It must be documented of course. When I started to work with this search syntax, I had to look it up in the source. Can I contribute to the doc?
Anyhow, I did not want to modify the standard behaviour of "=" and "!=" because it might break stuff. Since there where special implementations for Exists and DoesNotExists, I just wanted to makle those accessible.
Assignee | ||
Comment 19•6 years ago
|
||
Right now you have to always use (or(field,!=,string),(field,!ex,))
Since the code returns early at line #462 if the field is empty, this is true. I also run a few tests to verify that. For me, this is not an issue, if it gets documented. Ping me, if I can contribute to the docs.
Description
•