mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 09:47:30 +03:00 
			
		
		
		
	Added implementation for Range gt and ge operators
Using a common implementation for all the operators. Note that lt is the one used by sort so it's nice it's the fastest.
This commit is contained in:
		
							parent
							
								
									6cd0647da9
								
							
						
					
					
						commit
						4545d1636c
					
				| 
						 | 
				
			
			@ -154,20 +154,22 @@ class Range(object):
 | 
			
		|||
        return False
 | 
			
		||||
 | 
			
		||||
    def __le__(self, other):
 | 
			
		||||
        if not isinstance(other, Range):
 | 
			
		||||
            return NotImplemented
 | 
			
		||||
        for attr in self.__slots__:
 | 
			
		||||
            self_value = getattr(self, attr)
 | 
			
		||||
            other_value = getattr(other, attr)
 | 
			
		||||
            if self_value == other_value:
 | 
			
		||||
                pass
 | 
			
		||||
            elif self_value is None:
 | 
			
		||||
        if self == other:
 | 
			
		||||
            return True
 | 
			
		||||
            elif other_value is None:
 | 
			
		||||
                return False
 | 
			
		||||
        else:
 | 
			
		||||
                return self_value <= other_value
 | 
			
		||||
            return self.__lt__(other)
 | 
			
		||||
 | 
			
		||||
    def __gt__(self, other):
 | 
			
		||||
        if isinstance(other, Range):
 | 
			
		||||
            return other.__lt__(self)
 | 
			
		||||
        else:
 | 
			
		||||
            return NotImplemented
 | 
			
		||||
 | 
			
		||||
    def __ge__(self, other):
 | 
			
		||||
        if self == other:
 | 
			
		||||
            return True
 | 
			
		||||
        else:
 | 
			
		||||
            return self.__gt__(other)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def register_range(pgrange, pyrange, conn_or_curs, globally=False):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user