﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35688	Postgresql DatabaseWrapper does not allow to override ensure_timezone() function in derived classes	Christian Hardenberg	Sarah Boyce	"**Description:**

The function _configure_connection() in base.py of the postgresql DatabaseWrapper directly calls the local function ensure_timezone:

{{{#!python
    def _configure_connection(self, connection):
        # This function is called from init_connection_state and from the
        # psycopg pool itself after a connection is opened. Make sure that
        # whatever is done here does not access anything on self aside from
        # variables.

        # Commit after setting the time zone.
        commit_tz = ensure_timezone(connection, self.ops, self.timezone_name)
        # Set the role on the connection. This is useful if the credential used
        # to login is not the same as the role that owns database resources. As
        # can be the case when using temporary or ephemeral credentials.
        role_name = self.settings_dict[""OPTIONS""].get(""assume_role"")
        commit_role = ensure_role(connection, self.ops, role_name)

        return commit_role or commit_tz
}}}

Instead it should call the class method like this, which should have the same result, but allows overriding in derived classes:
{{{#!python
        commit_tz = self.ensure_timezone()
}}} 

**Why it matters?**
I am implementing a database wrapper for QuestDB, which implements the postgres-protocol, so it's useful to derive the wrapper from the postgres wrapper. I need to override some methods though, such as ensure_timezone, because the set_config function is not supported by QuestDB (""SELECT set_config('TimeZone', 'UTC', false)"")

"	Bug	closed	contrib.postgres	5.1	Release blocker	fixed	DatabaseWrapper posgresql ensure_timezone	Christian Hardenberg Florian Apolloner	Ready for checkin	1	0	0	0	0	0
