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

Got a 500 error on a like % query #41

Closed
simonw opened this issue Mar 18, 2021 · 1 comment
Closed

Got a 500 error on a like % query #41

simonw opened this issue Mar 18, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@simonw
Copy link
Owner

simonw commented Mar 18, 2021

I tried this:

select * from reporter where auth0_role_name like '%Trainee%'

And got a 500 error. Should have had an inline pink error instead. The problem was that those % needed to be %% - should have a hint about that.

@simonw simonw added the bug Something isn't working label Mar 18, 2021
@simonw simonw added this to the First non-alpha release milestone Mar 21, 2021
@simonw
Copy link
Owner Author

simonw commented Mar 21, 2021

This was a problem with the new code for extracting named parameters.

For input select 'foo' like 'f%':

Traceback (most recent call last):
  File "/Users/simon/.local/share/virtualenvs/vial-YGecuKOB/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/Users/simon/.local/share/virtualenvs/vial-YGecuKOB/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/simon/.local/share/virtualenvs/vial-YGecuKOB/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/Users/simon/Dropbox/Development/django-sql-dashboard/django_sql_dashboard/views.py", line 45, in dashboard_index
    return _dashboard_index(request, sql_queries, title="Django SQL Dashboard")
  File "/Users/simon/Dropbox/Development/django-sql-dashboard/django_sql_dashboard/views.py", line 72, in _dashboard_index
    for p in extract_named_parameters(sql):
  File "/Users/simon/Dropbox/Development/django-sql-dashboard/django_sql_dashboard/utils.py", line 47, in extract_named_parameters
    sql % capture

Exception Type: ValueError at /dashboard/
Exception Value: unsupported format character ''' (0x27) at index 21

def extract_named_parameters(sql):
capture = _CaptureDict()
sql % capture
return capture.accessed

@simonw simonw closed this as completed in 5b549fb Mar 21, 2021
simonw added a commit that referenced this issue Mar 24, 2021
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

No branches or pull requests

1 participant