d2sqlite3 icon indicating copy to clipboard operation
d2sqlite3 copied to clipboard

Bind to empty string results in a bind to null

Open schveiguy opened this issue 1 year ago • 0 comments

If I bind an empty string which happens to point at null, the sqlite3 C library thinks I am setting it to null.

Given how the d2sqlite3 library tries at all costs to build a string if the thing isn't exactly a string, this results in it being very likely the pointer will be null.

Read this note from sqlite.org

The third argument is the value to bind to the parameter. If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16() or sqlite3_bind_blob() is a NULL pointer then the fourth parameter is ignored and the end result is the same as sqlite3_bind_null()

This is causing problems where I'm saving a string that is empty in a non-null field. The library should pass in a non-null pointer when the pointer is null and the length is 0 to avoid this situation.

schveiguy avatar Jan 02 '24 02:01 schveiguy