Skip to content

Hotfix empty props at type select #275

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion notion/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ def check_schema_select_options(self, prop, values):
Check and update the prop dict with new values
"""
schema_update = False
current_options = list([p["value"].lower() for p in prop["options"]])
current_options = []
try:
current_options = list([p["value"].lower() for p in prop["options"]])
except KeyError:
logger.warning("Prop may not have options {}".format(prop))
prop["options"] = []
if not isinstance(values, list):
values = [values]
for v in values:
Expand Down
17 changes: 17 additions & 0 deletions notion/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def run_live_smoke_test(token_v2, parent_page_url_or_id):
== get_collection_schema()[prop]["options"][0]["id"]
)

# check that insert in empty props works
assert not row2.eselect
row2.eselect = "A"
assert cvb.collection.get("schema.{}.options.0.value".format("eselect")) == "A"

assert not row2.emselect
row2.emselect = ["A", "B"]
assert cvb.collection.get("schema.{}.options.0.value".format("emselect")) == "A"

# Run a filtered/sorted query using the view's default parameters
result = view.default_query().execute()
assert row1 == result[0]
Expand Down Expand Up @@ -272,6 +281,14 @@ def get_collection_schema():
},
],
},
"eselect": {
"name": "eselect",
"type": "select",
},
"emselect": {
"name": "emselect",
"type": "multi_select",
},
"LL[(": {"name": "Person", "type": "person"},
"4Jv$": {"name": "Estimated value", "type": "number"},
"OBcJ": {"name": "Where to?", "type": "url"},
Expand Down