mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-29 00:23:23 -05:00
[smartpl] Support "starts with" operator for string fields
This commit is contained in:
parent
ea4ea072cd
commit
879307f3ac
@ -38,7 +38,7 @@ nexpr : NOT^ crit
|
|||||||
;
|
;
|
||||||
|
|
||||||
crit : LPAR expression RPAR -> expression
|
crit : LPAR expression RPAR -> expression
|
||||||
| STRTAG (INCLUDES|IS) STR
|
| STRTAG (INCLUDES|IS|STARTSWITH) STR
|
||||||
| INTTAG INTBOOL INT
|
| INTTAG INTBOOL INT
|
||||||
| DATETAG (AFTER|BEFORE) dateval
|
| DATETAG (AFTER|BEFORE) dateval
|
||||||
| ENUMTAG IS ENUMVAL
|
| ENUMTAG IS ENUMVAL
|
||||||
@ -85,6 +85,9 @@ INCLUDES : 'includes'
|
|||||||
IS : 'is'
|
IS : 'is'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
STARTSWITH : 'starts with'
|
||||||
|
;
|
||||||
|
|
||||||
INTBOOL : (GREATER|GREATEREQUAL|LESS|LESSEQUAL|EQUAL)
|
INTBOOL : (GREATER|GREATEREQUAL|LESS|LESSEQUAL|EQUAL)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -114,6 +114,20 @@ expression returns [ pANTLR3_STRING result ]
|
|||||||
$result->append8($result, sqlite3_mprintf("\%q", (const char *)val));
|
$result->append8($result, sqlite3_mprintf("\%q", (const char *)val));
|
||||||
$result->append8($result, "'");
|
$result->append8($result, "'");
|
||||||
}
|
}
|
||||||
|
| STRTAG STARTSWITH STR
|
||||||
|
{
|
||||||
|
pANTLR3_UINT8 val;
|
||||||
|
val = $STR.text->toUTF8($STR.text)->chars;
|
||||||
|
val++;
|
||||||
|
val[strlen((const char *)val) - 1] = '\0';
|
||||||
|
|
||||||
|
$result = $STR.text->factory->newRaw($STR.text->factory);
|
||||||
|
$result->append8($result, "f.");
|
||||||
|
$result->appendS($result, $STRTAG.text->toUTF8($STRTAG.text));
|
||||||
|
$result->append8($result, " LIKE '");
|
||||||
|
$result->append8($result, sqlite3_mprintf("\%q", (const char *)val));
|
||||||
|
$result->append8($result, "\%'");
|
||||||
|
}
|
||||||
| INTTAG INTBOOL INT
|
| INTTAG INTBOOL INT
|
||||||
{
|
{
|
||||||
$result = $INTTAG.text->factory->newRaw($INTTAG.text->factory);
|
$result = $INTTAG.text->factory->newRaw($INTTAG.text->factory);
|
||||||
|
Loading…
Reference in New Issue
Block a user