From: Sebastian Harl Date: Tue, 14 Oct 2014 07:16:09 +0000 (+0200) Subject: frontend/grammar: Added (limited) support for attribute values in expressions. X-Git-Tag: sysdb-0.6.0~121 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=64c09eee7ba3f1c811c06b46e060fe22b98b8276;p=sysdb.git frontend/grammar: Added (limited) support for attribute values in expressions. This is not fully supported yet as expressions may not be used in all places yet. --- diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 6aa4095..0c9d361 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -1007,9 +1007,8 @@ sdb_store_matcher_parse_cmp(const char *obj_type, const char *attr, if (! expr) return NULL; - if (sdb_store_expr_eval(expr, NULL, &value)) - return NULL; - if (value.type != SDB_TYPE_STRING) { + if (sdb_store_expr_eval(expr, NULL, &value) || + (value.type != SDB_TYPE_STRING)) { sdb_data_free_datum(&value); if (type != SDB_ATTRIBUTE) return NULL; diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 93616ac..0f01bd3 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -495,6 +495,13 @@ expression: $$ = sdb_store_expr_fieldvalue(field); } | + IDENTIFIER '[' IDENTIFIER ']' + { + $$ = sdb_store_expr_attrvalue($3); + free($1); $1 = NULL; + free($3); $3 = NULL; + } + | data { $$ = sdb_store_expr_constvalue(&$1);