Allow leading comments in SQL input field (#653)

Thanks, @jaywgraves!
This commit is contained in:
Jay Graves 2020-02-04 20:13:24 -06:00 committed by GitHub
commit 33a12c8ae5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -174,6 +174,7 @@ disallawed_sql_res = [(re.compile("pragma"), "Statement may not contain PRAGMA")
def validate_sql_select(sql):
sql = "\n".join(line for line in sql.split('\n') if not line.strip().startswith('--'))
sql = sql.strip().lower()
if not any(r.match(sql) for r in allowed_sql_res):
raise InvalidSql("Statement must be a SELECT")