Skip to content

Commit 5fe3e2f

Browse files
authored
Merge branch 'sqlalchemy:main' into feature/history-reversed-order
2 parents 9407e4b + b36174e commit 5fe3e2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4320
-1593
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
- id: black
88

99
- repo: https://github.com/sqlalchemyorg/zimports
10-
rev: v0.6.2
10+
rev: v0.7.0
1111
hooks:
1212
- id: zimports
1313
args:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2009-2025 Michael Bayer.
1+
Copyright 2009-2026 Michael Bayer.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of
44
this software and associated documentation files (the "Software"), to deal in

alembic/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from . import context
22
from . import op
3+
from .runtime import plugins
34

4-
__version__ = "1.17.3"
5+
6+
__version__ = "1.18.2"

alembic/autogenerate/api.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import contextlib
4+
import logging
45
from typing import Any
56
from typing import Dict
67
from typing import Iterator
@@ -17,11 +18,9 @@
1718
from . import render
1819
from .. import util
1920
from ..operations import ops
21+
from ..runtime.plugins import Plugin
2022
from ..util import sqla_compat
2123

22-
"""Provide the 'autogenerate' feature which can produce migration operations
23-
automatically."""
24-
2524
if TYPE_CHECKING:
2625
from sqlalchemy.engine import Connection
2726
from sqlalchemy.engine import Dialect
@@ -42,6 +41,10 @@
4241
from ..script.base import Script
4342
from ..script.base import ScriptDirectory
4443
from ..script.revision import _GetRevArg
44+
from ..util import PriorityDispatcher
45+
46+
47+
log = logging.getLogger(__name__)
4548

4649

4750
def compare_metadata(context: MigrationContext, metadata: MetaData) -> Any:
@@ -304,7 +307,7 @@ class AutogenContext:
304307
305308
"""
306309

307-
dialect: Optional[Dialect] = None
310+
dialect: Dialect
308311
"""The :class:`~sqlalchemy.engine.Dialect` object currently in use.
309312
310313
This is normally obtained from the
@@ -326,9 +329,11 @@ class AutogenContext:
326329
327330
"""
328331

329-
migration_context: MigrationContext = None # type: ignore[assignment]
332+
migration_context: MigrationContext
330333
"""The :class:`.MigrationContext` established by the ``env.py`` script."""
331334

335+
comparators: PriorityDispatcher
336+
332337
def __init__(
333338
self,
334339
migration_context: MigrationContext,
@@ -346,6 +351,19 @@ def __init__(
346351
"the database for schema information"
347352
)
348353

354+
# branch off from the "global" comparators. This collection
355+
# is empty in Alembic except that it is populated by third party
356+
# extensions that don't use the plugin system. so we will build
357+
# off of whatever is in there.
358+
if autogenerate:
359+
self.comparators = compare.comparators.branch()
360+
Plugin.populate_autogenerate_priority_dispatch(
361+
self.comparators,
362+
include_plugins=migration_context.opts.get(
363+
"autogenerate_plugins", ["alembic.autogenerate.*"]
364+
),
365+
)
366+
349367
if opts is None:
350368
opts = migration_context.opts
351369

@@ -380,9 +398,8 @@ def __init__(
380398
self._name_filters = name_filters
381399

382400
self.migration_context = migration_context
383-
if self.migration_context is not None:
384-
self.connection = self.migration_context.bind
385-
self.dialect = self.migration_context.dialect
401+
self.connection = self.migration_context.bind
402+
self.dialect = self.migration_context.dialect
386403

387404
self.imports = set()
388405
self.opts: Dict[str, Any] = opts

0 commit comments

Comments
 (0)