-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Worksheet.isSheetHidden
is not updated when Worksheet.hide()
or Worksheet.show()
used
#1201
Comments
Addendum: interaction with testsTests which test for only internal
|
Hi let's take it one by one 😉
The answer to the last point (3.) we can't... 😢 for a single reason: right after updating the spreadsheet, someone (using web UI), something (using a second gspread script) might update the spreadsheet. so while you hide the first worksheet, and then save locally that this first sheet is hidden, someone can show the first worksheet right after you. This is the major issue with distributed systems. So there's this big question about updating the local properties of a spreadsheet that comes back from time to time. So far I chose not to update it and let the user refresh the sheet properties in order to first check the state of a property before updating it. But knowing that quiet few people are asking for it, we can change that behavior and store the new property on each change knowing that it might already be outdated (or not ? we don't know until we fetch it form the API). That's a major issue that we can't solve, but we can make either choice, whichever is best for the users. |
This is interesting. I agree that someone could change any of these properties on the web, etc.. Thus keeping a local copy of the state (title/color/hidden) of the sheet up to date does not make much sense. But then, what is the point of having the @properties (e.g., Perhaps, we could change them so they are always the "newest" when asked for. So, instead of current @property
def title(self):
"""Worksheet title."""
return self._properties["title"] new @property
def title(self):
"""Worksheet title."""
return self._get_sheet_property(self, "title", "") Of course, this would increase API calls a lot if someone wanted to get all the metadata on startup. But it would always be up to date, and would remove internal state of |
yep that's a good question. To me we should:
|
I will make a branch/PR to do this, it should be an easy change. And was the original meaning of this issue. For the rest we will have to have a think. How should we record this think? |
we can create a new issue with a summary of the infos we have here, that should do it. |
I will do that now. |
Describe the bug
Worksheet.isSheetHidden
is not updated whenWorksheet.hide
orWorksheet.show
(i.e.,Worksheet._set_hidden_flag
) is used.To Reproduce
Create a spreadsheet with minimum 2 worksheets.
Expected behavior
Actual behavior
Environment info:
Additional context
Worksheet._properties
is set only whenWorksheet
is initialised.Thus, whenever a property is changed, the correct API request must be sent, and then the property must be manually updated. For example,
Worksheet.update_title
runsself._properties[["title"]] = title
:Internal behavior comparison
I had a look to see which "meta field updaters" remember (or don't!) to update the internal
Worksheet._properties
object with the update.I call a "meta field updater" anything that updates things about the spreadsheet that are not the cells, i.e., name, tab color, etc. (i.e., spreadsheet properties). They can be found by searching for requests which send an
"updateSheetProperties"
request.This is not an exhaustive list
meta field updaters which do change
Worksheet._properties
Worksheet.update_title
Worksheet.update_tab_color
meta field updaters which do not change
Worksheet._properties
Worksheet.resize
Worksheet.update_index
Worksheet.freeze
Worksheet._set_hidden_flag
(and thusWorksheet.hide
&Worksheet.show
)Thus, this is why the bug exists. In fixing this, it is probably worth fixing all 4 of these at once.
The text was updated successfully, but these errors were encountered: