-
-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for case insensitive regexp + add support for REGEXP SQLite module #1737
Conversation
Pull Request Test Coverage Report for Build 12543888866Details
💛 - Coveralls |
@larsschwegmann Hi! Sorry I didn't pay attention to this PR, seems like I missed it Could you please add some tests for that feature? |
Sorry, I also missed your response while i was on vacation. I'll add tests later today 👍 |
dda4eaf
to
2a7f84e
Compare
@abondar Hi again! I added tests for the new functionality. Please take a look and let me know what you think. Feel free to merge if it looks okay to you 😄 |
tortoise/backends/sqlite/client.py
Outdated
@@ -81,6 +82,7 @@ async def create_connection(self, with_db: bool) -> None: | |||
for pragma, val in self.pragmas.items(): | |||
cursor = await self._connection.execute(f"PRAGMA {pragma}={val}") | |||
await cursor.close() | |||
await install_regexp_function(self._connection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit strange that we are automatically installing new functions in user db just on connection
May be we should add some kind of flag to make it explicit and only in case user need it?
If we do so, also would be nice to check if it was activated inside function and propagate proper error for user to prompt him to switch that flag
Even though it sounds like unneeded extra steps - it seems reasonable to not modify user db without explicit requests to do so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you are probably right about that. although it does not modify the db, it could introduce bad behaviour in case a user has already overwritten the regexp
or match
functions. I like the approach with the flag you proposed, I'll try and implement that 😄
c1e2b6c
to
06af74d
Compare
Hi @abondar ! |
@larsschwegmann Hi! Sorry, I missed your update and now branch is stale |
02cf054
to
a627171
Compare
Hi @abondar , thanks for reaching out :) |
# Conflicts: # tortoise/contrib/postgres/regex.py
# Conflicts: # tortoise/backends/sqlite/client.py
# Conflicts: # tortoise/contrib/postgres/regex.py
# Conflicts: # tortoise/backends/sqlite/client.py
a627171
to
aa47753
Compare
Hi @abondar , could you please check when you have time? I have rebased again |
Thank you for merging @abondar ! 😄 |
I think it should be soon enough |
This PR adds support for case insentive regex filtering (postgres and sqlite). It also adds support for the REGEXP sqlite module (needs to be installed in sqlite to work).
Description
Postgres and SQLite offer ways to query with regular expression while ignoring case, similiarly how we already have case insensitive contains, etc. This PR adds support for these filters.
This PR also adds support for SQLite (regexp() function needs to be supplied at runtime, e.g. via an extension). It is installed by default on most linux distributions of sqlite.
Motivation and Context
I want to query case insensitive regex patterns. Having sqlite support is good for completeness. Many people including me use sqlite for unit tests, so having feature parity across db backends is aa big plus.
How Has This Been Tested?
Ran the tests suite
Checklist: