Skip to content

Spaces and double quotes #52

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

Closed
satirebird opened this issue Feb 29, 2020 · 2 comments · Fixed by #55
Closed

Spaces and double quotes #52

satirebird opened this issue Feb 29, 2020 · 2 comments · Fixed by #55

Comments

@satirebird
Copy link

I have some trouble with spaces in the tags. The following code results in an error:

let write_query = WriteQuery::new(Timestamp::Now, "temperature")
    .add_field("value", 25)
    .add_tag("tag1", "ABC DEF".to_string());

The error contains: Err(DatabaseError { error: "influxdb error: \"{\"error\":\"unable to parse \'temperature,tag1=\\\"ABC DEF\\\" value=25\': invalid field format\"}\n\"" })

By replacing the spaces with a backslash influxdb accepts the request:

let write_query = WriteQuery::new(Timestamp::Now, "temperature")
    .add_field("value", 25)
    .add_tag("tag1", "ABC DEF".replace(" ", "\\ "));

The second issue is that the influxdb stores the double quotes of the tags as follows:

time                tag1                   value
----                ---                    -----
1583008260693608605 "ABC DEF"              25

If I use the python influxdb client the double quotes are not stored. So I tested it without surrounding double quotes. I changed write_query.rs as follows:

-Text(text) => write!(f, "\"{text}\"", text = text),
+Text(text) => write!(f, "{text}", text = text),

It works as expected. So I guess that the spaces must be handled by escaping with backslash instead of surrounding with quotes.

influxdb version is 1.3.6-1

@satirebird satirebird changed the title Space and double quotes Spaces and double quotes Mar 1, 2020
@Empty2k12
Copy link
Collaborator

Empty2k12 commented Mar 1, 2020

Thanks for reporting this. Seems like an oversight on my side. Feel free to open a Pull Request fixing the escaping of the characters.

@dangoodman
Copy link

#55 should be covering this.

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

Successfully merging a pull request may close this issue.

3 participants