On 2015/11/16 7:59 PM, Igor Korot wrote:
> Stephan,
>
> On Mon, Nov 16, 2015 at 12:42 PM, Stephan Beal <sgbeal at googlemail.com>
> wrote:
>> On Mon, Nov 16, 2015 at 6:11 PM, Igor Korot <ikorot01 at gmail.com> wrote:
>>
>>> The variables referenced are defined as "std::string" and the code is in
>>> C++.
>>>
>> the std::string(char const *) constructor does not, last time i checked,
>> accept a NULL value. You will need to pass it "" in that case.
>>
>> [stephan at host:~/tmp]$ cat foo.cpp
>> #include <string>
>>
>> int main(){
>> std::string s(0);
>> return 0;
>> }
>>
>> [stephan at host:~/tmp]$ gcc -o foo foo.cpp -lstdc++
>> [stephan at host:~/tmp]$ ./foo
>> terminate called after throwing an instance of 'std::logic_error'
>> what(): basic_string::_S_construct null not valid
>> Aborted
> OK, it looks like the value is NULL instead of "".
> I will change the code accordingly.
>
> BTW, are only name, type and pk fields are guaranteed to have a value?
Nothing is guaranteed to have a value unless created with NOT NULL in
the field specification in the CREATE TABLE schema SQL.
Usually (in most DBs) a Primary key is guaranteed to not have NULL
values, but in SQLite it is permissible if the PK is not specifically
stated to be NOT NULL.