diff options
Diffstat (limited to 'database/sqlite')
| -rw-r--r-- | database/sqlite/sqlite.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/database/sqlite/sqlite.c b/database/sqlite/sqlite.c index 247bff4..3075efb 100644 --- a/database/sqlite/sqlite.c +++ b/database/sqlite/sqlite.c @@ -346,14 +346,19 @@ char *_build_sqlpart(int btyp, eDBfieldMap *map) { case btINSERT: // (field_name, field_name, field_name) VALUES ('val','val','val') memset(&fields, 0, 4090); + first = 1; for( ptr = map; ptr != NULL; ptr = ptr->next ) { char *val = NULL; + // If the value is NULL, ignore it + if( ptr->value == NULL ) { + continue; + } + // Put separator in front of values and field names - if( first != 1 ) { + if( first == 0 ) { append_str(fields, ",", 8192); append_str(vals, ",", 8192); - first = 0; } // Append the current field name and value to each string @@ -361,6 +366,7 @@ char *_build_sqlpart(int btyp, eDBfieldMap *map) { val = _build_value_string(ptr); append_str(vals, val, 4092); sqlite3_free(val); + first = 0; } // Put all the pieces together |
