Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Fix issue with parsing multiline SQL statements, closes #242

davidmezzettidda277785a61
diff --git a/src/python/txtai/database/sql/base.py b/src/python/txtai/database/sql/base.py
index e7bef613..439f18b1 100644
--- a/src/python/txtai/database/sql/base.py
+++ b/src/python/txtai/database/sql/base.py
@@ -94,7 +94,10 @@ class SQL:
True if this is a valid SQL query, False otherwise
"""
- query = query.lower().strip(";")
+ # Reduce query to a single line, lower-cased and stripped of leading/trailing whitespace
+ query = query.lower().strip(";").replace("\n", " ").replace("\t", " ").strip()
+
+ # Detect if this is a valid txtai SQL statement
return query.startswith("select ") and (" from txtai " in query or query.endswith(" from txtai"))
def tokenize(self, query):