lol
This commit is contained in:
@@ -50,7 +50,6 @@ from typing import overload
|
||||
from typing import Sequence as _typing_Sequence
|
||||
from typing import Set
|
||||
from typing import Tuple
|
||||
from typing import Type
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TypeVar
|
||||
from typing import Union
|
||||
@@ -1433,7 +1432,7 @@ class Table(
|
||||
elif schema is None:
|
||||
actual_schema = metadata.schema
|
||||
else:
|
||||
actual_schema = schema # type: ignore
|
||||
actual_schema = schema
|
||||
key = _get_table_key(name, actual_schema)
|
||||
if key in metadata.tables:
|
||||
util.warn(
|
||||
@@ -2452,14 +2451,8 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_T]):
|
||||
|
||||
# Constraint objects plus non-constraint-bound ForeignKey objects
|
||||
args: List[SchemaItem] = [
|
||||
c._copy(**kw)
|
||||
for c in self.constraints
|
||||
if not c._type_bound # type: ignore
|
||||
] + [
|
||||
c._copy(**kw) # type: ignore
|
||||
for c in self.foreign_keys
|
||||
if not c.constraint
|
||||
]
|
||||
c._copy(**kw) for c in self.constraints if not c._type_bound
|
||||
] + [c._copy(**kw) for c in self.foreign_keys if not c.constraint]
|
||||
|
||||
# ticket #5276
|
||||
column_kwargs = {}
|
||||
@@ -2529,6 +2522,15 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_T]):
|
||||
if self.primary_key:
|
||||
other.primary_key = True
|
||||
|
||||
if self.autoincrement != "auto" and other.autoincrement == "auto":
|
||||
other.autoincrement = self.autoincrement
|
||||
|
||||
if self.system:
|
||||
other.system = self.system
|
||||
|
||||
if self.info:
|
||||
other.info.update(self.info)
|
||||
|
||||
type_ = self.type
|
||||
if not type_._isnull and other.type._isnull:
|
||||
if isinstance(type_, SchemaEventTarget):
|
||||
@@ -2574,6 +2576,12 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_T]):
|
||||
if self.index and not other.index:
|
||||
other.index = True
|
||||
|
||||
if self.doc and other.doc is None:
|
||||
other.doc = self.doc
|
||||
|
||||
if self.comment and other.comment is None:
|
||||
other.comment = self.comment
|
||||
|
||||
if self.unique and not other.unique:
|
||||
other.unique = True
|
||||
|
||||
@@ -3973,7 +3981,7 @@ class FetchedValue(SchemaEventTarget):
|
||||
if for_update == self.for_update:
|
||||
return self
|
||||
else:
|
||||
return self._clone(for_update) # type: ignore
|
||||
return self._clone(for_update)
|
||||
|
||||
def _copy(self) -> FetchedValue:
|
||||
return FetchedValue(self.for_update)
|
||||
@@ -4151,7 +4159,7 @@ class Constraint(DialectKWArgs, HasConditionalDDL, SchemaItem):
|
||||
"and will be removed in a future release.",
|
||||
)
|
||||
def copy(self, **kw: Any) -> Self:
|
||||
return self._copy(**kw) # type: ignore
|
||||
return self._copy(**kw)
|
||||
|
||||
def _copy(self, **kw: Any) -> Self:
|
||||
raise NotImplementedError()
|
||||
@@ -5286,35 +5294,31 @@ class Index(
|
||||
)
|
||||
|
||||
|
||||
_AllConstraints = Union[
|
||||
Index,
|
||||
UniqueConstraint,
|
||||
CheckConstraint,
|
||||
ForeignKeyConstraint,
|
||||
PrimaryKeyConstraint,
|
||||
]
|
||||
|
||||
_NamingSchemaCallable = Callable[[_AllConstraints, Table], str]
|
||||
_NamingSchemaCallable = Callable[[Constraint, Table], str]
|
||||
_NamingSchemaDirective = Union[str, _NamingSchemaCallable]
|
||||
|
||||
|
||||
class _NamingSchemaTD(TypedDict, total=False):
|
||||
fk: Union[str, _NamingSchemaCallable]
|
||||
pk: Union[str, _NamingSchemaCallable]
|
||||
ix: Union[str, _NamingSchemaCallable]
|
||||
ck: Union[str, _NamingSchemaCallable]
|
||||
uq: Union[str, _NamingSchemaCallable]
|
||||
fk: _NamingSchemaDirective
|
||||
pk: _NamingSchemaDirective
|
||||
ix: _NamingSchemaDirective
|
||||
ck: _NamingSchemaDirective
|
||||
uq: _NamingSchemaDirective
|
||||
|
||||
|
||||
_NamingSchemaParameter = Union[
|
||||
# it seems like the TypedDict here is useful for pylance typeahead,
|
||||
# and not much else
|
||||
_NamingSchemaTD,
|
||||
Mapping[
|
||||
Union[Type[_AllConstraints], str], Union[str, _NamingSchemaCallable]
|
||||
],
|
||||
# there is no form that allows Union[Type[Any], str] to work in all
|
||||
# cases, including breaking out Mapping[] entries for each combination
|
||||
# even, therefore keys must be `Any` (see #10264)
|
||||
Mapping[Any, _NamingSchemaDirective],
|
||||
]
|
||||
|
||||
|
||||
DEFAULT_NAMING_CONVENTION: _NamingSchemaParameter = util.immutabledict(
|
||||
{"ix": "ix_%(column_0_label)s"} # type: ignore[arg-type]
|
||||
{"ix": "ix_%(column_0_label)s"}
|
||||
)
|
||||
|
||||
|
||||
@@ -5522,7 +5526,7 @@ class MetaData(HasSchemaAttr):
|
||||
|
||||
def _remove_table(self, name: str, schema: Optional[str]) -> None:
|
||||
key = _get_table_key(name, schema)
|
||||
removed = dict.pop(self.tables, key, None) # type: ignore
|
||||
removed = dict.pop(self.tables, key, None)
|
||||
if removed is not None:
|
||||
for fk in removed.foreign_keys:
|
||||
fk._remove_from_metadata(self)
|
||||
@@ -5622,7 +5626,9 @@ class MetaData(HasSchemaAttr):
|
||||
bind: Union[Engine, Connection],
|
||||
schema: Optional[str] = None,
|
||||
views: bool = False,
|
||||
only: Optional[_typing_Sequence[str]] = None,
|
||||
only: Union[
|
||||
_typing_Sequence[str], Callable[[str, MetaData], bool], None
|
||||
] = None,
|
||||
extend_existing: bool = False,
|
||||
autoload_replace: bool = True,
|
||||
resolve_fks: bool = True,
|
||||
|
||||
Reference in New Issue
Block a user