--- /dev/null
+.. change::
+ :tags: bug, postgresql
+ :tickets: 8984
+
+ The :meth:`_postgresql.Range.__eq___` will now return ``NotImplemented``
+ when comparing with an instance of a different class, instead of raising
+ an :exc:`AttributeError` exception.
return AbstractRange()
def _contains_value(self, value: _T) -> bool:
- """return True if this range contains the given value."""
+ """Return True if this range contains the given value."""
if self.empty:
return False
bounds inclusivity, returning ``True`` if they are equal.
"""
+ if not isinstance(other, Range):
+ return NotImplemented
+
if self.empty and other.empty:
return True
elif self.empty != other.empty:
cls: Type[Union[TypeEngine[Any], TypeEngineMixin]],
**kw: Any,
) -> TypeEngine[Any]:
- """dynamically adapt a range type to an abstract impl.
+ """Dynamically adapt a range type to an abstract impl.
For example ``INT4RANGE().adapt(_Psycopg2NumericRange)`` should
produce a type that will have ``_Psycopg2NumericRange`` behaviors
class AbstractRangeImpl(AbstractRange[Range[_T]]):
- """marker for AbstractRange that will apply a subclass-specific
+ """Marker for AbstractRange that will apply a subclass-specific
adaptation"""
class AbstractMultiRangeImpl(
AbstractRangeImpl[Range[_T]], AbstractMultiRange[Range[_T]]
):
- """marker for AbstractRange that will apply a subclass-specific
+ """Marker for AbstractRange that will apply a subclass-specific
adaptation"""
is_false(range_.contains(values["rh"]))
+ is_true(range_ == range_)
+ is_false(range_ != range_)
+ is_false(range_ == None)
+
def test_compatibility_accessors(self):
range_ = self._data_obj()