-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Natively support PGARRAY from PostgreSQL within the ORM #370
Comments
Seems reasonable, we should do it. Ok, for filtering by it, the SQL would be something like: SELECT * FROM foo WHERE ANY(bar) = 'value' Ah, and I think we should create an We will have to try and implement some kind of emulation for SQLite and MySQL which don't support this |
Hi @grigi! It's nice to see you have answered so fast :)
So essentially I would like to be able to check if one array is contained in another one (if each of its elements appears in the other array). |
hey @grigi! I was wondering if there are any updates on this request? |
Hi @odimko No, sorry no updates. I don't have much time this week to do anything much. |
Hi @grigi! Just checking in to ask if there's any progress with my request. Any update would be appreciated. |
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. |
Is 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 convertingJSONB
toVARCHAR
, to be able to have my data in thePGARRAY
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 thePhrases
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:tortoise-orm/tortoise/fields/data.py
Line 371 in bad2710
After that a new filter is needed, that could also be created similarly to
tortoise-orm/tortoise/filters.py
Line 150 in a3d8507
Additional context
The feature would bring more value to the ORM when it comes to the exact matching of elements with a database.
The text was updated successfully, but these errors were encountered: