mirror of https://github.com/zulip/zulip.git
Revert "db: Force use of TimeTrackingCursor to work around Django 4.2 bug."
This reverts commit f1925487e8
.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
d0481be3e5
commit
e88b2caeef
|
@ -1,17 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from typing import (
|
from typing import Any, Callable, Dict, Iterable, List, Mapping, Sequence, TypeVar, Union
|
||||||
Any,
|
|
||||||
Callable,
|
|
||||||
Dict,
|
|
||||||
Iterable,
|
|
||||||
List,
|
|
||||||
Mapping,
|
|
||||||
Optional,
|
|
||||||
Sequence,
|
|
||||||
TypeVar,
|
|
||||||
Union,
|
|
||||||
overload,
|
|
||||||
)
|
|
||||||
|
|
||||||
from psycopg2.extensions import connection, cursor
|
from psycopg2.extensions import connection, cursor
|
||||||
from psycopg2.sql import Composable
|
from psycopg2.sql import Composable
|
||||||
|
@ -60,41 +48,6 @@ class TimeTrackingConnection(connection):
|
||||||
self.queries: List[Dict[str, str]] = []
|
self.queries: List[Dict[str, str]] = []
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
@overload
|
|
||||||
def cursor(
|
|
||||||
self,
|
|
||||||
name: Union[str, bytes, None] = ...,
|
|
||||||
*,
|
|
||||||
withhold: bool = ...,
|
|
||||||
scrollable: Optional[bool] = ...,
|
|
||||||
) -> TimeTrackingCursor:
|
|
||||||
...
|
|
||||||
|
|
||||||
@overload
|
|
||||||
def cursor(
|
|
||||||
self,
|
|
||||||
name: Union[str, bytes, None] = ...,
|
|
||||||
*,
|
|
||||||
cursor_factory: Callable[..., CursorT] = ...,
|
|
||||||
withhold: bool = ...,
|
|
||||||
scrollable: Optional[bool] = ...,
|
|
||||||
) -> CursorT:
|
|
||||||
...
|
|
||||||
|
|
||||||
@overload
|
|
||||||
def cursor(
|
|
||||||
self,
|
|
||||||
name: Union[str, bytes, None],
|
|
||||||
cursor_factory: Callable[..., CursorT] = ...,
|
|
||||||
withhold: bool = ...,
|
|
||||||
scrollable: Optional[bool] = ...,
|
|
||||||
) -> CursorT:
|
|
||||||
...
|
|
||||||
|
|
||||||
def cursor(self, *args: Any, **kwargs: Any) -> cursor:
|
|
||||||
kwargs["cursor_factory"] = TimeTrackingCursor
|
|
||||||
return super().cursor(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def reset_queries() -> None:
|
def reset_queries() -> None:
|
||||||
from django.db import connections
|
from django.db import connections
|
||||||
|
|
|
@ -7,7 +7,7 @@ from typing import Any, Dict, Final, List, Tuple, Union
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
from scripts.lib.zulip_tools import get_tornado_ports
|
from scripts.lib.zulip_tools import get_tornado_ports
|
||||||
from zerver.lib.db import TimeTrackingConnection
|
from zerver.lib.db import TimeTrackingConnection, TimeTrackingCursor
|
||||||
|
|
||||||
from .config import (
|
from .config import (
|
||||||
DEPLOY_ROOT,
|
DEPLOY_ROOT,
|
||||||
|
@ -281,6 +281,7 @@ DATABASES: Dict[str, Dict[str, Any]] = {
|
||||||
"CONN_MAX_AGE": 600,
|
"CONN_MAX_AGE": 600,
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"connection_factory": TimeTrackingConnection,
|
"connection_factory": TimeTrackingConnection,
|
||||||
|
"cursor_factory": TimeTrackingCursor,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import Dict, List, Optional, Tuple
|
||||||
import ldap
|
import ldap
|
||||||
from django_auth_ldap.config import LDAPSearch
|
from django_auth_ldap.config import LDAPSearch
|
||||||
|
|
||||||
from zerver.lib.db import TimeTrackingConnection
|
from zerver.lib.db import TimeTrackingConnection, TimeTrackingCursor
|
||||||
from zproject.settings_types import OIDCIdPConfigDict, SAMLIdPConfigDict, SCIMConfigDict
|
from zproject.settings_types import OIDCIdPConfigDict, SAMLIdPConfigDict, SCIMConfigDict
|
||||||
|
|
||||||
from .config import DEPLOY_ROOT, get_from_file_if_exists
|
from .config import DEPLOY_ROOT, get_from_file_if_exists
|
||||||
|
@ -36,6 +36,7 @@ DATABASES["default"] = {
|
||||||
"TEST_NAME": "django_zulip_tests",
|
"TEST_NAME": "django_zulip_tests",
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"connection_factory": TimeTrackingConnection,
|
"connection_factory": TimeTrackingConnection,
|
||||||
|
"cursor_factory": TimeTrackingCursor,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue