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
feat: Native PG array type #9
Conversation
e45bef5
to
0d31d88
Compare
Can I help at all in getting this merged? |
0d31d88
to
4576a31
Compare
@maitham I think the big thing this needs now is to figure out how to get |
I made some progress on debugging these tests and trying to make this work. Basically it boils down to needing to call The challenge is that when Ormar compiles statements, it uses Unfortunately, SQLAlchemy cannot render literals for arrays. A simple test to show this is: from sqlalchemy import Column, Integer
from sqlalchemy.dialects import postgresql
numbers = Column(postgresql.ARRAY(Integer))
clause = numbers.contains([11])
print(clause.compile(compile_kwargs={"literal_binds": True},)) # Causes a NotImplementedError @collerek is there a reason ormar uses |
Following up on |
Will check that, to be honest I don't remember why it uses literal binds 🙈 |
Thanks for taking a look @collerek! I was digging through it as well. It looks like it was introduced in collerek/ormar#87. It appears to be related to column aliases. I was actually able to make it work with arrays by simply commenting out the call to The good news is that I haven't been able to inject something via a string filter. |
There is a PR that removes the literal binds, currently blocked by a bug in |
Amazing, thank you @collerek! |
] | ||
|
||
|
||
for (method_name, method) in FIELD_ACCESSOR_MAP: |
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.
@collerek not sure how you feel about this patching of the FieldAccessor
class and the FILTER_OPERATIONS
and METHODS_TO_OPERATORS
dictionaries. I'm open to other suggestions if there's a better way to implement this.
🎉 This PR is included in version 2.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
No description provided.