from typing import Any, Dict
from pystratum_common.wrapper.Singleton0Wrapper import Singleton0Wrapper
from pystratum_pgsql.wrapper.PgSqlWrapper import PgSqlWrapper
[docs]class PgSqlSingleton0Wrapper(PgSqlWrapper, Singleton0Wrapper):
"""
Wrapper method generator for stored procedures that are selecting 0 or 1 row with one column only.
"""
# ------------------------------------------------------------------------------------------------------------------
def _write_result_handler(self, routine: Dict[str, Any]) -> None:
"""
Generates code of the return statement of the wrapper method for invoking a stored routine.
:param dict routine: Metadata of the stored routine.
"""
self._write_line('return self.execute_sp_singleton0({0!s})'.format(self._generate_command(routine)))
# ----------------------------------------------------------------------------------------------------------------------