Skip to content

Commit 6d07636

Browse files
ckarnellJukkaL
authored andcommitted
Fix types and add test for concat (#125)
Arguments for `concat` are allowed to be null, so this is just a simple fix for the existing stub.
1 parent a4e7d13 commit 6d07636

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

sqlalchemy-stubs/sql/functions.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class sum(ReturnTypeFromArgs[Any]): ...
112112

113113
class now(GenericFunction[datetime]): ...
114114

115-
class concat(GenericFunction[Text]): ...
115+
class concat(GenericFunction[Optional[Text]]): ...
116116

117117
class char_length(GenericFunction[int]): ...
118118

test/test-data/sqlalchemy-functions.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,22 @@ users_table = Table(
1616

1717
query = users_table.update().values(user=functions.concat(users_table.c.user, "@domain.com"))
1818
[out]
19+
20+
[case testConcatFunctionNullableString]
21+
from sqlalchemy.sql import functions
22+
23+
from sqlalchemy import Column, Table
24+
from sqlalchemy.types import Integer, String
25+
from sqlalchemy import MetaData
26+
27+
metadata = MetaData()
28+
29+
users_table = Table(
30+
"users",
31+
metadata,
32+
Column("id", Integer, primary_key=True, autoincrement=True),
33+
Column("user", String(42), unique=True, nullable=True),
34+
)
35+
36+
query = users_table.update().values(user=functions.concat(users_table.c.user, "@domain.com"))
37+
[out]

0 commit comments

Comments
 (0)