@@ -270,7 +270,7 @@ def convert_json_type_to_string(type, column, registry=None):
270
270
271
271
272
272
@singledispatchbymatchfunction
273
- def convert_hybrid_property_return_type_inner (arg : Any ):
273
+ def convert_sqlalchemy_hybrid_property_type (arg : Any ):
274
274
existing_graphql_type = get_global_registry ().get_type_for_model (arg )
275
275
if existing_graphql_type :
276
276
return existing_graphql_type
@@ -283,60 +283,60 @@ def convert_hybrid_property_return_type_inner(arg: Any):
283
283
return String
284
284
285
285
286
- @convert_hybrid_property_return_type_inner .register (value_equals (str ))
287
- def convert_hybrid_property_return_type_inner_str (arg ):
286
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (str ))
287
+ def convert_sqlalchemy_hybrid_property_type_str (arg ):
288
288
return String
289
289
290
290
291
- @convert_hybrid_property_return_type_inner .register (value_equals (int ))
292
- def convert_hybrid_property_return_type_inner_int (arg ):
291
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (int ))
292
+ def convert_sqlalchemy_hybrid_property_type_int (arg ):
293
293
return Int
294
294
295
295
296
- @convert_hybrid_property_return_type_inner .register (value_equals (float ))
297
- def convert_hybrid_property_return_type_inner_float (arg ):
296
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (float ))
297
+ def convert_sqlalchemy_hybrid_property_type_float (arg ):
298
298
return Float
299
299
300
300
301
- @convert_hybrid_property_return_type_inner .register (value_equals (Decimal ))
302
- def convert_hybrid_property_return_type_inner_decimal (arg ):
301
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (Decimal ))
302
+ def convert_sqlalchemy_hybrid_property_type_decimal (arg ):
303
303
# The reason Decimal should be serialized as a String is because this is a
304
304
# base10 type used in things like money, and string allows it to not
305
305
# lose precision (which would happen if we downcasted to a Float, for example)
306
306
return String
307
307
308
308
309
- @convert_hybrid_property_return_type_inner .register (value_equals (bool ))
310
- def convert_hybrid_property_return_type_inner_bool (arg ):
309
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (bool ))
310
+ def convert_sqlalchemy_hybrid_property_type_bool (arg ):
311
311
return Boolean
312
312
313
313
314
- @convert_hybrid_property_return_type_inner .register (value_equals (datetime .datetime ))
315
- def convert_hybrid_property_return_type_inner_datetime (arg ):
314
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (datetime .datetime ))
315
+ def convert_sqlalchemy_hybrid_property_type_datetime (arg ):
316
316
return DateTime
317
317
318
318
319
- @convert_hybrid_property_return_type_inner .register (value_equals (datetime .date ))
320
- def convert_hybrid_property_return_type_inner_date (arg ):
319
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (datetime .date ))
320
+ def convert_sqlalchemy_hybrid_property_type_date (arg ):
321
321
return Date
322
322
323
323
324
- @convert_hybrid_property_return_type_inner .register (value_equals (datetime .time ))
325
- def convert_hybrid_property_return_type_inner_time (arg ):
324
+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (datetime .time ))
325
+ def convert_sqlalchemy_hybrid_property_type_time (arg ):
326
326
return Time
327
327
328
328
329
- @convert_hybrid_property_return_type_inner .register (value_is_subclass (enum .Enum ))
330
- def convert_hybrid_property_return_type_inner_enum (arg ):
329
+ @convert_sqlalchemy_hybrid_property_type .register (value_is_subclass (enum .Enum ))
330
+ def convert_sqlalchemy_hybrid_property_type_enum (arg ):
331
331
return Enum .from_enum (arg )
332
332
333
333
334
- @convert_hybrid_property_return_type_inner .register (lambda x : getattr (x , '__origin__' , None ) in [list , typing .List ])
335
- def convert_hybrid_property_return_type_inner_list (arg ):
334
+ @convert_sqlalchemy_hybrid_property_type .register (lambda x : getattr (x , '__origin__' , None ) in [list , typing .List ])
335
+ def convert_sqlalchemy_hybrid_property_type_list_t (arg ):
336
336
# type is either list[T] or List[T], generic argument at __args__[0]
337
337
internal_type = arg .__args__ [0 ]
338
338
339
- graphql_internal_type = convert_hybrid_property_return_type_inner (internal_type )
339
+ graphql_internal_type = convert_sqlalchemy_hybrid_property_type (internal_type )
340
340
341
341
return List (graphql_internal_type )
342
342
@@ -345,4 +345,4 @@ def convert_hybrid_property_return_type(hybrid_prop):
345
345
# Grab the original method's return type annotations from inside the hybrid property
346
346
return_type_annotation = hybrid_prop .fget .__annotations__ .get ('return' , str )
347
347
348
- return convert_hybrid_property_return_type_inner (return_type_annotation )
348
+ return convert_sqlalchemy_hybrid_property_type (return_type_annotation )
0 commit comments