libsql-experimental-python icon indicating copy to clipboard operation
libsql-experimental-python copied to clipboard

Inserting None results in panic

Open bensengupta opened this issue 1 year ago • 2 comments

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

bensengupta avatar Mar 20 '24 20:03 bensengupta

@penberg @notrab Please look into this guys

PrinceBaghel258025 avatar Aug 16 '24 07:08 PrinceBaghel258025

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")

notrab avatar Aug 16 '24 13:08 notrab

@notrab, "" works for me. Should we expect explicit NoneType support? Thanks a lot in advance

leonardo-blas avatar Oct 30 '24 00:10 leonardo-blas

@leonardo-blas I pushed a branch with a simple fix to accept None. @penberg and @levydsa might have some further change requests.

notrab avatar Oct 30 '24 10:10 notrab