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

500 Response When Triggering Wildcard in List NotImplementedError #152

Open
meksor opened this issue Jan 17, 2025 · 2 comments
Open

500 Response When Triggering Wildcard in List NotImplementedError #152

meksor opened this issue Jan 17, 2025 · 2 comments

Comments

@meksor
Copy link
Contributor

meksor commented Jan 17, 2025

The error is thrown here:

raise NotImplementedError("Filter by list with wildcard is not implemented")

and should probably be a custom Ixmp4Error to produce a 404 response.

@danielhuppmann
Copy link
Member

Looks like I implemented that a while ago because the "expanded" filter had to be either __in for a list or __like for a string.

Would it make sense to do do something like

  _value = []
  for v in value:
      if "*" in v:
          _value.add(<get list that matches v  on the "upstream" repository>)
      else:
           _value.append(v)
   return dict(name__in=_value)

But I'm not sure what's an efficient way to implement <get list that matches v>.

@meksor meksor changed the title 500 Response When Triggering NotImplementedError 500 Response When Triggering Wildcard in List NotImplementedError Jan 17, 2025
@meksor
Copy link
Contributor Author

meksor commented Jan 17, 2025

The best way I can think of implementing this is by making a second in_() filter function like this one:

def in_(
c: db.typing_column[in_Type], v: Iterable[in_Type] | db.BindParameter[in_Type]
) -> db.BinaryExpression[bool]:
return c.in_(v)

Which parses the list if values (i guess this only works for strings) and builds a complex sql query from the list.
The best way to build the query is probably by filtering out all entries containing wildcards and building a query like:

SELECT ... FROM table WHERE
column IN ("no wildcard", "simple name", "single model")
OR 
column LIKE "wildcard %query"
OR 
column LIKE "Model %";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants