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:
luukas
2022-05-20 13:15:50 +03:00
parent 48948423c9
commit 1b059b24df
3 changed files with 9 additions and 19 deletions

View File

@ -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