Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
coilysiren committed Oct 22, 2023
1 parent c158a9e commit bdbe926
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/python/sql_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class SQLState:
def read_table_meta(self, table_name: str) -> dict:
return self.state.get(table_name, {}).get("metadata", {})

def read_table_rows(self, table_name: str) -> dict:
return self.state.get(table_name, {}).get("rows", {})
def read_table_rows(self, table_name: str) -> list[dict]:
return self.state.get(table_name, {}).get("rows", [])

def read_information_schema(self) -> list[dict]:
return [data["metadata"] for data in self.state.values()]
Expand Down Expand Up @@ -104,6 +104,8 @@ def insert_into(state: SQLState, *args) -> typing.Tuple[list, SQLState]:
for i, arg in enumerate(args):
if arg == "VALUES":
values_index = i
if values_index is None:
raise ValueError("VALUES not found")

keys = " ".join(args[3:values_index]).replace("(", "").replace(")", "").split(",")
keys = [key.strip() for key in keys]
Expand All @@ -130,6 +132,8 @@ def select(state: SQLState, *args) -> typing.Tuple[list, SQLState]:
from_index = i
if arg == "WHERE":
where_index = i
if from_index is None:
raise ValueError("FROM not found")

# get select keys by getting the slice of args before FROM
select_keys = " ".join(args[1:from_index]).split(",")
Expand Down

0 comments on commit bdbe926

Please sign in to comment.