mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Update get_*_column functions
Use getattr instead of model_to_dict in single columns. We might want to change the functions later on so peewee's ForeignKeyField primary key shorthand like model.server_id instead of model.server.server_id will work. This will very likely increase performance of the get_*_column functions due to not having to call the model_to_dict function from Peewee's helper library.
This commit is contained in:
@ -144,10 +144,10 @@ class HelperServers:
|
||||
@staticmethod
|
||||
def get_server_column(server_id: t.Union[str, int], column_name: str) -> t.Any:
|
||||
column = getattr(Servers, column_name)
|
||||
return model_to_dict(
|
||||
return getattr(
|
||||
Servers.select(column).where(Servers.server_id == server_id).get(),
|
||||
only=[column],
|
||||
)[column_name]
|
||||
column_name,
|
||||
)
|
||||
|
||||
# **********************************************************************************
|
||||
# Servers Methods
|
||||
|
Reference in New Issue
Block a user