[Models] Fixed optional detection
This commit is contained in:
		
							parent
							
								
									d6475604e9
								
							
						
					
					
						commit
						cb342c07e8
					
				|  | @ -14,10 +14,8 @@ class ModelSerializeMixin: | |||
|             return False | ||||
| 
 | ||||
|         import typing | ||||
| 
 | ||||
|         if typing.get_origin(self.__class__.__annotations__[param]) is typing.Union and typing.get_args( | ||||
|             self.__class__.__annotations__[param] | ||||
|         )[1] is type(None): | ||||
|         hint = typing.get_type_hints(self.__class__)[param] | ||||
|         if typing.get_origin(hint) is typing.Union and len(typing.get_args(hint)) == 2 and typing.get_args(hint)[1] is type(None): | ||||
|             return getattr(self, param) is None | ||||
| 
 | ||||
|     def serialize(self): | ||||
|  |  | |||
|  | @ -80,7 +80,7 @@ class Event(db.Model, ModelSerializeMixin): | |||
| 
 | ||||
|     id: int = db.Column(db.Integer, primary_key=True) | ||||
|     start: datetime = db.Column(UtcDateTime, nullable=False) | ||||
|     end: datetime = db.Column(UtcDateTime) | ||||
|     end: Optional[datetime] = db.Column(UtcDateTime) | ||||
|     description: Optional[str] = db.Column(db.String(255)) | ||||
|     type: EventType = db.relationship("EventType") | ||||
|     jobs: list[Job] = db.relationship( | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue