GNOME Bugzilla – Bug 754238
[sqlite3] vapi throws error in strict non-null mode
Last modified: 2016-09-12 10:24:58 UTC
Compiling an application of mine with the valac flags `--pkg sqlite3` and `--enable-experimental-non-null` results in the following error: sqlite3.vapi:58.78-58.94: error: Argument 5: Cannot convert from `string?' to `string' var ec = this._get_table (sql, out sqlite_resultp, out nrow, out ncolumn, out sqlite_errmsg); ^^^^^^^^^^^^^^^^^ Package vala-0.28.1-1 on Fedora 22
Also, as far as I can tell some of the function signatures are incorrect. For example, I believe this signature from Sqlite.Statement: public unowned string column_text (int col) Might more accurately be: public unowned string? column_text (int col) as I have had this return null previously. This of course further invalidates my application insofar as valac is concerned as logic checking for a null value is flagged as an invalid equality operation
Created attachment 313052 [details] [review] Proposed patch Managed to get around fixing the issue. Statement.column_text() seems to really return null at times, so I guess the return value should be a nullable string here.
Review of attachment 313052 [details] [review]: For sqlite3_exec the patch matches the documentation at https://www.sqlite.org/capi3ref.html#sqlite3_exec "If the 5th parameter to sqlite3_exec() is not NULL and no errors occur, then sqlite3_exec() sets the pointer in its 5th parameter to NULL before returning." For get_table the direct binding already makes errmsg nullable and this patch corrects the Vala wrapper to match that. For sqlite3_column_text the patch matches the documentation at https://www.sqlite.org/capi3ref.html#sqlite3_column_blob If the internal type is NULL and the requested type is TEXT then the result is a null pointer. Patch applies and looks good to me.