Natively support PGARRAY from PostgreSQL within the ORM
See original GitHub issueIs your feature request related to a problem? Please describe.
The request is not related to a problem and it is about a new feature, namely, I would like to be able to do exact matching of elements in a column in a database with a provided list of values natively by the means of PGARRAY
data type, PostgreSQL built-in.
Describe the solution you’d like
Possible usage is mentioned in the fixed issue: using __icontains
for string matching returns partial string matches. However, fo my use case, I need exact matches. Thus, I would like, instead of implicitly converting JSONB
to VARCHAR
, to be able to have my data in the PGARRAY
data type, so that if I have two rows with ["book", "new book", "interesting bookstore", "interesting book"]
and ["new book", "interesting bookstore", "interesting book"]
values in the Phrases
column respectively, to search for matches with "book"
and only get the first row, since it contains this element.
Describe alternatives you’ve considered
A solution (and a manual alternative) would be to create a new field type in a similar fashion as here for the JSONB
field: https://github.com/tortoise/tortoise-orm/blob/bad27105b07f85e9ea2213be3e451024a08a12dd/tortoise/fields/data.py#L371
After that a new filter is needed, that could also be created similarly to https://github.com/tortoise/tortoise-orm/blob/a3d8507fa529c89bc9f09dfcce16af2877e0d2a3/tortoise/filters.py#L150
Additional context The feature would bring more value to the ORM when it comes to the exact matching of elements with a database.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Sorry, no. Since the whole covid-19 thing I have extremely limited time. I’m still around and healthy, but don’t see much time becoming available for the next few weeks. if anybody wants to have a go at this feature, you’re welcome.
Hi @odimko No, sorry no updates. I don’t have much time this week to do anything much.