diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-18 18:46:26 +0100 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-18 18:46:26 +0100 |
commit | 0d765836d3ed7658ca6ca582c0176750d2b6921f (patch) | |
tree | 1ca5e62082a812e996817887afcf4e393a2d8ece /database/sqlite/sqlite.c | |
parent | 39cae7bac832d9e1279291dcf9e814d51ba97c9f (diff) | |
download | eurephia-0d765836d3ed7658ca6ca582c0176750d2b6921f.tar.gz eurephia-0d765836d3ed7658ca6ca582c0176750d2b6921f.tar.xz eurephia-0d765836d3ed7658ca6ca582c0176750d2b6921f.zip |
sqlite - BUGFIX: Fixed INSERT INTO statements when using sqlite_query_mapped(...)
Diffstat (limited to 'database/sqlite/sqlite.c')
-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 |