mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-23 20:53:19 -05:00
DMAP comparison against empty string needs to check against NULL too
'dmap.foo!:' -> (dmap.foo <> '' AND dmap.foo IS NOT NULL) 'dmap.foo:' -> (dmap.foo = '' OR dmap.foo IS NULL)
This commit is contained in:
parent
8025db2dc2
commit
ff03c2679d
@ -162,13 +162,20 @@ expr returns [ pANTLR3_STRING result, int valid ]
|
||||
}
|
||||
|
||||
/* Empty values OK for string fields, NOK for integer */
|
||||
if ((*val == '\0') && (dqfm->as_int))
|
||||
if (*val == '\0')
|
||||
{
|
||||
if (dqfm->as_int)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DAAP, "No value given in clause '\%s\%s\%c'\n", field, (neg_op) ? "!" : "", op);
|
||||
$valid = 0;
|
||||
goto STR_result_valid_0; /* ABORT */
|
||||
}
|
||||
|
||||
/* Need to check against NULL too */
|
||||
if (op == ':')
|
||||
$result->append8($result, "(");
|
||||
}
|
||||
|
||||
$result->append8($result, dqfm->db_col);
|
||||
|
||||
/* Int field: check integer conversion */
|
||||
@ -274,6 +281,24 @@ expr returns [ pANTLR3_STRING result, int valid ]
|
||||
if (!dqfm->as_int)
|
||||
$result->append8($result, "'");
|
||||
|
||||
/* For empty string value, we need to check against NULL too */
|
||||
if ((*val == '\0') && (op == ':'))
|
||||
{
|
||||
if (neg_op)
|
||||
$result->append8($result, " AND ");
|
||||
else
|
||||
$result->append8($result, " OR ");
|
||||
|
||||
$result->append8($result, dqfm->db_col);
|
||||
|
||||
if (neg_op)
|
||||
$result->append8($result, " IS NOT NULL");
|
||||
else
|
||||
$result->append8($result, " IS NULL");
|
||||
|
||||
$result->append8($result, ")");
|
||||
}
|
||||
|
||||
STR_result_valid_0: /* bail out label */
|
||||
;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user