Skip to content

Commit 34334d3

Browse files
committed
try additional oracle monkeypatch
1 parent 8065651 commit 34334d3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

django_enum/tests/tests.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
# monkey patch a fix to django oracle backend bug, blocks all oracle tests
7474
from django.db.backends.oracle.schema import DatabaseSchemaEditor
7575
from django.utils.duration import duration_iso_string
76+
from django.db.backends.oracle.base import FormatStylePlaceholderCursor
77+
7678
quote_value = DatabaseSchemaEditor.quote_value
7779

7880

@@ -85,6 +87,28 @@ def quote_value_patched(self, value):
8587

8688

8789
DatabaseSchemaEditor.quote_value = quote_value_patched
90+
91+
92+
_param_generator = FormatStylePlaceholderCursor._param_generator
93+
94+
95+
def param_generator(self, params):
96+
params = _param_generator(self, params)
97+
if hasattr(params, "items"):
98+
return {
99+
k: duration_iso_string(v)
100+
if isinstance(v, timedelta)
101+
else v for k, v in params.items()
102+
}
103+
else:
104+
return [
105+
duration_iso_string(p)
106+
if isinstance(p, timedelta) else p for p in params
107+
]
108+
109+
110+
FormatStylePlaceholderCursor._param_generator = param_generator
111+
import cx_Oracle
88112
###############################################################################
89113

90114

@@ -946,13 +970,14 @@ def test_max_length_override(self):
946970
def test_serialization(self):
947971
from django.db.utils import DatabaseError
948972
from django.db import connection
973+
from pprint import pprint
949974

950975
with CaptureQueriesContext(connection) as ctx:
951976
try:
952977
# code that runs SQL queries
953978
tester = self.MODEL_CLASS.objects.create(**self.values_params)
979+
pprint(ctx.captured_queries)
954980
except DatabaseError:
955-
from pprint import pprint
956981
pprint(ctx.captured_queries)
957982
raise
958983

0 commit comments

Comments
 (0)