Skip to content

Commit 391825e

Browse files
committed
update to_tree
1 parent b06775c commit 391825e

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

mindsdb_sql_parser/ast/mindsdb/knowledge_base.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ def __init__(
3737

3838
def to_tree(self, *args, level=0, **kwargs):
3939
ind = indent(level)
40-
storage_str = f"{ind} storage={self.storage.to_string()},\n" if self.storage else ""
41-
model_str = f"{ind} model={self.model.to_string()},\n" if self.model else ""
42-
out_str = f"""
43-
{ind}CreateKnowledgeBase(
44-
{ind} if_not_exists={self.if_not_exists},
45-
{ind} name={self.name.to_string()},
46-
{ind} from_query={self.from_query.to_tree(level=level + 1) if self.from_query else None},
47-
{model_str}{storage_str}{ind} params={self.params}
48-
{ind})
49-
"""
40+
storage_str = f"{ind} storage={self.storage.to_string()},\n" if self.storage else ""
41+
model_str = f"{ind} model={self.model.to_string()},\n" if self.model else ""
42+
out_str = f"{ind}CreateKnowledgeBase(\n" \
43+
f"{ind} if_not_exists={self.if_not_exists},\n" \
44+
f"{ind} name={self.name.to_string()},\n" \
45+
f"{ind} from_query={self.from_query.to_tree(level=level + 1) if self.from_query else None},\n" \
46+
f"{ind}{model_str}{storage_str}{ind} params={self.params}\n" \
47+
f"{ind})"
48+
5049
return out_str
5150

5251
def get_string(self, *args, **kwargs):
@@ -101,12 +100,10 @@ def __init__(
101100
self.params = params
102101
def to_tree(self, *args, level=0, **kwargs):
103102
ind = indent(level)
104-
out_str = f"""
105-
{ind}AlterKnowledgeBase(
106-
{ind} name={self.name.to_string()},
107-
{ind} params={self.params}
108-
{ind})
109-
"""
103+
out_str = f"{ind}AlterKnowledgeBase(\n" \
104+
f"{ind} name={self.name.to_string()},\n" \
105+
f"{ind} params={self.params}\n" \
106+
f"{ind})"
110107
return out_str
111108

112109
def get_string(self, *args, **kwargs):

0 commit comments

Comments
 (0)