dbcli / dbcli/litecli

Using extension function in a VIEW causes exception to be printed

Đang mở
#265 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
3.3k
Fork
95
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

With current git:
```sql
.load ./crypto -- included in popular sqlean extension for sqlite

CREATE TABLE products (
product_id INTEGER PRIMARY KEY,
product_name TEXT NOT NULL
);

INSERT INTO products (product_name) VALUES ('Wireless Mouse');

CREATE VIEW v_hashed_product_id AS
SELECT
hex(crypto_blake3(product_id))
FROM products;
```

Running this in the REPL prints out this exception:
```python
File "site-packages/litecli/completion_refresher.py", line 85, in _bg_refresh
refresher(completer, executor)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "site-packages/litecli/completion_refresher.py", line 128, in refresh_tables
table_cols = list(executor.table_columns())
File "site-packages/litecli/sqlexecute.py", line 197, in table_columns
cur.execute(self.table_columns_query)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such function: crypto_blake3
```
but the view is created and works as expected.

Furthermore, existing and then opening the db in litecli also prints this exception:
```text
$ litecli ./my.db
File "site-packages/litecli/completion_refresher.py", line 85, in _bg_refresh
refresher(completer, executor)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "site-packages/litecli/completion_refresher.py", line 128, in refresh_tables
table_cols = list(executor.table_columns())
File "site-packages/litecli/sqlexecute.py", line 197, in table_columns
cur.execute(self.table_columns_query)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such function: crypto_blake3
my.db>
```

Here's a link to sqlean [binaries](https://github.com/nalgeon/sqlean/releases/latest) for testing.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start by examining `litecli/completion_refresher.py` and `litecli/sqlexecute.py`, especially the background refresh and `table_columns()` query mentioned in the traceback. Reproduce with a SQLite view that uses an extension function unavailable to the connection, or open a database with such a view. Done means the CLI no longer prints an exception during completion refresh while the view remains usable.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python, sqlite
Lĩnh vực
cli, database
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
66/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.