Re: Rest interface: how to match empty fields

"John P. Rouillard" <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
Hi Ralf:

In message <[email protected]>,
Ralf Schlatterbeck writes:
>On Sun, Oct 06, 2019 at 12:19:57PM -0400, John P. Rouillard wrote:
>> Does anybody have any ideas on how to ask a rest interface if a value
>> is missing? I am working with multilinks specifically, but empty links
>> or text fields are also a concern.
>
>You can put "-1" for the ID.

Sorry I should have said I tried that and it didn't work (but I agree
it should). This is the result with the version I installed from the
tip yesterday.

    curl -u demo:demo https://zzzz/demo/rest/data/issue?keyword=-1
    {
      "error": {
        "status": 400,
        "msg": "'No key (name) value \"-1\" for \"keyword\"'"
      }
    }

is a multilink case. I expected it to work for the link case as well
given the web interface, but:

   curl -u demo:demo https://zzzz/demo/rest/data/issue?assignedto=-1
   {
      "error": {
        "status": 400,
        "msg": "'No key (username) value \"-1\" for \"user\"'"
      }
   }

It does work in the html interface. Is -1 is special cased in the html
interface? Are we filtering too much in the rest interface and just
need to pass the parameter value down to the lower level rather than
validating at the rest level.

>> Use cases:
>> 
>>    issues that do not have a keyword value set (e.g. no keywords, or null)
>-1 for the keyword multilink should do the trick.
>
>>    issues that do not have the FirstTimeFailure (item #7) keyword set
>> 
>> This is also kind of an issue in the web interface IIRC. E.G. for
>> links I can't say must not be item 4, I have to say must be
>> -1,1,2,3,5,6,7,8,9. This obviously doesn't work for multilinks as I
>> can have both link3 and link 4.
>
>There is a hack that implements an expression parser using special
>negative values (like -1 for no value, -2,... is used for specifying
>boolean expressions like 'not', 'and', 'or'). See code in and around
>_filter_multilink_expression in backends/rdbms_common.py.

I think that's the back end to the "expr" link in the web interface.
I hope there is a similar backend in the anydbm path.

>There is unfortunately no regression test for this and the
>implementation uses subselects (instead of an outer join) but, well, it
>sort of works :-) I've encountered at least one case (which I can't
>currently reproduce) where it fails when two such searches are
>performed in the same query.

We should get some testing of that code into the test suite.

>And, no, I don't know how to really use this, so a test to document how
>to do that would be really nice (I didn't implement this feature :-)

I vaguely remember when it was added. I'll see if I can find some
docs on it. IIRC there was a ticket on it.

>Note that this is only implemented for Multilinks although I see no
>reason why it couldn't work on Link, too.

Fair enough.

--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.