Skip to content

Commit

Permalink
Merge pull request #97 from DanCardin/dc/optional-alembic
Browse files Browse the repository at this point in the history
fix: Undo accidental inclusion of alembic as required dependencies.
  • Loading branch information
DanCardin authored Oct 7, 2024
2 parents ca32253 + 67cc8a9 commit 62cb948
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
20 changes: 14 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@

## 0.15

### 0.15.4

- fix: Undo accidental inclusion of alembic as required dependencies.

### 0.15.3

- fix: Handle row/view metadata sequence.

### 0.15.2

fix: Handle trigger metadata sequence.
fix: Handle procedure metadata sequence.
fix: Handle function metadata sequence.
fix: Handle grant metadata sequence.
fix: Handle role metadata sequence.
fix: Handle schema metadata sequence.
- fix: Handle trigger metadata sequence.
- fix: Handle procedure metadata sequence.
- fix: Handle function metadata sequence.
- fix: Handle grant metadata sequence.
- fix: Handle role metadata sequence.
- fix: Handle schema metadata sequence.

### 0.15.1

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sqlalchemy-declarative-extensions"
version = "0.15.3"
version = "0.15.4"
authors = ["Dan Cardin <[email protected]>"]

description = "Library to declare additional kinds of objects not natively supported by SQLAlchemy/Alembic."
Expand Down
27 changes: 9 additions & 18 deletions src/sqlalchemy_declarative_extensions/alembic/base.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
from __future__ import annotations

import typing

from alembic.autogenerate.compare import comparators
from alembic.autogenerate.render import renderers
from alembic.autogenerate.rewriter import Rewriter
from alembic.operations import Operations

if typing.TYPE_CHECKING:
from alembic.operations.ops import MigrateOperation
from alembic.runtime.migration import MigrationContext
from alembic.script.revision import _GetRevArg


def register_alembic_events(
*,
Expand Down Expand Up @@ -60,33 +48,36 @@ def register_alembic_events(
import sqlalchemy_declarative_extensions.alembic.row # noqa


def _traverse_any_directive(
self,
context: MigrationContext,
revision: _GetRevArg,
directive: MigrateOperation,
) -> None:
def _traverse_any_directive(self, context, revision, directive) -> None:
pass


def register_comparator_dispatcher(fn, target: str):
from alembic.autogenerate.compare import comparators

dispatcher = comparators.dispatch_for(target)
dispatcher(fn)


def register_renderer_dispatcher(*ops, fn):
from alembic.autogenerate.render import renderers

for op in ops:
dispatcher = renderers.dispatch_for(op)
dispatcher(fn)


def register_rewriter_dispatcher(*ops):
from alembic.autogenerate.rewriter import Rewriter

for op in ops:
dispatcher = Rewriter._traverse.dispatch_for(op)
dispatcher(_traverse_any_directive)


def register_operation_dispatcher(*, fn, **ops):
from alembic.operations import Operations

for operation_name, op in ops.items():
operation_dispatcher = Operations.register_operation(operation_name)
operation_dispatcher(op)
Expand Down

0 comments on commit 62cb948

Please sign in to comment.