MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / Range

Class Range

lib/sqlalchemy/dialects/postgresql/ranges.py:53–681  ·  view source on GitHub ↗

Represent a PostgreSQL range. E.g.:: r = Range(10, 50, bounds="()") The calling style is similar to that of psycopg and psycopg2, in part to allow easier migration from previous SQLAlchemy versions that used these objects directly. :param lower: Lower bound value, or

Source from the content-addressed store, hash-verified

51
52@dataclasses.dataclass(frozen=True, slots=True)
53class Range(Generic[_T]):
54 """Represent a PostgreSQL range.
55
56 E.g.::
57
58 r = Range(10, 50, bounds="()")
59
60 The calling style is similar to that of psycopg and psycopg2, in part
61 to allow easier migration from previous SQLAlchemy versions that used
62 these objects directly.
63
64 :param lower: Lower bound value, or None
65 :param upper: Upper bound value, or None
66 :param bounds: keyword-only, optional string value that is one of
67 ``"()"``, ``"[)"``, ``"(]"``, ``"[]"``. Defaults to ``"[)"``.
68 :param empty: keyword-only, optional bool indicating this is an "empty"
69 range
70
71 .. versionadded:: 2.0
72
73 """
74
75 lower: Optional[_T] = None
76 """the lower bound"""
77
78 upper: Optional[_T] = None
79 """the upper bound"""
80
81 bounds: _BoundsType = dataclasses.field(default="[)", kw_only=True)
82 empty: bool = dataclasses.field(default=False, kw_only=True)
83
84 def __bool__(self) -> bool:
85 return not self.empty
86
87 @property
88 def isempty(self) -> bool:
89 "A synonym for the 'empty' attribute."
90
91 return self.empty
92
93 @property
94 def is_empty(self) -> bool:
95 "A synonym for the 'empty' attribute."
96
97 return self.empty
98
99 @property
100 def lower_inc(self) -> bool:
101 """Return True if the lower bound is inclusive."""
102
103 return self.bounds[0] == "["
104
105 @property
106 def lower_inf(self) -> bool:
107 """Return True if this range is non-empty and lower bound is
108 infinite."""
109
110 return not self.empty and self.lower is None

Callers 15

test_range_frozenMethod · 0.90
test_basic_py_sanityMethod · 0.90
test_boolMethod · 0.90
_data_objMethod · 0.90
_data_objMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_range_frozenMethod · 0.72
test_basic_py_sanityMethod · 0.72
test_boolMethod · 0.72
_data_objMethod · 0.72
_data_objMethod · 0.72
_data_objMethod · 0.72