Skip to content

Commit

Permalink
HOTFIX: Escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Clifford committed Jan 25, 2024
1 parent 6ceac2c commit b9a915a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,23 +322,26 @@ def __init__(self, data_frame, point_settings, precision=DEFAULT_WRITE_PRECISION
else:
self.number_of_chunks = None

def escape_value(self,value):
def escape_key(self,value):
return str(value).translate(_ESCAPE_KEY)

def escape_value(self,value):
return str(value).translate(_ESCAPE_STRING)


def to_line_protocol(self, row):
# Filter out None or empty values for tags
tags = ""

tags = ",".join(
f'{self.escape_value(col)}={self.escape_value(row[self.column_indices[col]])}'
f'{self.escape_key(col)}={self.escape_key(row[self.column_indices[col]])}'
for col in self.tag_columns
if row[self.column_indices[col]] is not None and row[self.column_indices[col]] != ""
)

if self.point_settings.defaultTags:
default_tags = ",".join(
f'{self.escape_value(key)}={self.escape_value(value)}'
f'{self.escape_key(key)}={self.escape_key(value)}'
for key, value in self.point_settings.defaultTags.items()
)
# Ensure there's a comma between existing tags and default tags if both are present
Expand Down

0 comments on commit b9a915a

Please sign in to comment.