mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 06:35:57 -05:00
[smartpl] Fix bison parser regression, missing "starts with" syntax
Also adds "ends with" syntax just for good measure. Closes #1432
This commit is contained in:
parent
9d6eec3b18
commit
75f6f75da3
@ -50,14 +50,14 @@ Where valid field-names (with their types) are:
|
||||
* `random` (special)
|
||||
|
||||
Valid operators include:
|
||||
* `is`, `includes`, `starts with` (string)
|
||||
* `is`, `includes`, `starts with`, `ends with` (string)
|
||||
* `>`, `<`, `<=`, `>=`, `=` (int)
|
||||
* `after`, `before` (date)
|
||||
* `is` (enumeration)
|
||||
|
||||
The `is` operator must exactly match the field value, while the `includes` operator matches a substring.
|
||||
The `starts with` operator matches, if the value starts with the given prefix.
|
||||
All three matches are case-insensitive.
|
||||
The `starts with` operator matches, if the value starts with the given prefix,
|
||||
and `ends with` matches the opposite. All these matches are case-insensitive.
|
||||
|
||||
Valid operands include:
|
||||
* "string value" (string)
|
||||
|
@ -138,6 +138,8 @@ after { return (yylval->ival = SMARTPL_T_AFTER); }
|
||||
|
||||
is { return (yylval->ival = SMARTPL_T_IS); }
|
||||
includes { return (yylval->ival = SMARTPL_T_INCLUDES); }
|
||||
starts\ with { return (yylval->ival = SMARTPL_T_STARTSWITH); }
|
||||
ends\ with { return (yylval->ival = SMARTPL_T_ENDSWITH); }
|
||||
= { return (yylval->ival = SMARTPL_T_EQUAL); }
|
||||
\<= { return (yylval->ival = SMARTPL_T_LESSEQUAL); }
|
||||
\< { return (yylval->ival = SMARTPL_T_LESS); }
|
||||
|
@ -301,10 +301,10 @@ static void sql_append_recursive(struct smartpl_result *result, struct result_pa
|
||||
break;
|
||||
case SQL_APPEND_OPERATOR_LIKE:
|
||||
sql_from_ast(result, part, a->l);
|
||||
sql_append(result, part, " %s '%%", is_not ? op_not : op);
|
||||
sql_append(result, part, " %s '%s", is_not ? op_not : op, a->type == SMARTPL_T_STARTSWITH ? "" : "%");
|
||||
sql_like_escape((char **)(&a->r->data), &escape_char);
|
||||
sql_from_ast(result, part, a->r);
|
||||
sql_append(result, part, "%%'");
|
||||
sql_append(result, part, "%s'", a->type == SMARTPL_T_ENDSWITH ? "" : "%");
|
||||
if (escape_char)
|
||||
sql_append(result, part, " ESCAPE '%c'", escape_char);
|
||||
break;
|
||||
@ -379,6 +379,8 @@ static void sql_from_ast(struct smartpl_result *result, struct result_part *part
|
||||
case SMARTPL_T_IS:
|
||||
sql_append_recursive(result, part, a, "=", "!=", is_not, SQL_APPEND_OPERATOR_STR); break;
|
||||
case SMARTPL_T_INCLUDES:
|
||||
case SMARTPL_T_STARTSWITH:
|
||||
case SMARTPL_T_ENDSWITH:
|
||||
sql_append_recursive(result, part, a, "LIKE", "NOT LIKE", is_not, SQL_APPEND_OPERATOR_LIKE); break;
|
||||
case SMARTPL_T_BEFORE:
|
||||
sql_append_recursive(result, part, a, "<", ">=", is_not, SQL_APPEND_OPERATOR); break;
|
||||
@ -517,6 +519,8 @@ static int result_set(struct smartpl_result *result, char *title, struct ast *cr
|
||||
set to the token value by the lexer. */
|
||||
%token <ival> SMARTPL_T_IS
|
||||
%token <ival> SMARTPL_T_INCLUDES
|
||||
%token <ival> SMARTPL_T_STARTSWITH
|
||||
%token <ival> SMARTPL_T_ENDSWITH
|
||||
%token <ival> SMARTPL_T_EQUAL
|
||||
%token <ival> SMARTPL_T_LESS
|
||||
%token <ival> SMARTPL_T_LESSEQUAL
|
||||
@ -629,6 +633,8 @@ limit: SMARTPL_T_LIMIT SMARTPL_T_NUM { $$ = ast_int(SMART
|
||||
|
||||
strbool: SMARTPL_T_IS
|
||||
| SMARTPL_T_INCLUDES
|
||||
| SMARTPL_T_STARTSWITH
|
||||
| SMARTPL_T_ENDSWITH
|
||||
;
|
||||
|
||||
intbool: SMARTPL_T_EQUAL
|
||||
|
Loading…
Reference in New Issue
Block a user