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

Deriving named parameters fails in 1.0a11 #2442

Open
hughrawlinson opened this issue Nov 20, 2024 · 0 comments
Open

Deriving named parameters fails in 1.0a11 #2442

hughrawlinson opened this issue Nov 20, 2024 · 0 comments

Comments

@hughrawlinson
Copy link

hughrawlinson commented Nov 20, 2024

I had been using 1.0a11 since it's required for datasette-write, but when I tried to make a particular query (below), I got a 500 in datasette code. Stacktrace excerpt:

  File "/home/hugh/Development/github.com/hughrawlinson/eire-election-2024/.venv/lib/python3.12/site-packages/datasette/utils/__init__.py", line 1134, in derive_named_parameters
    return [row["p4"].lstrip(":") for row in results if row["opcode"] == "Variable"]
            ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lstrip'
INFO:     127.0.0.1:47266 - "GET /election-2024?sql=select+*+from+candidates+full+join+returning_officer_data+on+upper%28candidates.name%29+%3D+upper%28returning_officer_data.full_name%29+where+candidates.constituency+%3D%7E+%3Aconstituency+or+returning_officer_data.constituency+%3D%7E+%3Aconstituency&constituency=Cork+South-Central HTTP/1.1" 500 Internal Server Error

Looks like it's failing to derive named parameters from the query. When I checked this code in the repo, I found that it had changed since the alpha I was on - I removed datasette-write and moved to mainline releases, and the issue is fixed. Time to cut a new alpha for 1.0 with that change in? I also saw a PR saying that the write api had been merged to main - does this mean that the datasette-write and datasette-write-ui repos ought to be updated to remove the requirement on the alpha?

Query

select
  *
from
  candidates full
  join returning_officer_data on upper(candidates.name) = upper(returning_officer_data.full_name)
where
  candidates.constituency like :constituency
  or returning_officer_data.constituency like :constituency
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

1 participant