Skip to content

Commit

Permalink
sheets notes and comments about _row_from_index quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
tgbugs committed Jul 27, 2023
1 parent 018f350 commit ea92cc1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pyontutils/sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ def _setup(self):

def metadata(self):
# TODO figure out the caching here
resp = (self._spreadsheet_service
resp = (self._spreadsheet_service # FIXME annoying attribute error here when _only_cache = True
.get(spreadsheetId=self._sheet_id())
.execute())
self._meta = resp
Expand Down Expand Up @@ -1082,8 +1082,10 @@ def _appendRow(self, row):
cell = self.cell_object(row_index, col_index)
self._incomplete_removes[cell] = value

def _row_from_index(self, index_column=None, value=None, row=None,
fail=False):
def _row_from_index(self, index_column=None, value=None, row=None, fail=False):
""" REMINDER: this expects the passed row to have the same structure
as the remote row """

if index_column is None:
index_column = self.index_columns[0]

Expand All @@ -1098,6 +1100,7 @@ def _row_from_index(self, index_column=None, value=None, row=None,
index_value = value

row_object = getattr(cell_index_header.column, index_value)().row

return row_object, index_value

def insert(self, *rows):
Expand Down Expand Up @@ -1143,6 +1146,7 @@ def upsert(self, *rows):
WARNING: DO NOT USE THIS IF THE PRIMARY INDEX COLUMN IS NOT UNIQUE
We do not currently have support for composite primary keys. """

# FIXME this assumes that the column headers are the same
for row in rows:
try:
row_object, index_value = self._row_from_index(row=row)
Expand Down

0 comments on commit ea92cc1

Please sign in to comment.