More tests for range coercion
This commit is contained in:
		@@ -36,12 +36,18 @@ class RangeComparator(types.TypeEngine.Comparator):
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def coerce_arg(cls, func):
 | 
			
		||||
        def operation(self, other, **kwargs):
 | 
			
		||||
            if other is None:
 | 
			
		||||
                return getattr(types.TypeEngine.Comparator, func)(
 | 
			
		||||
                    self, other, **kwargs
 | 
			
		||||
                )
 | 
			
		||||
            coerced_types = (
 | 
			
		||||
                self.type.interval_class.type,
 | 
			
		||||
                tuple,
 | 
			
		||||
                list,
 | 
			
		||||
                str,
 | 
			
		||||
                unicode
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            if isinstance(other, coerced_types):
 | 
			
		||||
                other = self.type.interval_class(other)
 | 
			
		||||
            return getattr(types.TypeEngine.Comparator, func)(
 | 
			
		||||
                self, self.type.interval_class(other), **kwargs
 | 
			
		||||
                self, other, **kwargs
 | 
			
		||||
            )
 | 
			
		||||
        return operation
 | 
			
		||||
 | 
			
		||||
@@ -144,6 +150,10 @@ class IntRangeType(RangeType):
 | 
			
		||||
        )
 | 
			
		||||
        print total
 | 
			
		||||
        # '30-140'
 | 
			
		||||
 | 
			
		||||
    Good reading:
 | 
			
		||||
 | 
			
		||||
    http://wiki.postgresql.org/images/f/f0/Range-types.pdf
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    impl = INT4RANGE
 | 
			
		||||
 
 | 
			
		||||
@@ -98,6 +98,18 @@ class TestIntRangeTypeOnPostgres(NumberRangeTestCase):
 | 
			
		||||
        )
 | 
			
		||||
        assert query.count()
 | 
			
		||||
 | 
			
		||||
    def test_eq_with_query_arg(self):
 | 
			
		||||
        self.create_building([1, 3])
 | 
			
		||||
        query = (
 | 
			
		||||
            self.session.query(self.Building)
 | 
			
		||||
            .filter(
 | 
			
		||||
                self.Building.persons_at_night ==
 | 
			
		||||
                self.session.query(
 | 
			
		||||
                    self.Building.persons_at_night)
 | 
			
		||||
                ).order_by(self.Building.persons_at_night).limit(1)
 | 
			
		||||
        )
 | 
			
		||||
        assert query.count()
 | 
			
		||||
 | 
			
		||||
    @mark.parametrize(
 | 
			
		||||
        'number_range',
 | 
			
		||||
        (
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user