💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Fix issue with ORDER BY case sensitivity, closes #405
davidmezzettid92a076c06a6
diff --git a/src/python/txtai/database/sql/base.py b/src/python/txtai/database/sql/base.pyindex 6dabaa15..58d4156f 100644--- a/src/python/txtai/database/sql/base.py+++ b/src/python/txtai/database/sql/base.py@@ -144,7 +144,7 @@ class SQL:# Get position of clause keywords. For multi-term clauses, validate next token matches as wellfor x, token in enumerate(tokens):t = token.lower()- if t not in positions and t in SQL.CLAUSES and (t not in ["group", "order"] or (x + 1 < len(tokens) and tokens[x + 1] == "by")):+ if t not in positions and t in SQL.CLAUSES and (t not in ["group", "order"] or (x + 1 < len(tokens) and tokens[x + 1].lower() == "by")):positions[t] = xreturn (tokens, positions)diff --git a/test/python/testdatabase/testsql.py b/test/python/testdatabase/testsql.pyindex 3249614a..9cf6e3fa 100644--- a/test/python/testdatabase/testsql.py+++ b/test/python/testdatabase/testsql.py@@ -236,6 +236,14 @@ class TestSQL(unittest.TestCase):self.assertSql("where", prefix + "where coalesce(similar('abc'), similar('abc'))", "coalesce(__SIMILAR__0, __SIMILAR__1)")self.assertSql("similar", prefix + "where coalesce(similar('abc'), similar('abc'))", [["abc"], ["abc"]])+ def testUpper(self):+ """+ Tests SQL statements are case insensitive.+ """++ self.assertSql("groupby", "SELECT * FROM TXTAI WHERE a = 1 GROUP BY id", "s.id")+ self.assertSql("orderby", "SELECT * FROM TXTAI WHERE a = 1 ORDER BY id", "s.id")+def testWhereBasic(self):"""Test basic where clauses