Allow empty values in DMAP queries for string fields
This commit is contained in:
parent
371725b0da
commit
f56884015f
|
@ -136,28 +136,18 @@ expr returns [ pANTLR3_STRING result, int valid ]
|
|||
*val = '\0';
|
||||
val++;
|
||||
|
||||
if (op == '!')
|
||||
{
|
||||
if (*val == '\0')
|
||||
{
|
||||
if (op == '!')
|
||||
DPRINTF(E_LOG, L_DAAP, "Negation found but operator missing in clause '\%s\%c'\n", field, op);
|
||||
else
|
||||
DPRINTF(E_LOG, L_DAAP, "No value given in clause '\%s\%c'\n", field, op);
|
||||
$valid = 0;
|
||||
goto STR_result_valid_0; /* ABORT */
|
||||
}
|
||||
|
||||
if (op == '!')
|
||||
{
|
||||
neg_op = 1;
|
||||
op = *val;
|
||||
val++;
|
||||
|
||||
if (*val == '\0')
|
||||
{
|
||||
DPRINTF(E_LOG, L_DAAP, "No value given in clause '\%s!\%c'\n", field, op);
|
||||
$valid = 0;
|
||||
goto STR_result_valid_0; /* ABORT */
|
||||
}
|
||||
}
|
||||
else
|
||||
neg_op = 0;
|
||||
|
@ -171,6 +161,14 @@ expr returns [ pANTLR3_STRING result, int valid ]
|
|||
goto STR_result_valid_0; /* ABORT */
|
||||
}
|
||||
|
||||
/* Empty values OK for string fields, NOK for integer */
|
||||
if ((*val == '\0') && (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 */
|
||||
}
|
||||
|
||||
$result->append8($result, dqfm->db_col);
|
||||
|
||||
/* Int field: check integer conversion */
|
||||
|
@ -182,16 +180,16 @@ expr returns [ pANTLR3_STRING result, int valid ]
|
|||
if (((errno == ERANGE) && ((longval == LONG_MAX) || (longval == LONG_MIN)))
|
||||
|| ((errno != 0) && (longval == 0)))
|
||||
{
|
||||
DPRINTF(E_LOG, L_DAAP, "Value '\%s' in clause '\%s\%c\%s' does not convert to an integer type\n",
|
||||
val, field, op, val);
|
||||
DPRINTF(E_LOG, L_DAAP, "Value '\%s' in clause '\%s\%s\%c\%s' does not convert to an integer type\n",
|
||||
val, field, (neg_op) ? "!" : "", op, val);
|
||||
$valid = 0;
|
||||
goto STR_result_valid_0; /* ABORT */
|
||||
}
|
||||
|
||||
if (end == (char *)val)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DAAP, "Value '\%s' in clause '\%s\%c\%s' does not represent an integer value\n",
|
||||
val, field, op, val);
|
||||
DPRINTF(E_LOG, L_DAAP, "Value '\%s' in clause '\%s\%s\%c\%s' does not represent an integer value\n",
|
||||
val, field, (neg_op) ? "!" : "", op, val);
|
||||
$valid = 0;
|
||||
goto STR_result_valid_0; /* ABORT */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue