MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / Integer

Class Integer

lib/sqlalchemy/sql/sqltypes.py:365–422  ·  view source on GitHub ↗

A type for ``int`` integers.

Source from the content-addressed store, hash-verified

363
364
365class Integer(HasExpressionLookup, TypeEngine[int]):
366 """A type for ``int`` integers."""
367
368 __visit_name__ = "integer"
369
370 operator_classes = OperatorClass.INTEGER
371
372 if TYPE_CHECKING:
373
374 @util.ro_memoized_property
375 def _type_affinity(self) -> Type[Integer]: ...
376
377 def get_dbapi_type(self, dbapi):
378 return dbapi.NUMBER
379
380 @property
381 def python_type(self):
382 return int
383
384 def _resolve_for_literal(self, value):
385 if value.bit_length() >= 32:
386 return _BIGINTEGER
387 else:
388 return self
389
390 def literal_processor(self, dialect):
391 def process(value):
392 return str(int(value))
393
394 return process
395
396 @util.memoized_property
397 def _expression_adaptations(self):
398 return {
399 operators.add: {
400 Date: Date,
401 Integer: self.__class__,
402 Numeric: Numeric,
403 Float: Float,
404 },
405 operators.mul: {
406 Interval: Interval,
407 Integer: self.__class__,
408 Numeric: Numeric,
409 Float: Float,
410 },
411 operators.truediv: {
412 Integer: Numeric,
413 Numeric: Numeric,
414 Float: Float,
415 },
416 operators.floordiv: {Integer: self.__class__, Numeric: Numeric},
417 operators.sub: {
418 Integer: self.__class__,
419 Numeric: Numeric,
420 Float: Float,
421 },
422 }

Calls

no outgoing calls