Skip to content

Allow dot and slash as message identifier #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2019

Conversation

garaemon
Copy link
Contributor

@garaemon garaemon commented May 2, 2019

line protocol can include '/' and '.' without double quotes. (confirmed on influxdb 1.7.6)

@d-led d-led merged commit 88f73ac into d-led:master May 2, 2019
@d-led
Copy link
Owner

d-led commented May 2, 2019

looks good, merging. Thanks you, @garaemon !

Would you like to add an extra test case for a round-trip with the message identifier containing the two characters?

@d-led
Copy link
Owner

d-led commented May 2, 2019

ok. it's not symmetric:

> INSERT weather,location=us-midwest temperature=82 1465839830100400200
> INSERT weather.test,location=us-midwest temperature=82 1465839830100400200
> INSERT weather.test/test,location=us-midwest temperature=82 1465839830100400200
> show measurements
name: measurements
name
----
weather
weather.test
weather.test/test
> select * from weather.test
ERR: retention policy not found: weather
> select * from "weather.test"
name: weather.test
time                location   temperature
----                --------   -----------
1465839830100400200 us-midwest 82

so, a test would have been worth it. The usage will need asymmetric handling: the two special characters are ok in insertion statements, but not in the queries

The docs say:

Note that you will also need to wrap identifiers in double quotes in queries if they contain characters other than [A-z,_]

> create database test.test
ERR: error parsing query: found ., expected ; at line 1, char 21
> create database "test.test"
>

I'll have to revert the change, as other parts of the API use the same validation. It's simpler to just put quotes at the usage sites. If you wish, you may try creating a new patch, including tests, which will also test database creation with special characters (check that it throws on no quotes, and doesn't with, checking that the DB exists and is queryable).

The test I wrote for your patch was:

TEST_CASE_METHOD(simple_connected_test, "inserting values into measurements with '.' and '//' the identifier", "[connected]") {
    // line protocols allows some freedom in the identifiers
    db.insert(line("test.test/test", key_value_pairs("mytag", 424242L), key_value_pairs("value", "hello world!")));

    wait_for([] {return false; }, 3);

    // queries need quotes for complex identifiers
    CHECK_THROWS(result("test.test/test"));
    auto res = result("\"test.test/test\"");
    CHECK(res.contains("424242i"));
    CHECK(res.contains("mytag"));
    CHECK(res.contains("hello world!"));
}

d-led added a commit that referenced this pull request May 2, 2019
This reverts commit 88f73ac, reversing
changes made to 6d3103e.
@garaemon
Copy link
Contributor Author

garaemon commented May 3, 2019

Oh, I understood the asymmetry of API.

I will create another patch to separate validation code for insert, query and create database with tests and please check it if it is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants