-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Add overload for ColumnCollection.get(col, default)" into rel_2_0
- Loading branch information
Showing
5 changed files
with
65 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from typing import Any | ||
|
||
from sqlalchemy import column | ||
from sqlalchemy import ColumnElement | ||
from sqlalchemy import Integer | ||
from sqlalchemy import literal | ||
from sqlalchemy import table | ||
|
||
|
||
def test_col_accessors() -> None: | ||
t = table("t", column("a"), column("b"), column("c")) | ||
|
||
t.c.a | ||
t.c["a"] | ||
|
||
t.c[2] | ||
t.c[0, 1] | ||
t.c[0, 1, "b", "c"] | ||
t.c[(0, 1, "b", "c")] | ||
|
||
t.c[:-1] | ||
t.c[0:2] | ||
|
||
|
||
def test_col_get() -> None: | ||
col_id = column("id", Integer) | ||
col_alt = column("alt", Integer) | ||
tbl = table("mytable", col_id) | ||
|
||
# EXPECTED_TYPE: Union[ColumnClause[Any], None] | ||
reveal_type(tbl.c.get("id")) | ||
# EXPECTED_TYPE: Union[ColumnClause[Any], None] | ||
reveal_type(tbl.c.get("id", None)) | ||
# EXPECTED_TYPE: Union[ColumnClause[Any], ColumnClause[int]] | ||
reveal_type(tbl.c.get("alt", col_alt)) | ||
col: ColumnElement[Any] = tbl.c.get("foo", literal("bar")) | ||
print(col) |
This file was deleted.
Oops, something went wrong.