diff --git a/src/db.c b/src/db.c index 85d58088..5e666d1b 100644 --- a/src/db.c +++ b/src/db.c @@ -178,7 +178,7 @@ static const struct col_type_map pli_cols_map[] = { pli_offsetof(virtual_path), DB_TYPE_STRING }, { pli_offsetof(parent_id), DB_TYPE_INT }, { pli_offsetof(directory_id), DB_TYPE_INT }, - { pli_offsetof(query_orderby),DB_TYPE_STRING }, + { pli_offsetof(query_order),DB_TYPE_STRING }, { pli_offsetof(query_limit), DB_TYPE_INT }, /* items is computed on the fly */ @@ -270,7 +270,7 @@ static const ssize_t dbpli_cols_map[] = dbpli_offsetof(virtual_path), dbpli_offsetof(parent_id), dbpli_offsetof(directory_id), - dbpli_offsetof(query_orderby), + dbpli_offsetof(query_order), dbpli_offsetof(query_limit), /* items is computed on the fly */ @@ -585,7 +585,7 @@ free_query_params(struct query_params *qp, int content_only) free(qp->filter); free(qp->having); - free(qp->orderby); + free(qp->order); if (!content_only) free(qp); @@ -1439,8 +1439,8 @@ db_build_query_clause(struct query_params *qp) else qc->having = sqlite3_mprintf(""); - if (qp->orderby) - qc->order = sqlite3_mprintf("ORDER BY %s", qp->orderby); + if (qp->order) + qc->order = sqlite3_mprintf("ORDER BY %s", qp->order); else if (qp->sort) qc->order = sqlite3_mprintf("ORDER BY %s", sort_clause[qp->sort]); else if (qp->type & Q_F_BROWSE) @@ -1614,11 +1614,11 @@ db_build_query_plitems_smart(struct query_params *qp, struct playlist_info *pli) } } - if (pli->query_orderby) + if (pli->query_order) { - if (!qp->orderby && qp->sort == S_NONE) + if (!qp->order && qp->sort == S_NONE) { - qp->orderby = strdup(pli->query_orderby); + qp->order = strdup(pli->query_order); free_orderby = true; } else @@ -1628,8 +1628,8 @@ db_build_query_plitems_smart(struct query_params *qp, struct playlist_info *pli) qc = db_build_query_clause(qp); if (free_orderby) { - free(qp->orderby); - qp->orderby = NULL; + free(qp->order); + qp->order = NULL; } if (!qc) return NULL; @@ -3425,7 +3425,7 @@ db_pl_add(struct playlist_info *pli, int *id) { #define QDUP_TMPL "SELECT COUNT(*) FROM playlists p WHERE p.title = TRIM(%Q) AND p.path = '%q';" #define QADD_TMPL "INSERT INTO playlists (title, type, query, db_timestamp, disabled, path, idx, special_id, " \ - " parent_id, virtual_path, directory_id, query_orderby, query_limit)" \ + " parent_id, virtual_path, directory_id, query_order, query_limit)" \ " VALUES (TRIM(%Q), %d, '%q', %" PRIi64 ", %d, '%q', %d, %d, %d, '%q', %d, %Q, %d);" char *query; char *errmsg; @@ -3453,7 +3453,7 @@ db_pl_add(struct playlist_info *pli, int *id) query = sqlite3_mprintf(QADD_TMPL, pli->title, pli->type, pli->query, (int64_t)time(NULL), pli->disabled, STR(pli->path), pli->index, pli->special_id, pli->parent_id, pli->virtual_path, pli->directory_id, - pli->query_orderby, pli->query_limit); + pli->query_order, pli->query_limit); if (!query) { @@ -3519,7 +3519,7 @@ db_pl_update(struct playlist_info *pli) { #define Q_TMPL "UPDATE playlists SET title = TRIM(%Q), type = %d, query = '%q', db_timestamp = %" PRIi64 ", disabled = %d, " \ " path = '%q', idx = %d, special_id = %d, parent_id = %d, virtual_path = '%q', directory_id = %d, " \ - " query_orderby = %Q, query_limit = %d " \ + " query_order = %Q, query_limit = %d " \ " WHERE id = %d;" char *query; int ret; @@ -3527,7 +3527,7 @@ db_pl_update(struct playlist_info *pli) query = sqlite3_mprintf(Q_TMPL, pli->title, pli->type, pli->query, (int64_t)time(NULL), pli->disabled, STR(pli->path), pli->index, pli->special_id, pli->parent_id, pli->virtual_path, pli->directory_id, - pli->query_orderby, pli->query_limit, pli->id); + pli->query_order, pli->query_limit, pli->id); ret = db_query_run(query, 1, 0); diff --git a/src/db.h b/src/db.h index 6de25475..96a88b3c 100644 --- a/src/db.h +++ b/src/db.h @@ -92,7 +92,7 @@ struct query_params { int limit; char *having; - char *orderby; + char *order; char *filter; @@ -247,7 +247,7 @@ struct playlist_info { char *virtual_path; /* virtual path of underlying playlist */ uint32_t parent_id; /* Id of parent playlist if the playlist is nested */ uint32_t directory_id; /* Id of directory */ - char *query_orderby; /* order by clause if it is a smart playlist */ + char *query_order; /* order by clause if it is a smart playlist */ uint32_t query_limit; /* limit if it is a smart playlist */ }; @@ -268,7 +268,7 @@ struct db_playlist_info { char *virtual_path; char *parent_id; char *directory_id; - char *query_orderby; + char *query_order; char *query_limit; }; diff --git a/src/db_init.c b/src/db_init.c index 5c6b48b9..d23c5510 100644 --- a/src/db_init.c +++ b/src/db_init.c @@ -110,7 +110,7 @@ " virtual_path VARCHAR(4096)," \ " parent_id INTEGER DEFAULT 0," \ " directory_id INTEGER DEFAULT 0," \ - " query_orderby VARCHAR(1024)," \ + " query_order VARCHAR(1024)," \ " query_limit INTEGER DEFAULT 0" \ ");" diff --git a/src/db_upgrade.c b/src/db_upgrade.c index 9c815841..73c083f9 100644 --- a/src/db_upgrade.c +++ b/src/db_upgrade.c @@ -1634,8 +1634,8 @@ static const struct db_upgrade_query db_upgrade_V1907_queries[] = }; -#define U_V1908_ALTER_PL_ADD_ORDERBY \ - "ALTER TABLE playlists ADD COLUMN query_orderby VARCHAR(1024);" +#define U_V1908_ALTER_PL_ADD_ORDER \ + "ALTER TABLE playlists ADD COLUMN query_order VARCHAR(1024);" #define U_V1908_ALTER_PL_ADD_LIMIT \ "ALTER TABLE playlists ADD COLUMN query_limit INTEGER DEFAULT 0;" @@ -1644,7 +1644,7 @@ static const struct db_upgrade_query db_upgrade_V1907_queries[] = static const struct db_upgrade_query db_upgrade_v1908_queries[] = { - { U_V1908_ALTER_PL_ADD_ORDERBY, "alter table playlists add column query_orderby" }, + { U_V1908_ALTER_PL_ADD_ORDER, "alter table playlists add column query_order" }, { U_V1908_ALTER_PL_ADD_LIMIT, "alter table playlists add column query_limit" }, { U_V1908_SCVER_MINOR, "set schema_version_minor to 08" }, diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index ed9f1bee..75a6284a 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -2369,7 +2369,7 @@ search_tracks(json_object *reply, struct httpd_request *hreq, const char *param_ else { query_params.filter = strdup(smartpl_expression->query_where); - query_params.orderby = safe_strdup(smartpl_expression->order_by); + query_params.order = safe_strdup(smartpl_expression->order); if (smartpl_expression->limit > 0) { @@ -2428,7 +2428,7 @@ search_artists(json_object *reply, struct httpd_request *hreq, const char *param { query_params.filter = strdup(smartpl_expression->query_where); query_params.having = safe_strdup(smartpl_expression->having); - query_params.orderby = safe_strdup(smartpl_expression->order_by); + query_params.order = safe_strdup(smartpl_expression->order); if (smartpl_expression->limit > 0) { @@ -2487,7 +2487,7 @@ search_albums(json_object *reply, struct httpd_request *hreq, const char *param_ { query_params.filter = strdup(smartpl_expression->query_where); query_params.having = safe_strdup(smartpl_expression->having); - query_params.orderby = safe_strdup(smartpl_expression->order_by); + query_params.order = safe_strdup(smartpl_expression->order); if (smartpl_expression->limit > 0) { diff --git a/src/library/filescanner_smartpl.c b/src/library/filescanner_smartpl.c index 841593e4..760e17cb 100644 --- a/src/library/filescanner_smartpl.c +++ b/src/library/filescanner_smartpl.c @@ -86,8 +86,8 @@ scan_smartpl(const char *file, time_t mtime, int dir_id) free(pli->query); pli->query = strdup(smartpl.query_where); - free(pli->query_orderby); - pli->query_orderby = safe_strdup(smartpl.order_by); + free(pli->query_order); + pli->query_order = safe_strdup(smartpl.order); pli->query_limit = smartpl.limit; diff --git a/src/smartpl_query.c b/src/smartpl_query.c index b85820af..4841d62f 100644 --- a/src/smartpl_query.c +++ b/src/smartpl_query.c @@ -135,9 +135,9 @@ parse_input(struct smartpl *smartpl, pANTLR3_INPUT_STREAM input) free(smartpl->having); smartpl->having = safe_strdup((char *)plreturn.having->chars); - if (smartpl->order_by) - free(smartpl->order_by); - smartpl->order_by = safe_strdup((char *)plreturn.orderby->chars); + if (smartpl->order) + free(smartpl->order); + smartpl->order = safe_strdup((char *)plreturn.orderby->chars); smartpl->limit = plreturn.limit; @@ -224,7 +224,7 @@ free_smartpl(struct smartpl *smartpl, int content_only) free(smartpl->title); free(smartpl->query_where); free(smartpl->having); - free(smartpl->order_by); + free(smartpl->order); if (!content_only) free(smartpl); diff --git a/src/smartpl_query.h b/src/smartpl_query.h index ab4c6169..532880cd 100644 --- a/src/smartpl_query.h +++ b/src/smartpl_query.h @@ -7,7 +7,7 @@ struct smartpl { char *title; char *query_where; char *having; - char *order_by; + char *order; int limit; };