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

Database with dot in filename causes errors, tilde encoding issue #23

Open
voltagex opened this issue Jan 20, 2024 · 0 comments · May be fixed by #24
Open

Database with dot in filename causes errors, tilde encoding issue #23

voltagex opened this issue Jan 20, 2024 · 0 comments · May be fixed by #24

Comments

@voltagex
Copy link

voltagex commented Jan 20, 2024

echo "create table if not exists test (myrow int); insert into test values (1)" | sqlite3 /tmp/this.is.a.test.db

Run datasette,

Traceback (most recent call last):
  File "/home/voltagex/.local/pipx/venvs/datasette/lib/python3.11/site-packages/datasette/app.py", line 1598, in route_path
    response = await view(request, send)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/voltagex/.local/pipx/venvs/datasette/lib/python3.11/site-packages/datasette/app.py", line 1780, in async_view_fn
    response = await async_call_with_supported_arguments(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/voltagex/.local/pipx/venvs/datasette/lib/python3.11/site-packages/datasette/utils/__init__.py", line 1014, in async_call_with_supported_arguments
    return await fn(*call_with)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/voltagex/.local/pipx/venvs/datasette/lib/python3.11/site-packages/datasette_write_ui/__init__.py", line 159, in insert_row_details
    db = datasette.get_database(db_name)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/voltagex/.local/pipx/venvs/datasette/lib/python3.11/site-packages/datasette/app.py", line 573, in get_database
    return self.databases[name]
           ~~~~~~~~~~~~~~^^^^^^
KeyError: 'this~2Eis~2Ea~2Etest'

This seems to impact insert and edit but not delete.

Running with pdb shows the error:

(Pdb) self.databases
OrderedDict([('this.is.a.test', <Database: this.is.a.test (mutable, size=8192)>)])

get_database needs to be passed the URLDecoded database name.

https://github.com/datasette/datasette-write-ui/blob/main/datasette_write_ui/__init__.py#L151

@voltagex voltagex changed the title Database with dot in filename causes errors, URL encoding issue Database with dot in filename causes errors, tilde encoding issue Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant