We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e835899 commit 56b030eCopy full SHA for 56b030e
scraper_service/shovel_events/utils.py
@@ -1,3 +1,4 @@
1
+import json
2
from functools import lru_cache
3
from substrateinterface.base import is_valid_ss58_address
4
from shared.clickhouse.utils import (
@@ -10,9 +11,17 @@
10
11
def format_value(value):
12
"""
13
SQL requires strings to be wrapped in single quotes
14
+ Complex types like lists with dictionaries are serialized to JSON
15
- if isinstance(value, str):
16
+ if value is None:
17
+ return "NULL"
18
+ elif isinstance(value, str):
19
return f"'{value}'"
20
+ elif isinstance(value, list):
21
+ if len(value) > 0 and all(isinstance(x, (str, int, float)) for x in value):
22
+ return value
23
+ else:
24
+ return f"'{json.dumps(value)}'"
25
else:
26
return value
27
0 commit comments