MCPcopy Create free account
hub / github.com/explorerhq/sql-explorer / validate

Method validate

explorer/forms.py:12–30  ·  view source on GitHub ↗

Ensure that the SQL passes the blacklist. :param value: The SQL for this Query model.

(self, value)

Source from the content-addressed store, hash-verified

10class SqlField(CharField):
11
12 def validate(self, value):
13 """
14 Ensure that the SQL passes the blacklist.
15
16 :param value: The SQL for this Query model.
17 """
18 super().validate(value)
19 query = Query(sql=value)
20
21 passes_blacklist, failing_words = query.passes_blacklist()
22
23 error = MSG_FAILED_BLACKLIST % ", ".join(
24 failing_words) if not passes_blacklist else None
25
26 if error:
27 raise ValidationError(
28 error,
29 code="InvalidSql"
30 )
31
32
33class QueryForm(ModelForm):

Callers

nothing calls this directly

Calls 2

passes_blacklistMethod · 0.95
QueryClass · 0.90

Tested by

no test coverage detected