tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.7k stars 391 forks source link

Add support for case insensitive regexp + add support for REGEXP SQLite module #1737

Open larsschwegmann opened 1 month ago

larsschwegmann commented 1 month ago

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:

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 11324387264

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/filters.py 1 2 50.0%
tortoise/contrib/postgres/regex.py 3 5 60.0%
tortoise/contrib/sqlite/regex.py 6 8 75.0%
<!-- Total: 14 19 73.68% -->
Totals Coverage Status
Change from base Build 11323175489: -0.02%
Covered Lines: 5993
Relevant Lines: 6620

💛 - Coveralls
abondar commented 2 weeks ago

@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?