]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
fix `server_default` type hint
authorCharly Laurent <charly.laurent@mergify.com>
Tue, 1 Apr 2025 18:21:00 +0000 (14:21 -0400)
committersqla-tester <sqla-tester@sqlalchemy.org>
Tue, 1 Apr 2025 18:21:00 +0000 (14:21 -0400)
### Description

The docstring of `alter_column` states: "Set to `None` to have the default removed". The type hint should accept None.

### Checklist

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

Fixes: #1639
Closes: #1641
Pull-request: https://github.com/sqlalchemy/alembic/pull/1641
Pull-request-sha: 6642187d254681712443039a95cc1f3110549654

Change-Id: Icb7246b47805d9b2c1ab70d4e26f3e09354fe190

alembic/op.pyi
alembic/operations/base.py
alembic/operations/ops.py

index 13a5852f6b1310c1e4a6ab6f9eb421456bb545f6..14e6c39ae7fea1308bd14f2899b475b699451f93 100644 (file)
@@ -146,7 +146,9 @@ def alter_column(
     *,
     nullable: Optional[bool] = None,
     comment: Union[str, Literal[False], None] = False,
-    server_default: Union[str, bool, Identity, Computed, TextClause] = False,
+    server_default: Union[
+        str, bool, Identity, Computed, TextClause, None
+    ] = False,
     new_column_name: Optional[str] = None,
     type_: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None,
     existing_type: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None,
index 139931147eba583ab5626195a2011763b601f466..d7823a5bfe677924fbb74dbbc3b83608f04d46e3 100644 (file)
@@ -706,7 +706,7 @@ class Operations(AbstractOperations):
             nullable: Optional[bool] = None,
             comment: Union[str, Literal[False], None] = False,
             server_default: Union[
-                str, bool, Identity, Computed, TextClause
+                str, bool, Identity, Computed, TextClause, None
             ] = False,
             new_column_name: Optional[str] = None,
             type_: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None,
index eebc23235b4c09ffa4dc8fda3dd8697c5a45a573..8c0bdf854af352aa0d5b2adfc8d200ad73eab74b 100644 (file)
@@ -1841,7 +1841,7 @@ class AlterColumnOp(AlterTableOp):
         nullable: Optional[bool] = None,
         comment: Optional[Union[str, Literal[False]]] = False,
         server_default: Union[
-            str, bool, Identity, Computed, TextClause
+            str, bool, Identity, Computed, TextClause, None
         ] = False,
         new_column_name: Optional[str] = None,
         type_: Optional[Union[TypeEngine[Any], Type[TypeEngine[Any]]]] = None,