An unknown type. :class:`.NullType` is used as a default type for those cases where a type cannot be determined, including: * During table reflection, when the type of a column is not recognized by the :class:`.Dialect` * When constructing SQL expressions using plain Python o
| 3690 | |
| 3691 | |
| 3692 | class NullType(TypeEngine[None]): |
| 3693 | """An unknown type. |
| 3694 | |
| 3695 | :class:`.NullType` is used as a default type for those cases where |
| 3696 | a type cannot be determined, including: |
| 3697 | |
| 3698 | * During table reflection, when the type of a column is not recognized |
| 3699 | by the :class:`.Dialect` |
| 3700 | * When constructing SQL expressions using plain Python objects of |
| 3701 | unknown types (e.g. ``somecolumn == my_special_object``) |
| 3702 | * When a new :class:`_schema.Column` is created, |
| 3703 | and the given type is passed |
| 3704 | as ``None`` or is not passed at all. |
| 3705 | |
| 3706 | The :class:`.NullType` can be used within SQL expression invocation |
| 3707 | without issue, it just has no behavior either at the expression |
| 3708 | construction level or at the bind-parameter/result processing level. |
| 3709 | :class:`.NullType` will result in a :exc:`.CompileError` if the compiler |
| 3710 | is asked to render the type itself, such as if it is used in a |
| 3711 | :func:`.cast` operation or within a schema creation operation such as that |
| 3712 | invoked by :meth:`_schema.MetaData.create_all` or the |
| 3713 | :class:`.CreateTable` |
| 3714 | construct. |
| 3715 | |
| 3716 | """ |
| 3717 | |
| 3718 | __visit_name__ = "null" |
| 3719 | |
| 3720 | _isnull = True |
| 3721 | |
| 3722 | operator_classes = OperatorClass.ANY |
| 3723 | |
| 3724 | def literal_processor(self, dialect): |
| 3725 | return None |
| 3726 | |
| 3727 | class Comparator(TypeEngine.Comparator[_T]): |
| 3728 | __slots__ = () |
| 3729 | |
| 3730 | def _adapt_expression( |
| 3731 | self, |
| 3732 | op: OperatorType, |
| 3733 | other_comparator: TypeEngine.Comparator[Any], |
| 3734 | ) -> Tuple[OperatorType, TypeEngine[Any]]: |
| 3735 | if isinstance( |
| 3736 | other_comparator, NullType.Comparator |
| 3737 | ) or not operators.is_commutative(op): |
| 3738 | return op, self.expr.type |
| 3739 | else: |
| 3740 | return other_comparator._adapt_expression(op, self) |
| 3741 | |
| 3742 | comparator_factory = Comparator |
| 3743 | |
| 3744 | |
| 3745 | class TableValueType(HasCacheKey, TypeEngine[Any]): |
no outgoing calls