File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed
src/strawberry_sqlalchemy_mapper Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ Natively supports the following SQLAlchemy types:
136
136
``` python
137
137
Integer: int ,
138
138
Float: float ,
139
- BigInteger: int ,
139
+ BigInteger: BigInt ,
140
140
Numeric: Decimal,
141
141
DateTime: datetime,
142
142
Date: date,
Original file line number Diff line number Diff line change
1
+ Release type: patch
2
+
3
+ This change implements a new custom scalar ` BigInt ` that is mapped to SQLAlchemy's ` BigInteger ` .
Original file line number Diff line number Diff line change 93
93
resolve_model_node ,
94
94
resolve_model_nodes ,
95
95
)
96
+ from strawberry_sqlalchemy_mapper .scalars import BigInt
96
97
97
98
if TYPE_CHECKING :
98
99
from sqlalchemy .sql .expression import ColumnElement
@@ -193,7 +194,7 @@ class StrawberrySQLAlchemyMapper(Generic[BaseModelType]):
193
194
] = {
194
195
Integer : int ,
195
196
Float : float ,
196
- BigInteger : int ,
197
+ BigInteger : BigInt ,
197
198
Numeric : Decimal ,
198
199
DateTime : datetime ,
199
200
Date : date ,
@@ -353,6 +354,8 @@ def _convert_column_to_strawberry_type(
353
354
if item_type is SkipTypeSentinel :
354
355
return item_type
355
356
type_annotation = List [item_type ] # type: ignore
357
+ elif isinstance (column .type , BigInteger ):
358
+ type_annotation = BigInt
356
359
else :
357
360
for (
358
361
sqlalchemy_type ,
Original file line number Diff line number Diff line change
1
+ from typing import Union
2
+
3
+ import strawberry
4
+
5
+ BigInt = strawberry .scalar (
6
+ Union [int , str ], # type: ignore
7
+ serialize = lambda v : int (v ),
8
+ parse_value = lambda v : str (v ),
9
+ description = "BigInt field" ,
10
+ )
You can’t perform that action at this time.
0 commit comments