return self.render_literal_value(value, bindparam.type)
def render_literal_value(
- self, value: str | None, type_: sqltypes.String
+ self, value: Optional[str], type_: sqltypes.String
) -> str:
"""Render the value of a bind parameter as a quoted literal.
return None
def get_from_hint_text(
- self, table: FromClause, text: str | None
- ) -> str | None:
+ self, table: FromClause, text: Optional[str]
+ ) -> Optional[str]:
return None
def get_crud_hint_text(self, table, text):
return text
- def update_limit_clause(self, update_stmt: "Update") -> str | None:
+ def update_limit_clause(self, update_stmt: "Update") -> Optional[str]:
"""Provide a hook for MySQL to add LIMIT to the UPDATE"""
return None
)
def visit_update(
- self, update_stmt: "Update", visiting_cte: CTE | None = None, **kw: Any
+ self,
+ update_stmt: "Update",
+ visiting_cte: Optional[CTE] = None,
+ **kw: Any,
) -> str:
compile_state = update_stmt._compile_state_factory( # type: ignore[call-arg] # NOQA: E501
update_stmt, self, **kw # type: ignore[arg-type]
def post_create_table(self, table):
return ""
- def get_column_default_string(self, column: Column[Any]) -> str | None:
+ def get_column_default_string(self, column: Column[Any]) -> Optional[str]:
if isinstance(column.server_default, schema.DefaultClause):
return self.render_default_string(column.server_default.arg)
else:
return None
- def render_default_string(self, default: Visitable | str) -> str:
+ def render_default_string(self, default: Union[Visitable, str]) -> str:
if isinstance(default, str):
return self.sql_compiler.render_literal_value(
default, sqltypes.STRINGTYPE
}
def visit_DECIMAL(
- self, type_: "sqltypes.DECIMAL[decimal.Decimal| float]", **kw: Any
+ self, type_: sqltypes.DECIMAL[Union[decimal.Decimal, float]], **kw: Any
) -> str:
if type_.precision is None:
return "DECIMAL"
def _render_string_type(
self,
- type_: "sqltypes.String | sqltypes.Uuid[_UUID_RETURN]",
+ type_: Union[sqltypes.String, sqltypes.Uuid[_UUID_RETURN]],
name: str,
- length_override: int | None = None,
+ length_override: Optional[int] = None,
) -> str:
text = name
if length_override:
self,
dialect: Dialect,
initial_quote: str = '"',
- final_quote: str | None = None,
+ final_quote: Optional[str] = None,
escape_quote: str = '"',
quote_case_sensitive_collations: bool = True,
omit_schema: bool = False,
@util.preload_module("sqlalchemy.sql.naming")
def format_constraint(
self, constraint: Constraint, _alembic_quote: bool = True
- ) -> str | None:
+ ) -> Optional[str]:
naming = util.preloaded.sql_naming
if constraint.name is _NONE_NAME:
def truncate_and_render_index_name(
self, name: str, _alembic_quote: bool = True
- ) -> str | None:
+ ) -> Optional[str]:
# calculate these at format time so that ad-hoc changes
# to dialect.max_identifier_length etc. can be reflected
# as IdentifierPreparer is long lived
def truncate_and_render_constraint_name(
self, name: str, _alembic_quote: bool = True
- ) -> str | None:
+ ) -> Optional[str]:
# calculate these at format time so that ad-hoc changes
# to dialect.max_identifier_length etc. can be reflected
# as IdentifierPreparer is long lived
def _truncate_and_render_maxlen_name(
self, name: str, max_: int, _alembic_quote: bool
- ) -> str | None:
+ ) -> Optional[str]:
if isinstance(name, elements._truncated_label):
if len(name) > max_:
name = name[0 : max_ - 8] + "_" + util.md5_hex(name)[-4:]
@overload
def format_table(
self,
- table: "FromClause | None",
+ table: Optional[FromClause],
use_schema: bool,
name: str,
) -> str: ...
def format_table(
self,
- table: "FromClause | None",
+ table: Optional[FromClause],
use_schema: bool = True,
- name: str | None = None,
+ name: Optional[str] = None,
) -> str:
"""Prepare a quoted table and schema name."""
if name is None:
self,
column: ColumnElement[Any],
use_table: bool = False,
- name: str | None = None,
- table_name: str | None = None,
+ name: Optional[str] = None,
+ table_name: Optional[str] = None,
use_schema: bool = False,
- anon_map: Mapping[str, Any] | None = None,
+ anon_map: Optional[Mapping[str, Any]] = None,
) -> str:
"""Prepare a quoted column name."""
def bind_processor(
self, dialect: Dialect
- ) -> _BindProcessorType[str] | None:
+ ) -> Optional[_BindProcessorType[str]]:
return None
def result_processor(
def _type_affinity(
self,
) -> Type[
- Numeric[decimal.Decimal | float] | Float[decimal.Decimal | float]
+ Union[
+ Numeric[Union[decimal.Decimal, float]],
+ Float[Union[decimal.Decimal, float]],
+ ]
]: ...
def __init__(
__visit_name__ = "float"
- scale: int | None = None
+ scale: Optional[int] = None
@overload
def __init__(
__visit_name__ = "enum"
- enum_class: None | str | type[enum.Enum]
+ enum_class: Union[None, str, type[enum.Enum]]
def __init__(self, *enums: Union[str, type[enum.Enum]], **kw: Any):
r"""Construct an enum.
"""
self.native_enum = kw.pop("native_enum", True)
self.create_constraint = kw.pop("create_constraint", False)
- self.values_callable: (
- Callable[[type[enum.Enum]], Sequence[str]] | None
- ) = kw.pop("values_callable", None)
+ self.values_callable: Optional[
+ Callable[[type[enum.Enum]], Sequence[str]]
+ ] = kw.pop("values_callable", None)
self._sort_key_function = kw.pop("sort_key_function", NO_ARG)
length_arg = kw.pop("length", NO_ARG)
self._omit_aliases = kw.pop("omit_aliases", True)
)
def _parse_into_values(
- self, enums: Sequence[str | type[enum.Enum]], kw: Any
- ) -> tuple[Sequence[str], Sequence[enum.Enum] | Sequence[str]]:
+ self, enums: Sequence[Union[str, type[enum.Enum]]], kw: Any
+ ) -> tuple[Sequence[str], Union[Sequence[enum.Enum], Sequence[str]]]:
if not enums and "_enums" in kw:
enums = kw.pop("_enums")
def _setup_for_values(
self,
values: Sequence[str],
- objects: Sequence[enum.Enum] | Sequence[str],
+ objects: Union[Sequence[enum.Enum], Sequence[str]],
kw: Any,
) -> None:
self.enums = list(values)
- self._valid_lookup: dict[enum.Enum | str | None, str | None] = dict(
- zip(reversed(objects), reversed(values))
- )
+ self._valid_lookup: dict[
+ Union[enum.Enum, str, None], Optional[str]
+ ] = dict(zip(reversed(objects), reversed(values)))
- self._object_lookup: dict[str | None, enum.Enum | str | None] = dict(
- zip(values, objects)
- )
+ self._object_lookup: dict[
+ Optional[str], Union[enum.Enum, str, None]
+ ] = dict(zip(values, objects))
self._valid_lookup.update(
[
def bind_processor(
self, dialect: Dialect
- ) -> "_BindProcessorType[dt.timedelta]":
+ ) -> _BindProcessorType[dt.timedelta]:
if TYPE_CHECKING:
assert isinstance(self.impl_instance, DateTime)
impl_processor = self.impl_instance.bind_processor(dialect)
def bind_processor(
self, dialect: Dialect
- ) -> "_BindProcessorType[_UUID_RETURN] | None":
+ ) -> Optional[_BindProcessorType[_UUID_RETURN]]:
character_based_uuid = (
not dialect.supports_native_uuid or not self.native_uuid
)