Skip to content

Commit 850cfb1

Browse files
authored
Improve types of lowecase table, column and values (#162)
fixes #161
1 parent 9661099 commit 850cfb1

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

sqlalchemy-stubs/sql/selectable.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ from .base import ImmutableColumnCollection
2828
from .elements import BindParameter
2929
from .elements import BooleanClauseList
3030
from .elements import ClauseElement
31+
from .elements import ColumnClause
3132
from .elements import ColumnElement
3233
from .elements import GroupedElement
3334
from .elements import Grouping
3435
from .elements import Label
3536
from .elements import TableValuedColumn
3637
from .elements import UnaryExpression
37-
from .schema import Column
3838
from .schema import ForeignKey
3939
from .schema import Table
4040
from .. import util
@@ -78,8 +78,8 @@ class Selectable(ReturnsRows):
7878
def lateral(self, name: Optional[str] = ...) -> Lateral: ...
7979
def replace_selectable(self: _S, old: Any, alias: Any) -> _S: ...
8080
def corresponding_column(
81-
self, column: Column[Any], require_embedded: bool = ...
82-
) -> Optional[Column[Any]]: ...
81+
self, column: ColumnElement[Any], require_embedded: bool = ...
82+
) -> Optional[ColumnElement[Any]]: ...
8383

8484
class HasPrefixes:
8585
def prefix_with(self: _HP, *expr: Any, **kw: Any) -> _HP: ...
@@ -298,11 +298,11 @@ class TableClause(roles.DMLTableRole, Immutable, FromClause):
298298
schema: Any = ...
299299
_autoincrement_column: None = ...
300300
def __init__(
301-
self, name: str, *columns: Column[Any], **kw: Any
301+
self, name: str, *columns: ColumnClause[Any], **kw: Any
302302
) -> None: ...
303303
@util.memoized_property
304304
def description(self) -> util.text_type: ... # type: ignore[override]
305-
def append_column(self, c: Column[Any], **kw: Any) -> None: ...
305+
def append_column(self, c: ColumnClause[Any], **kw: Any) -> None: ...
306306
def insert(
307307
self, values: Optional[Any] = ..., inline: bool = ..., **kwargs: Any
308308
) -> dml.Insert: ...
@@ -340,7 +340,7 @@ class Values(Generative, FromClause):
340340
__visit_name__: str = ...
341341
name: Any = ...
342342
literal_binds: Any = ...
343-
def __init__(self, *columns: Column[Any], **kw: Any) -> None: ...
343+
def __init__(self, *columns: ColumnClause[Any], **kw: Any) -> None: ...
344344
def alias(self: _VA, name: Any, **kw: Any) -> _VA: ... # type: ignore[override]
345345
def lateral(self: _VA, name: Optional[Any] = ...) -> _VA: ... # type: ignore[override]
346346
def data(self: _VA, values: Any) -> _VA: ...

test/files/lowercase_objects.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sqlalchemy as sa
2+
3+
Book = sa.table(
4+
"book",
5+
sa.column("id", sa.Integer),
6+
sa.column("name", sa.String),
7+
)
8+
Book.append_column(sa.column("other"))
9+
Book.corresponding_column(Book.c.id)
10+
11+
value_expr = sa.values(
12+
sa.column("id", sa.Integer), sa.column("name", sa.String), name="my_values"
13+
).data([(1, "name1"), (2, "name2"), (3, "name3")])

0 commit comments

Comments
 (0)