@@ -17,12 +17,14 @@ class SQLSelectForm(forms.Form):
17
17
"""
18
18
Validate params
19
19
20
- sql: urlencoded sql with positional arguments
20
+ sql: The sql statement with interpolated params
21
+ raw_sql: The sql statement with placeholders
21
22
params: JSON encoded parameter values
22
23
duration: time for SQL to execute passed in from toolbar just for redisplay
23
24
hash: the hash of (secret + sql + params) for tamper checking
24
25
"""
25
26
sql = forms .CharField ()
27
+ raw_sql = forms .CharField ()
26
28
params = forms .CharField ()
27
29
alias = forms .CharField (required = False , initial = 'default' )
28
30
duration = forms .FloatField ()
@@ -39,8 +41,8 @@ def __init__(self, *args, **kwargs):
39
41
for name in self .fields :
40
42
self .fields [name ].widget = forms .HiddenInput ()
41
43
42
- def clean_sql (self ):
43
- value = self .cleaned_data ['sql ' ]
44
+ def clean_raw_sql (self ):
45
+ value = self .cleaned_data ['raw_sql ' ]
44
46
45
47
if not value .lower ().strip ().startswith ('select' ):
46
48
raise ValidationError ("Only 'select' queries are allowed." )
@@ -72,8 +74,7 @@ def clean_hash(self):
72
74
return hash
73
75
74
76
def reformat_sql (self ):
75
- sql , params = self .cleaned_data ['sql' ], self .cleaned_data ['params' ]
76
- return reformat_sql (self .cursor .db .ops .last_executed_query (self .cursor , sql , params ))
77
+ return reformat_sql (self .cleaned_data ['sql' ])
77
78
78
79
def make_hash (self , data ):
79
80
params = force_text (settings .SECRET_KEY ) + data ['sql' ] + data ['params' ]
0 commit comments