Skip to content

Commit 04522d2

Browse files
committed
feat: format polardb
1 parent 426a307 commit 04522d2

File tree

1 file changed

+49
-15
lines changed

1 file changed

+49
-15
lines changed

src/memos/graph_dbs/polardb.py

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,28 +1776,50 @@ def export_graph(
17761776

17771777
for row in edge_results:
17781778
source_agtype, target_agtype, edge_agtype = row
1779-
1779+
17801780
# Extract and clean source
1781-
source_raw = source_agtype.value if hasattr(source_agtype, "value") else str(source_agtype)
1782-
if isinstance(source_raw, str) and source_raw.startswith('"') and source_raw.endswith('"'):
1781+
source_raw = (
1782+
source_agtype.value
1783+
if hasattr(source_agtype, "value")
1784+
else str(source_agtype)
1785+
)
1786+
if (
1787+
isinstance(source_raw, str)
1788+
and source_raw.startswith('"')
1789+
and source_raw.endswith('"')
1790+
):
17831791
source = source_raw[1:-1]
17841792
else:
17851793
source = str(source_raw)
1786-
1794+
17871795
# Extract and clean target
1788-
target_raw = target_agtype.value if hasattr(target_agtype, "value") else str(target_agtype)
1789-
if isinstance(target_raw, str) and target_raw.startswith('"') and target_raw.endswith('"'):
1796+
target_raw = (
1797+
target_agtype.value
1798+
if hasattr(target_agtype, "value")
1799+
else str(target_agtype)
1800+
)
1801+
if (
1802+
isinstance(target_raw, str)
1803+
and target_raw.startswith('"')
1804+
and target_raw.endswith('"')
1805+
):
17901806
target = target_raw[1:-1]
17911807
else:
17921808
target = str(target_raw)
1793-
1809+
17941810
# Extract and clean edge type
1795-
type_raw = edge_agtype.value if hasattr(edge_agtype, "value") else str(edge_agtype)
1796-
if isinstance(type_raw, str) and type_raw.startswith('"') and type_raw.endswith('"'):
1811+
type_raw = (
1812+
edge_agtype.value if hasattr(edge_agtype, "value") else str(edge_agtype)
1813+
)
1814+
if (
1815+
isinstance(type_raw, str)
1816+
and type_raw.startswith('"')
1817+
and type_raw.endswith('"')
1818+
):
17971819
edge_type = type_raw[1:-1]
17981820
else:
17991821
edge_type = str(type_raw)
1800-
1822+
18011823
edges.append(
18021824
{
18031825
"source": source,
@@ -2782,21 +2804,33 @@ def get_edges(
27822804
for row in results:
27832805
# Extract and clean from_id
27842806
from_id_raw = row[0].value if hasattr(row[0], "value") else row[0]
2785-
if isinstance(from_id_raw, str) and from_id_raw.startswith('"') and from_id_raw.endswith('"'):
2807+
if (
2808+
isinstance(from_id_raw, str)
2809+
and from_id_raw.startswith('"')
2810+
and from_id_raw.endswith('"')
2811+
):
27862812
from_id = from_id_raw[1:-1]
27872813
else:
27882814
from_id = str(from_id_raw)
2789-
2815+
27902816
# Extract and clean to_id
27912817
to_id_raw = row[1].value if hasattr(row[1], "value") else row[1]
2792-
if isinstance(to_id_raw, str) and to_id_raw.startswith('"') and to_id_raw.endswith('"'):
2818+
if (
2819+
isinstance(to_id_raw, str)
2820+
and to_id_raw.startswith('"')
2821+
and to_id_raw.endswith('"')
2822+
):
27932823
to_id = to_id_raw[1:-1]
27942824
else:
27952825
to_id = str(to_id_raw)
2796-
2826+
27972827
# Extract and clean edge_type
27982828
edge_type_raw = row[2].value if hasattr(row[2], "value") else row[2]
2799-
if isinstance(edge_type_raw, str) and edge_type_raw.startswith('"') and edge_type_raw.endswith('"'):
2829+
if (
2830+
isinstance(edge_type_raw, str)
2831+
and edge_type_raw.startswith('"')
2832+
and edge_type_raw.endswith('"')
2833+
):
28002834
edge_type = edge_type_raw[1:-1]
28012835
else:
28022836
edge_type = str(edge_type_raw)

0 commit comments

Comments
 (0)