diff options
Diffstat (limited to 'database/sqlite/sqlite.c')
-rw-r--r-- | database/sqlite/sqlite.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/database/sqlite/sqlite.c b/database/sqlite/sqlite.c index 6021462..13a6f07 100644 --- a/database/sqlite/sqlite.c +++ b/database/sqlite/sqlite.c @@ -270,10 +270,10 @@ dbresult *sqlite_query(eurephiaCTX *ctx, const char *fmt, ... ) { if( strcasestr(sql, "INSERT INTO") != 0) { dbres->last_insert_id = sqlite3_last_insert_rowid((sqlite3 *) dbc->dbhandle); }; - if( strcasestr(sql, "SELECT ") == 0 ) { - // If not a SELECT query, then get the number of affected records - dbres->affected_rows = sqlite3_changes((sqlite3 *) dbc->dbhandle); - } + if( strcasestr(sql, "SELECT ") == 0 ) { + // If not a SELECT query, then get the number of affected records + dbres->affected_rows = sqlite3_changes((sqlite3 *) dbc->dbhandle); + } dbres->srch_tuples = dbres->tuples; dbres->srch_headerrec = dbres->headerrec; @@ -311,7 +311,7 @@ inline int SQLreservedWord(char **reserved_words, const char *val) { * * @return Returns a string to be used within an SQL query. */ -char *_build_value_string(eDBfieldMap *ptr) { +static char *_build_value_string(eDBfieldMap *ptr) { char *reserved_datetime[] = {"CURRENT_TIMESTAMP", "CURRENT_TIME", "CURRENT_DATE", NULL}; char *val = NULL; @@ -335,6 +335,10 @@ char *_build_value_string(eDBfieldMap *ptr) { val = sqlite3_mprintf("NULL"); break; + case ft_STRING_LOWER: + val = sqlite3_mprintf("lower('%q')", ptr->value); + break; + case ft_PASSWD: case ft_STRING: default: @@ -355,7 +359,7 @@ char *_build_value_string(eDBfieldMap *ptr) { * @return Returns a string with parts of the SQL query containing the dynamic variables on success, * otherwise NULL is returned. */ -char *_build_sqlpart(int btyp, eDBfieldMap *map) { +static char *_build_sqlpart(int btyp, eDBfieldMap *map) { eDBfieldMap *ptr = NULL; char *ret = NULL; char *fsep = NULL; @@ -393,7 +397,13 @@ char *_build_sqlpart(int btyp, eDBfieldMap *map) { append_str(buf, ptr->table_alias, 8192); append_str(buf, ".", 8192); } - append_str(buf, ptr->field_name, 8192); + if( (btyp == btWHERE) && ptr->field_type == ft_STRING_LOWER ) { + append_str(buf, "lower(", 8192); + append_str(buf, ptr->field_name, 8192); + append_str(buf, ")", 8192); + } else { + append_str(buf, ptr->field_name, 8192); + } switch( ptr->filter_type ) { case flt_LT: |