Repository navigation
Add default SQLite REGEXP support - #1770
Chen-dreamyu wants to merge 5 commits into
Conversation
|
Thank you for this PR. What if instead of documenting this, we added a default The idea would be we'd check if "regexp" not in self.functions:
conn.create_function(
"regexp", 2,
lambda pattern, value: re.search(pattern, value) is not None
)or we could have on SQLite: def regexp(self, pattern, value):
return value is not None and re.search(pattern, value) is not None
if "regexp" not in self.functions:
conn.create_function("regexp", 2, self.regexp) |
|
Thanks for the suggestion! I updated the branch in e73487c to register a default SQLite regexp function, while preserving custom regexp functions (including differently cased names). NULL inputs do not match. The documentation now describes the default and the override. Validation on Windows: PYTHONPATH=src/python;test/python python -m unittest testdatabase.testsql — 37 passed; python -m black --check src/python/txtai/database/sqlite.py test/python/testdatabase/testsql.py and git diff --check passed. The environment emitted existing NumPy/SciPy compatibility warnings; the complete suite and other platforms were not run. |
|
Please see build errors. The tests need to be alphabetically ordered and the test name is too long. You can run the same checks locally. |
Summary
Register a default Python regular-expression function for SQLite so queries using REGEXP work without custom configuration. A user-provided function named regexp continues to take precedence, and NULL inputs do not match. Update the query documentation to describe the default and customization.
Closes #1769. Related: #1625 and #1626 fixed SQL parsing.
Validation
The environment emitted NumPy/SciPy binary compatibility warnings during imports. The full suite and other operating systems were not run. Prepared with AI assistance.