Re: Range search syntax for integers and numbers??

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

Apprently this never got sent, it was still in my drafts folder.

In message <[email protected]>,
Ralf Schlatterbeck writes:
>On Tue, Oct 13, 2020 at 08:52:57PM -0400, John P. Rouillard wrote:
>> We have range search for dates and intervals. But is there a way to
>> search for a number or integer range? Specifically I want issues with
>> a number value > 0 (i.e. not unassigned).
>> 
>> I thought there was a mechanism for that, but I can't find it in the
>> doc and a search of the code isn't turning up anything either.
>> 
>> Can anybody give me a clue stick?
>
>No I do not think we have that for numbers. Shouldn't be too hard to
>implement the same class (I think it's called Range) as done for Date
>ranges for Number.

Is that an offer to add the code?

Thanks for the pointer. I found the date range code.

So it looks like hyperdb.py::Number and Integer classes need
range_from_raw function defined.

What I am having issues with is where to hook this into
backends/rdbms_common.py and backends/back_anydbm.py.

In back_anydbm.py there is at least a:

                 elif isinstance(propclass, hyperdb.Integer):
                    if type(v) != type([]):
                        try :
                            v = v.split(',')
                        except AttributeError :
                            v = [v]
                    l.append((OTHER, k, [int(val) for val in v]))

What's odd here is that it looks like it should accept:

   1,2,3,4,5,6,7,8,9,10

(i.e. comma separated list of Integers) but I am not able to enter
that into a search box without getting an error claiming that it's not
an integer. So there may be something else that needs fixing first.

In any case, does changing it to:


                 elif isinstance(propclass, hyperdb.Integer):
                    if type(v) != type([]):  # still a string
                        try :
			    ranges = []
                            v = v.split(',')
			    for i in v:
			       if i == '-':
			          ranges.append(None)
		              	  continue
			       try:		
			         from, to = i.split(';')
			       except ValueError:
			         ranges   
                               int_range = propclass.range_from_raw(i, self.db)
			       
                        except AttributeError :
                            v = [v]
                    l.append((OTHER, k, [int(val) for val in v]))

look like a start?

--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
In message <[email protected]>,
Ralf Schlatterbeck writes:
>On Tue, Oct 13, 2020 at 08:52:57PM -0400, John P. Rouillard wrote:
>> Hi all:
>> 
>> We have range search for dates and intervals. But is there a way to
>> search for a number or integer range? Specifically I want issues with
>> a number value > 0 (i.e. not unassigned).
>> 
>> I thought there was a mechanism for that, but I can't find it in the
>> doc and a search of the code isn't turning up anything either.
>> 
>> Can anybody give me a clue stick?
>
>No I do not think we have that for numbers. Shouldn't be too hard to
>implement the same class (I think it's called Range) as done for Date
>ranges for Number.

Is that an offer to add the code?

Thanks for the pointer. I found the date range code.

So it looks like hyperdb.py::Number and Integer classes need
range_from_raw function defined.

What I am having issues with is where to hook this into
backends/rdbms_common.py and backends/back_anydbm.py.

In back_anydbm.py there is at least a:

                 elif isinstance(propclass, hyperdb.Integer):
                    if type(v) != type([]):
                        try :
                            v = v.split(',')
                        except AttributeError :
                            v = [v]
                    l.append((OTHER, k, [int(val) for val in v]))

What's odd here is that it looks like it should accept:

   1,2,3,4,5,6,7,8,9,10

(i.e. comma separated list of Integers) but I am not able to enter
that into a search box without getting an error claiming that it's not
an integer. So there may be something else that needs fixing first.

In any case, does changing it to:


                 elif isinstance(propclass, hyperdb.Integer):
                    if type(v) != type([]):  # still a string
                        try :
			    ranges = []
                            v = v.split(',')
			    for i in v:
			       if i == '-':
			          ranges.append(None)
		              	  continue
			       try:		
			         from, to = i.split(';')
			       except ValueError:
			         ranges   
                               int_range = propclass.range_from_raw(i, self.db)
			       
                        except AttributeError :
                            v = [v]
                    l.append((OTHER, k, [int(val) for val in v]))

look like a start?

--
				-- 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.