Inserting None results in panic
Closed this issue · 4 comments
bensengupta commented
Inserting None into a table appears to throw an exception. Is there a different way to insert a NULL value into a row or is this not supported?
import libsql_experimental as libsql
conn = libsql.connect("test.db")
conn.executescript(
"""
DROP TABLE IF EXISTS users;
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);
"""
)
conn.execute("INSERT INTO test (name) VALUES (?)", (None,))results in the following error
thread '<unnamed>' panicked at src/lib.rs:411:39:
not yet implemented
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/home/ben/projects/libsql_bug/main.py", line 12, in <module>
conn.execute("INSERT INTO test (name) VALUES (?)", (None,))
pyo3_runtime.PanicException: not yet implemented
PrinceBaghel258025 commented
notrab commented
Hey @PrinceBaghel258025, sorry for the delay here.
What happens if you just pass NULL instead of None?
conn.execute("INSERT INTO test (name) VALUES (NULL)")Or:
conn.execute("INSERT INTO users (name) VALUES (?)", ("",))Or:
conn.execute("INSERT INTO users DEFAULT VALUES")leonardo-blas commented
@notrab, "" works for me. Should we expect explicit NoneType support?
Thanks a lot in advance
notrab commented
@leonardo-blas I pushed a branch with a simple fix to accept None. @penberg and @levydsa might have some further change requests.