From 4f754d27ca890398c2477c0748a08b38790e722d Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 6 Oct 2014 08:24:13 +0200 Subject: [PATCH] frontend/grammar: Use '.' instead of ':' to access queryable object fields. --- src/frontend/grammar.y | 4 ++-- t/integration/simple_query.sh | 8 ++++---- t/unit/core/store_lookup_test.c | 2 +- t/unit/frontend/parser_test.c | 28 ++++++++++++++-------------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 08f8414..9cf98ee 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -398,7 +398,7 @@ matcher: * Parse matchers comparing object attributes with a value. */ compare_matcher: - ':' IDENTIFIER op expression + '.' IDENTIFIER op expression { $$ = sdb_store_matcher_parse_field_cmp($2, $3, $4); free($2); $2 = NULL; @@ -481,7 +481,7 @@ expression: sdb_object_deref(SDB_OBJ($3)); $3 = NULL; } | - ':' IDENTIFIER + '.' IDENTIFIER { int field = sdb_store_parse_field_name($2); free($2); $2 = NULL; diff --git a/t/integration/simple_query.sh b/t/integration/simple_query.sh index 1e1028c..677ce2f 100755 --- a/t/integration/simple_query.sh +++ b/t/integration/simple_query.sh @@ -139,7 +139,7 @@ echo "$output" | grep -F 'host2.example.com' && exit 1 output="$( run_sysdb -H "$SOCKET_FILE" \ -c "LOOKUP hosts MATCHING attribute != 'architecture' - FILTER :age >= 0s" )" + FILTER .age >= 0s" )" echo "$output" \ | grep -F '"some.host.name"' \ | grep -F '"localhost"' @@ -149,11 +149,11 @@ echo "$output" | grep -F 'host2.example.com' && exit 1 output="$( run_sysdb -H "$SOCKET_FILE" \ -c "LOOKUP hosts MATCHING attribute != 'architecture' - FILTER :last_update < 2Y" )" + FILTER .last_update < 2Y" )" echo $output | grep -E '^\[\]$' output="$( run_sysdb -H "$SOCKET_FILE" \ - -c "LOOKUP hosts FILTER :backend = 'backend::mock_plugin'" )" + -c "LOOKUP hosts FILTER .backend = 'backend::mock_plugin'" )" echo "$output" \ | grep -F '"host1.example.com"' \ | grep -F '"host2.example.com"' \ @@ -161,7 +161,7 @@ echo "$output" \ | grep -F '"other.host.name"' \ | grep -F '"some.host.name"' output="$( run_sysdb -H "$SOCKET_FILE" \ - -c "LOOKUP hosts FILTER :backend = 'invalid'" )" + -c "LOOKUP hosts FILTER .backend = 'invalid'" )" echo $output | grep -E '^\[\]$' output="$( run_sysdb -H "$SOCKET_FILE" \ diff --git a/t/unit/core/store_lookup_test.c b/t/unit/core/store_lookup_test.c index af680f0..e5a0a74 100644 --- a/t/unit/core/store_lookup_test.c +++ b/t/unit/core/store_lookup_test.c @@ -695,7 +695,7 @@ START_TEST(test_parse_field_cmp) { "interval", "!=", &datetime, MATCHER_NOT }, { "backend", "=", &string, MATCHER_EQ }, { "backend", "!=", &string, MATCHER_NOT }, - /* the behavior for other operators on :backend + /* the behavior for other operators on .backend * is currently unspecified */ { "last_update", "=", NULL, -1 }, { "last_update", "IS", NULL, -1 }, diff --git a/t/unit/frontend/parser_test.c b/t/unit/frontend/parser_test.c index 1412ee5..7560a5f 100644 --- a/t/unit/frontend/parser_test.c +++ b/t/unit/frontend/parser_test.c @@ -90,18 +90,18 @@ START_TEST(test_parse) "service =~ 'r'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " "host =~ 'p' " - "FILTER :age > 1D", -1, 1, CONNECTION_LOOKUP }, + "FILTER .age > 1D", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " "host =~ 'p' " - "FILTER :age > 1D AND " - ":interval < 240s" , -1, 1, CONNECTION_LOOKUP }, + "FILTER .age > 1D AND " + ".interval < 240s" , -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " "host =~ 'p' " - "FILTER NOT :age>1D", -1, 1, CONNECTION_LOOKUP }, + "FILTER NOT .age>1D", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " "host =~ 'p' " - "FILTER :age>" - ":interval", -1, 1, CONNECTION_LOOKUP }, + "FILTER .age>" + ".interval", -1, 1, CONNECTION_LOOKUP }, { "TIMESERIES 'host'.'metric' " "START 2014-01-01 " @@ -341,14 +341,14 @@ START_TEST(test_parse_matcher) { "attribute[foo] IS NOT NULL", -1, MATCHER_NOT }, /* object field matchers */ - { ":last_update < 10s", -1, MATCHER_LT }, - { ":AGE <= 1m", -1, MATCHER_LE }, - { ":interval = 10h", -1, MATCHER_EQ }, - { ":Last_Update >= 24D", -1, MATCHER_GE }, - { ":age > 1M", -1, MATCHER_GT }, - { ":age != 20Y", -1, MATCHER_NOT }, - { ":backend != 'be'", -1, MATCHER_NOT }, - { ":age <= 2 * :interval", -1, MATCHER_LE }, + { ".last_update < 10s", -1, MATCHER_LT }, + { ".AGE <= 1m", -1, MATCHER_LE }, + { ".interval = 10h", -1, MATCHER_EQ }, + { ".Last_Update >= 24D", -1, MATCHER_GE }, + { ".age > 1M", -1, MATCHER_GT }, + { ".age != 20Y", -1, MATCHER_NOT }, + { ".backend != 'be'", -1, MATCHER_NOT }, + { ".age <= 2 * .interval", -1, MATCHER_LE }, /* check operator precedence */ { "host = 'name' OR " -- 2.30.2