dlang-community / d2sqlite3

A small wrapper around SQLite for the D programming language
Boost Software License 1.0
75 stars 26 forks source link

Bind to empty string results in a bind to null #77

Open schveiguy opened 10 months ago

schveiguy commented 10 months ago

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.