73
73
# monkey patch a fix to django oracle backend bug, blocks all oracle tests
74
74
from django .db .backends .oracle .schema import DatabaseSchemaEditor
75
75
from django .utils .duration import duration_iso_string
76
+ from django .db .backends .oracle .base import FormatStylePlaceholderCursor
77
+
76
78
quote_value = DatabaseSchemaEditor .quote_value
77
79
78
80
@@ -85,6 +87,28 @@ def quote_value_patched(self, value):
85
87
86
88
87
89
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
88
112
###############################################################################
89
113
90
114
@@ -946,13 +970,14 @@ def test_max_length_override(self):
946
970
def test_serialization (self ):
947
971
from django .db .utils import DatabaseError
948
972
from django .db import connection
973
+ from pprint import pprint
949
974
950
975
with CaptureQueriesContext (connection ) as ctx :
951
976
try :
952
977
# code that runs SQL queries
953
978
tester = self .MODEL_CLASS .objects .create (** self .values_params )
979
+ pprint (ctx .captured_queries )
954
980
except DatabaseError :
955
- from pprint import pprint
956
981
pprint (ctx .captured_queries )
957
982
raise
958
983
0 commit comments