Skip to content
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

AstToSqlVisitor can not handle a function call as right hand side of contains-filter #47

Closed
d2a-pnagel opened this issue Nov 7, 2023 · 2 comments · Fixed by #49
Closed
Assignees
Labels
bug Something isn't working

Comments

@d2a-pnagel
Copy link

Steps to reproduce:

  • Try to translate contains(tolower(name), tolower('A')) to SQL using the AstToSqlVisitor
    -> error:
 AttributeError("'Call' object has no attribute 'val'")

Bug spotted:

  • AstToSqlVisitor._to_pattern does not take into account that the arg could be an ast.Call (and assumes a literal in the else branch)

Proposed solution:

Change

  if isinstance(arg, ast.Identifier):

Into

  if isinstance(arg, ast.Identifier | ast.Call):
@OliverHofkens OliverHofkens self-assigned this Nov 14, 2023
@OliverHofkens OliverHofkens added the bug Something isn't working label Nov 14, 2023
OliverHofkens added a commit that referenced this issue Nov 14, 2023
@OliverHofkens
Copy link
Member

Hi!
Thanks for the very clear and concise report, reproducer ánd proposed fix. What a blessing!
PR #49 contains the fix and a lot of test cases to cover it. Once reviewed, I'll include it in a new release (0.9.1).

@OliverHofkens
Copy link
Member

Should be live in v0.9.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants