diff --git a/db_author.c b/db_author.c index c8eaf24..9e8ac9e 100644 --- a/db_author.c +++ b/db_author.c @@ -92,10 +92,14 @@ static int query_authors(const char* sort, const char *order) { int query = STMT_AUTHORS_ID_ASC; - if (NULL != sort && 0 == strcmp(sort, "name")) + if (NULL != sort && 0 == strcmp(sort, "name")) { query = STMT_AUTHORS_NAME_ASC; - if (NULL != order && 0 == strcmp(order, "desc")) - query++; + if (NULL != order && 0 == strcmp(order, "desc")) + query++; + } else { + if (NULL == order || 0 == strcmp(order, "desc")) + query++; + } return query; } diff --git a/db_book.c b/db_book.c index a7c2c2f..fe95f0f 100644 --- a/db_book.c +++ b/db_book.c @@ -255,10 +255,14 @@ static int query_books(const char* sort, const char *order) { int query = STMT_BOOKS_ID_ASC; - if (NULL != sort && 0 == strcmp(sort, "title")) + if (NULL != sort && 0 == strcmp(sort, "title")) { query = STMT_BOOKS_TITLE_ASC; - if (NULL != order && 0 == strcmp(order, "desc")) - query++; + if (NULL != order && 0 == strcmp(order, "desc")) + query++; + } else { + if (NULL == order || 0 == strcmp(order, "desc")) + query++; + } return query; } @@ -266,10 +270,14 @@ static int query_books_authors(const char* sort, const char *order) { int query = STMT_BOOKS_AUTHORS_ID_ASC; - if (NULL != sort && 0 == strcmp(sort, "title")) + if (NULL != sort && 0 == strcmp(sort, "title")) { query = STMT_BOOKS_AUTHORS_TITLE_ASC; - if (NULL != order && 0 == strcmp(order, "desc")) - query++; + if (NULL != order && 0 == strcmp(order, "desc")) + query++; + } else { + if (NULL == order || 0 == strcmp(order, "desc")) + query++; + } return query; } @@ -277,10 +285,14 @@ static int query_books_tags(const char* sort, const char *order) { int query = STMT_BOOKS_TAGS_ID_ASC; - if (NULL != sort && 0 == strcmp(sort, "title")) + if (NULL != sort && 0 == strcmp(sort, "title")) { query = STMT_BOOKS_TAGS_TITLE_ASC; - if (NULL != order && 0 == strcmp(order, "desc")) - query++; + if (NULL != order && 0 == strcmp(order, "desc")) + query++; + } else { + if (NULL == order || 0 == strcmp(order, "desc")) + query++; + } return query; } diff --git a/db_series.c b/db_series.c index f5853f7..c2214a3 100644 --- a/db_series.c +++ b/db_series.c @@ -124,10 +124,14 @@ static int query_series(const char* sort, const char *order) { int query = STMT_SERIES_ID_ASC; - if (NULL != sort && 0 == strcmp(sort, "name")) + if (NULL != sort && 0 == strcmp(sort, "name")) { query = STMT_SERIES_NAME_ASC; - if (NULL != order && 0 == strcmp(order, "desc")) - query++; + if (NULL != order && 0 == strcmp(order, "desc")) + query++; + } else { + if (NULL == order || 0 == strcmp(order, "desc")) + query++; + } return query; } @@ -135,10 +139,14 @@ static int query_seriesauth(const char* sort, const char *order) { int query = STMT_SERIES_AUTHORS_ID_ASC; - if (NULL != sort && 0 == strcmp(sort, "name")) + if (NULL != sort && 0 == strcmp(sort, "name")) { query = STMT_SERIES_AUTHORS_NAME_ASC; - if (NULL != order && 0 == strcmp(order, "desc")) - query++; + if (NULL != order && 0 == strcmp(order, "desc")) + query++; + } else { + if (NULL == order || 0 == strcmp(order, "desc")) + query++; + } return query; }