Hacker News new | ask | show | jobs
by pgt 2153 days ago
+1 on escaping measurement names. Quoting from their source code:

    def get_escaped_measurement_name(user_name): # ... comment omitted
        return '"\\"{}\\""'.format(user_name.replace('\\', '\\\\\\\\').replace('"', '\\"').replace('\n', '\\\\\\\\n'))
3 comments

There are some edge cases in InfluxDB where escaping queries becomes a dark art.
That looks somehow worse than regex in C literal.
Although it seems about par for the course for regexp in elisp.
Do you have a URL? Thanks!
Thanks. I love developer comments -- we've all written things like "this is hacky and ugly" in our code :)

  # Note: influxdb-python first replaces each backslash in the username with two backslashes
  # and because in influx queries, we have to escape each backslash, overall each backslash
  # must be replaced by 4 backslashes. Yes, this is hacky and ugly.
I wrote that comment 3 years ago! It definitely took me a week or two worth of work to figure out what was happening there. The problem was exacerbated by the fact that the influx cli client then had different behaviour compared to the python client. Not sure if that has been fixed, but this isn't code that I'm really proud of. :D
We all have code like that somewhere :)