3 ms·
+1 on escaping measurement names. Quoting from their source code: def get_escaped_measurement_name(user_name): # ... comment omitted return '"\\"{}
by pgt 6y 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'))
- hoseja 6y agoThat looks somehow worse than regex in C literal.
- contravariant 6y agoAlthough it seems about par for the course for regexp in elisp.
- mfreed 6y agoDo you have a URL? Thanks!
- ilogik 6y agohttps://github.com/metabrainz/listenbrainz-server/blob/b0846d2a/listenbrainz/utils.py#L42 https://github.com/metabrainz/listenbrainz-server/blob/b0846...
- mfreed 6y agoThanks. 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.
- iliekcomputers 6y agoI 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
- dionian 6y agoWe all have code like that somewhere :)
- sgt 6y agoThere are some edge cases in InfluxDB where escaping queries becomes a dark art.