Deadman922 commited on
Commit
b33e000
·
verified ·
1 Parent(s): e1b8354

Upload environment.py

Browse files
Files changed (1) hide show
  1. server/environment.py +5 -5
server/environment.py CHANGED
@@ -223,13 +223,13 @@ class SQLQualityEnvironment:
223
  sql_stripped = re.sub(r"/\*.*?\*/", "", sql_stripped, flags=re.DOTALL) # block comments
224
  first_keyword = sql_stripped.strip().split()[0].upper() if sql_stripped.strip() else ""
225
 
226
- ALLOWED_READ_KEYWORDS = {"SELECT", "WITH", "EXPLAIN", "PRAGMA"}
 
 
227
  if first_keyword not in ALLOWED_READ_KEYWORDS:
228
  rejection_feedback = (
229
- f"QUERY action only accepts read-only SQL. "
230
- f"You submitted a '{first_keyword}' statement. "
231
- f"To modify data, use the FIX action (action_type: 'fix'). "
232
- f"To find the answer, use action_type: 'submit'."
233
  )
234
  # Add to trajectory as a step but with zero reward and clear feedback
235
  self._trajectory.append(
 
223
  sql_stripped = re.sub(r"/\*.*?\*/", "", sql_stripped, flags=re.DOTALL) # block comments
224
  first_keyword = sql_stripped.strip().split()[0].upper() if sql_stripped.strip() else ""
225
 
226
+ # Allow all SQL types in query box for testing
227
+ # Only FIX action should be restricted
228
+ ALLOWED_READ_KEYWORDS = {"SELECT", "WITH", "EXPLAIN", "PRAGMA", "UPDATE", "INSERT", "DELETE", "CREATE", "DROP", "ALTER"}
229
  if first_keyword not in ALLOWED_READ_KEYWORDS:
230
  rejection_feedback = (
231
+ f"Invalid SQL keyword: '{first_keyword}'. "
232
+ f"Allowed keywords: {', '.join(sorted(ALLOWED_READ_KEYWORDS))}"
 
 
233
  )
234
  # Add to trajectory as a step but with zero reward and clear feedback
235
  self._trajectory.append(