Enum
Enum used in py-linq-sql.
CommandType (StrEnum)
Enum of command type.
Source code in py_linq_sql/utils/classes/enum.py
class CommandType(StrEnum):
"""Enum of command type."""
SELECT = "select"
WHERE = "where"
MIN = "min"
MAX = "max"
INSERT = "insert"
ORDER_BY = "order by"
ORDER_BY_DESC = "order by desc"
TAKE = "take"
SKIP = "skip"
ELEMENT_AT = "element at"
FIRST = "first"
UPDATE = "update"
COUNT = "count"
SINGLE = "single"
LAST = "last"
TAKE_LAST = "take last"
SKIP_LAST = "skip last"
ALL = "all"
ANY = "any"
CONTAINS = "contains"
EXCEPT_ = "except"
JOIN = "join"
UNION = "union"
INTERSECT = "intersect"
DISTINCT = "distinct"
GROUP_BY = "group by"
DELETE = "delete"
GROUP_JOIN = "group join"
JoinType (_Type, Enum)
Enum of join type.
Source code in py_linq_sql/utils/classes/enum.py
class JoinType(_Type, Enum):
"""Enum of join type."""
INNER = _Type(is_intersect=False, as_str="INNER")
LEFT = _Type(False, "LEFT")
LEFT_MINUS_INTERSECT = _Type(True, "LEFT")
RIGHT = _Type(False, "RIGHT")
RIGHT_MINUS_INTERSECT = _Type(True, "RIGHT")
FULL = _Type(False, "FULL")
FULL_MINUS_INTERSECT = _Type(True, "FULL")
__new__(cls, value)
special
Create and return a new object. See help(type) for accurate signature.
Source code in py_linq_sql/utils/classes/enum.py
def __new__(cls, value):
# all enum instances are actually created during class construction
# without calling this method; this method is called by the metaclass'
# __call__ (i.e. Color(3) ), and by pickle
if type(value) is cls:
# For lookups like Color(Color.RED)
return value
# by-value search for a matching enum member
# see if it's in the reverse mapping (for hashable values)
try:
return cls._value2member_map_[value]
except KeyError:
# Not found, no need to do long O(n) search
pass
except TypeError:
# not there, now do long search -- O(n) behavior
for member in cls._member_map_.values():
if member._value_ == value:
return member
# still not found -- verify that members exist, in-case somebody got here mistakenly
# (such as via super when trying to override __new__)
if not cls._member_map_:
raise TypeError("%r has no members defined" % cls)
#
# still not found -- try _missing_ hook
try:
exc = None
result = cls._missing_(value)
except Exception as e:
exc = e
result = None
try:
if isinstance(result, cls):
return result
elif (
Flag is not None and issubclass(cls, Flag)
and cls._boundary_ is EJECT and isinstance(result, int)
):
return result
else:
ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))
if result is None and exc is None:
raise ve_exc
elif exc is None:
exc = TypeError(
'error in %s._missing_: returned %r instead of None or a valid member'
% (cls.__name__, result)
)
if not isinstance(exc, ValueError):
exc.__context__ = ve_exc
raise exc
finally:
# ensure all variables that could hold an exception are destroyed
exc = None
ve_exc = None
__repr__(self)
special
Return repr(self).
Source code in py_linq_sql/utils/classes/enum.py
def __repr__(self):
v_repr = self.__class__._value_repr_ or repr
return "<%s.%s: %s>" % (self.__class__.__name__, self._name_, v_repr(self._value_))
Terminal (Enum)
Enum of state of terminal flags.
Source code in py_linq_sql/utils/classes/enum.py
class Terminal(Enum):
"""Enum of state of terminal flags."""
COUNT = auto()
DISTINCT = auto()
ELEMENT_AT = auto()
EXCEPT_ = auto()
INTERSECT = auto()
LAST = auto()
MAX = auto()
MIN = auto()
SINGLE = auto()
UNION = auto()
GROUP_BY = auto()
GROUP_JOIN = auto()